Permalink
Browse files

Finish renaming square to position

  • Loading branch information...
edgenard committed Apr 3, 2018
1 parent 6550657 commit 194ce3a1b23d1bdc973bcbb0a861a7b97589fe39
Showing with 6 additions and 6 deletions.
  1. +6 −6 tic-tac-toe/tic_tac_toe.rb
@@ -2,7 +2,7 @@ class Game
attr_accessor :board

NO_MOVE = -1
SQUARES_ON_BOARD = (0..8)
POSITIONS_ON_BOARD = (0..8)

def initialize(s, position=nil, player=nil)
@board = s.dup
@@ -11,9 +11,9 @@ def initialize(s, position=nil, player=nil)

def best_move_for(player)
move = NO_MOVE
SQUARES_ON_BOARD.each do |square|
if square_unoccupied?(square)
move = square if winning_move?(square, player) || move == NO_MOVE
POSITIONS_ON_BOARD.each do |position|

This comment has been minimized.

@medwards1771

medwards1771 Apr 3, 2018

Collaborator

Yes, this makes more sense to me

if position_unoccupied?(position)
move = position if winning_move?(position, player) || move == NO_MOVE
end
end

@@ -37,7 +37,7 @@ def winning_player(position)
end
end

def square_unoccupied?(square)
board[square] == '-'
def position_unoccupied?(position)
board[position] == '-'
end
end

0 comments on commit 194ce3a

Please sign in to comment.