class Board
- Board
- Reference
- Object
Defined in:
board.crConstant Summary
-
CELL_INDEXES =
0..(NUMBER_OF_CELLS_IN_BOARD - 1)
-
EMPTY_CELL =
0
-
ENCODED_STATE_RADIX =
3
-
NUMBER_OF_CELLS_IN_BOARD =
NUMBER_OF_CELLS_PER_ROW ** 2
-
NUMBER_OF_CELLS_PER_ROW =
3
-
PLAYERS =
[1, 2]
-
WINS =
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
Constructors
Class Method Summary
-
.from_state(state)
state is a transformation of each of the boards cells to digits in a base-3 number
- .other_player(player)
Instance Method Summary
-
#==(other)
Returns
false
(other can only be aValue
here). -
#apply_move(move, as_player)
Player here is a number, 1 or # 2 indicating 1st or 2nd
- #game_over?
- #is_win_for?(player)
- #move_options
- #next_time_could_be_win_for?(player)
- #next_time_is_game_over?
- #next_time_is_win_for?(player)
- #no_moves_left?
- #to_a : Array(Int32)
-
#to_s(tokens = PLAYERS.map do |p|
p.to_s
end.reduce do |p1, p2|
p1 + p2
end)
Returns a nicely readable and concise string representation of this object, typically intended for users.
-
#to_state
state is a transformation of each of the boards cells to digits in a base-3 number
- #winner
Constructor Detail
Class Method Detail
def self.from_state(state)
#
state is a transformation of each of the boards cells to digits in a base-3 number
Instance Method Detail
def ==(other)
#
Description copied from class Reference
Returns false
(other can only be a Value
here).
Description copied from class Object
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.