嗨,有人可以向我解释为什么我的注射在这里不起作用吗?
我在这里正确使用注入吗?出于某种原因,一旦出现这种情况,我的代码就会陷入无限循环(通常是我的游戏中的第五步)
def cpu_block_player
winning_combinations = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
executed = 0
winning_combinations.each do |combination|
result_of_combination = ""
result_of_combination = combination.inject("") {|result, element| result + @board[element]}
if result_of_combination == "XXe" || result_of_combination == "eXX" || result_of_combination == "XeX"
executed += 1
puts executed
player_move(@current_turn, result_of_combination.index("e"))
end
break if executed >= 1
end