Class: GamesParadise::Board
- Inherits:
-
Object
- Object
- GamesParadise::Board
- Defined in:
- lib/games_paradise/tic_tac_toe/tic_tac_toe_with_AI/board.rb
Constant Summary collapse
- WINNING_PLACES =
#
WINNING_PLACES
Designate all winning places/locations.
#
[ [1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [3, 5, 7] ]
Instance Attribute Summary collapse
-
#info ⇒ Object
Returns the value of attribute info.
-
#positions_with_values ⇒ Object
Returns the value of attribute positions_with_values.
Instance Method Summary collapse
-
#display ⇒ Object
# === display.
-
#display_positions ⇒ Object
# === display_positions ========================================================================= #.
-
#initialize ⇒ Board
constructor
# === initialize ========================================================================= #.
-
#liner ⇒ Object
# === liner ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
Constructor Details
#initialize ⇒ Board
#
initialize
#
33 34 35 |
# File 'lib/games_paradise/tic_tac_toe/tic_tac_toe_with_AI/board.rb', line 33 def initialize reset end |
Instance Attribute Details
#info ⇒ Object
Returns the value of attribute info.
9 10 11 |
# File 'lib/games_paradise/tic_tac_toe/tic_tac_toe_with_AI/board.rb', line 9 def info @info end |
#positions_with_values ⇒ Object
Returns the value of attribute positions_with_values.
10 11 12 |
# File 'lib/games_paradise/tic_tac_toe/tic_tac_toe_with_AI/board.rb', line 10 def positions_with_values @positions_with_values end |
Instance Method Details
#display ⇒ Object
#
display
This method will display the game map, on the commandline.
#
78 79 80 81 82 83 84 85 86 |
# File 'lib/games_paradise/tic_tac_toe/tic_tac_toe_with_AI/board.rb', line 78 def display e e " #{self.positions_with_values["1"]} | #{self.positions_with_values["2"]} | #{self.positions_with_values["3"]} " liner e " #{self.positions_with_values["4"]} | #{self.positions_with_values["5"]} | #{self.positions_with_values["6"]} " liner e " #{self.positions_with_values["7"]} | #{self.positions_with_values["8"]} | #{self.positions_with_values["9"]} " e end |
#display_positions ⇒ Object
#
display_positions
#
56 57 58 59 60 61 62 63 64 |
# File 'lib/games_paradise/tic_tac_toe/tic_tac_toe_with_AI/board.rb', line 56 def display_positions # initial user friendly board display e e ' 1 | 2 | 3 ' liner e ' 4 | 5 | 6 ' liner e ' 7 | 8 | 9 ' e end |
#liner ⇒ Object
#
liner
#
69 70 71 |
# File 'lib/games_paradise/tic_tac_toe/tic_tac_toe_with_AI/board.rb', line 69 def liner e '-----------' end |
#reset ⇒ Object
#
reset
#
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/games_paradise/tic_tac_toe/tic_tac_toe_with_AI/board.rb', line 40 def reset # ======================================================================= # # === @positions_with_values # # Board position starts from 1 to 9 # ======================================================================= # @positions_with_values = { '1' => ' ', '2' => ' ', '3' => ' ', '4' => ' ', '5' => ' ', '6' => ' ', '7' => ' ', '8' => ' ', '9' => ' ' } end |