Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Finish renaming square to position
Browse files Browse the repository at this point in the history
  • Loading branch information
edgenard committed Apr 3, 2018
1 parent 6550657 commit 194ce3a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tic-tac-toe/tic_tac_toe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Copy link
@medwards1771

medwards1771 Apr 3, 2018

Contributor

Yes, this makes more sense to me

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

Expand All @@ -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.