From e69a42b6bc5b0177c218daceb389701fecd7366f Mon Sep 17 00:00:00 2001 From: Chris Reuter Date: Mon, 29 Nov 2021 13:37:56 -0500 Subject: [PATCH] Bug fix for Ruby version of Checkers We were using the result of Board.make_move!() to determine whether the current player could jump again. This worked by accident but was not part of the specified interface. I've changed the code to ignore the return value and instead query the move object itself. --- 23_Checkers/ruby/checkers.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/23_Checkers/ruby/checkers.rb b/23_Checkers/ruby/checkers.rb index cac0ab06..ec65e8d5 100644 --- a/23_Checkers/ruby/checkers.rb +++ b/23_Checkers/ruby/checkers.rb @@ -139,10 +139,10 @@ def my_turn(board, jumpStart = nil) # Do the move puts "My move: #{bestMove}" - canMoveAgain = board.make_move!(bestMove) + board.make_move!(bestMove) # Repeat (recursively) if we can make another jump - my_turn(board, bestMove.to) if canMoveAgain + my_turn(board, bestMove.to) if bestMove.jump? # No loss yet! return true @@ -182,8 +182,8 @@ def players_turn(board) return false if !from && !move return true if from && !move - canMoveAgain = board.make_move!(move) - return true unless canMoveAgain + board.make_move!(move) + return true unless move.jump? # If the player can jump again, repeat from the new position. from = move.to