Final Ruby project from TOP
Specification from The Odin Project
-
Do it the TDD way.
-
Update README regularly and ahead of doing things so I can document the journey better.
-
Find the easiest problem to solve and make it the starting point.
-
A promising starting point is the pieces with the pawn, bishop and rook.
-
Maybe something like
a1.up
returninga2
anda1.left
returningnil
used to move things around? Seems like pawns need colour-specific move rules. -
The pieces should hold their colour and position as instance variables.
-
At first I should not worry about piece collision, the board is necessary for pieces to become aware of that.
-
After all movement is figured out I can start involving the board.
-
The board is probably going to be made out of an array of Square objects that let me store coordinates and what they're occupied by if applicable.
-
Not sure if I need to store all pieces of a player in an instance variable. This is how I imagine the message flow to look like:
a) PLAYER INPUT =
start_position
end_position
,b) check whether the piece at
start_position
is owned by the player,c) check whether the move is legal,
d) make the move,
e) check if it is a pawn at the opposite end of the board and act accordingly,
f) check for checks, check-mates and ties,
g) pass turn.
So it seems like no need for the board to hold the pieces in a separate variable from the Square board itself.
Make note of f), the tie-checking means I have to store the history of moves somehow. This should be as easy as throwing them into an array.
-
This is probably the moment to figure some basic display going. Make it a separate class.
-
I might want to include some possible move highlighting for better UX.
-
Only at this point I'd really worry about Player creation and the entire game loop.
-
As for serialization, the Game class should be the one to be serialized - all we need is the info who's playing, whose turn it is and what is the board state.
-
This means I'd include some Driver class or script to make this easy, just like in Connect Four or Hangman.
-
Spice up the display.
-
Do the same with the README.
-
Rejoice!
-
Do it the TDD way.
So far so good, I think. Still having problems writing tests, though. I have to be more outside-in. -
Update README regularly and ahead of doing things so I can document the journey better.
Maybe should do this more often. -
Find the easiest problem to solve and make it the starting point.
-
A promising starting point is the pieces with the pawn, bishop and rook.
Pawn is absolutely not the best starting point. Looking back, maybeSquare
was the correct starting point. -
Maybe something like
a1.up
returninga2
anda1.left
returningnil
used to move things around? Seems like pawns need colour-specific move rules. *Went for a different approach where I verify coordinates like'a2'
against per-Piecelegal?
method. -
The pieces should hold their colour and position as instance variables.
It is the case. -
At first I should not worry about piece collision, the board is necessary for pieces to become aware of that.
This is true too, I think I have basics of collision down now. -
After all movement is figured out I can start involving the board.
Turns out, my tests from back when had to be corrected multiple times because they weren't robust enough resulting in buggy movement rules. -
The board is probably going to be made out of an array of Square objects that let me store coordinates and what they're occupied by if applicable.
Well, it is a hash ofSquare
objects so close enough. -
Not sure if I need to store all pieces of a player in an instance variable. This is how I imagine the message flow to look like:
a) PLAYER INPUT =
start_position
end_position
,b) check whether the piece at
start_position
is owned by the player,c) check whether the move is legal,
d) make the move,
e) check if it is a pawn at the opposite end of the board and act accordingly,
f) check for checks, check-mates and ties,
g) pass turn.
So it seems like no need for the board to hold the pieces in a separate variable from the Square board itself.
Make note of f), the tie-checking means I have to store the history of moves somehow. This should be as easy as throwing them into an array.
Haven't gotten to player inputs at all, guess I am more or less at c). -
This is probably the moment to figure some basic display going. Make it a separate class.
Made a small detour at some point, colours are off right now but otherwise I have a starting point here.