Right now I’m trying to create a basic tic tac toe game. Before I start coding the AI, I wanted to set up the game with two human players, and add in the computer later. I’m not exactly sure the best way to set up asking for multiple players though. (My code’s in Ruby)
num_of_users = 2
player1 = User.new
player2 = User.new
cpu = AI.new
if turn
# player1 stuff
turn = !turn
else
# player2 stuff
turn = !turn
end
This works fine for two players, but I don’t know how to adjust this for when I want to be able to play against the AI. Can someone help me with the best way to to approach this problem?
Using numbers as suffixes in variable names is usually a sign that you want an array instead.