# File lib/libpplayer.rb, line 34 def best_move(game, die_result) me = game.current_player possible_moves = game.possible_moves(die_result, me) scored_moves = possible_moves.collect do |m| begin game.apply_move! m score = score_position(game, me) # game.undo_move! rescue GameWonNotice score = 10000 ensure game.undo_move! end puts "#{m} scores #{score}" if @verbose [m, score] end best_move = (scored_moves.max {|a, b| a[1] <=> b[1]})[0] end