Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chess Variants (I) (#35) Build a 2-player Chess Game (no-AI) Make it as modular as possible, so that It is easy to adapt to game rule changes (variants)

Similar presentations


Presentation on theme: "Chess Variants (I) (#35) Build a 2-player Chess Game (no-AI) Make it as modular as possible, so that It is easy to adapt to game rule changes (variants)"— Presentation transcript:

1 Chess Variants (I) (#35) Build a 2-player Chess Game (no-AI) Make it as modular as possible, so that It is easy to adapt to game rule changes (variants) 7 Solutions were proposed by 5 people We were able to get only 2 to run on onyx: 1.Paolo Capriotti /tmp/chess/capriotti/ 2.James Edward Gray II /tmp/chess/gray/chess ruby -Ibin:lib bin/chess

2 Chess Variants (I) (#35) Capriotti Solution: - One file - 6 Classes: Numeric, Piece, Vector, Board, MoveGenerator, ChessGame - 58 methods lines of code - No comments

3 Chess Variants (I) (#35) Gray Solution: - 1 Library with 8 classes in 8 files Bishop, Board, Queen, Knight, King, Rook, Piece, Pawn 41 methods 456 lines of pure code 303 comment lines - 8 test classes (in 8 test files) tc_bishop tc_board tc_king tc_knight tc_pawn tc_queen tc_rook tc_all ruby -Itest:lib test/ts_all.rb

4 (Anil, how many of your 6 minutes are remaining?)

5 Chess Variants (II) (#36) Challenge: Modify any of the chess game solutions to Ruby Quiz 35 to create any of 6 variant forms: 1.Fibonacci Chess 2.Gun Chess 3.Blackhole Chess 4.Fairy Chess 5.Madhouse Chess 6.Extinction Chess 7.Baseline Chess

6 Chess Variants (II) (#36) 1.Fibonacci Chess The number of moves a player makes at one time is determined by the Fibonacci number sequence. White begins by making one move, then black responds with one move. White is then allowed two (1 + 1) moves, then black gets three (1 + 2). Putting a player in check ends your turn, even if you have moves remaining. Only 1 Solution posted – by James Edward Gray, II

7 Chess Variants (II) (#36) 2. Gun Chess Chess is played as normal and the pieces that can be captured are unaltered, but a capturing piece does not move when taking an opposing piece. As long as the move is a legal capture, the opposing piece is simply removed and the capturing piece in untouched. Only 1 Solution posted – by James Edward Gray, II

8 Chess Variants (II) (#36) 3. Blackhole Chess The squares d5 and f5 are considered "blackholes". Any piece moving onto or over either square vanishes as if it was captured. A King moving onto these squares loses the game. Only 1 Solution posted – by James Edward Gray, II

9 Chess Variants (II) (#36) 4. Fairy Chess Just like normal chess, except the Queen becomes a Fairy. A Fairy can make the normal moves of a Queen or also jump exactly like a Knight. Only 1 Solution posted – by James Edward Gray, II

10 Chess Variants (II) (#36) 5. Madhouse Chess When a piece is captured, it is not removed from the board, but instead moved to the square of the capturing player's choice. No solutions posted.

11 Chess Variants (II) (#36) 6. Extinction Chess Check and checkmate no longer apply. A player wins by capturing all of a single piece type of the opposing army (both of the rooks, for example). Pawns may promote to Kings and a pawn is counted as the piece it promotes to. Promoting your last pawn is a loss, unless it results in an immediate win. No solutions posted.

12 Chess Variants (II) (#36) 7. Baseline Chess In this variation, the starting position is altered. All pawns still appear on the usual squares, but players take turns placing their major pieces along the back rank before play begins. Castling is not allowed, but the rest of the rules are as normal. No solutions posted.

13 Chess Variants (II) (#36) 7. Baseline Chess We tried to solve this. First, by modifying the Capriotti Solution After 5 hours, still couldn’t even figure out how to input a valid move Then, by modifying the Gray Solution - Solution built in 2 hours. - created 1 sub class: BaselineBoard < Board - overwrote 1 method – setup() - no input validation yet - wrote 29 lines of code

14 Chess Variants (II) (#36) 7. Baseline Chess Show the code.

15 What We Learned More About. Symbols A symbol is a bit like a constant, but you never define it. def next_turn = == :white then :black else :white end - Also, like an enumerated type: (:knight, :bishop, :queen, :pawn, …) - Each is a reference to just one object. Faster to compare than strings. Even Ruby programs needs comments to be maintainable.


Download ppt "Chess Variants (I) (#35) Build a 2-player Chess Game (no-AI) Make it as modular as possible, so that It is easy to adapt to game rule changes (variants)"

Similar presentations


Ads by Google