kevin-shannon / connect4

The original vertical four in a line game.
12 stars 3 forks source link

Player that goes first should alternate #30

Closed tannerkrewson closed 3 years ago

tannerkrewson commented 4 years ago

Hmm something that might be good but there currently isn't a ticket for is nailing down how we want to define the player. Meaning like red/blue player and how that ties into who goes first. Rn in single player if you win for some reason you go from red to blue and the ai goes first. Kinda silly when we have the win counter tied to color. So obviously we want color to stay the same for the player, but should red always go first? This i think could go either way, what do you think? I would probably prefer player who moves first alternates to keep it more fair.

-@kevin-shannon

tannerkrewson commented 4 years ago

After some investigation, here is why I think the described issue is happening:

This line:

askIfPlayersWantToPlayAgain(playerToTakeTurnNow, playerToTakeTurnAfter);

shows the play again button when called. If both players click play again, playAgain(player1, player2) will be called (where playerToTakeTurnNow becomes player1, and playerToTakeTurnAfter becomes player2), which will call start(player1, player2, which will eventually start a new game off by calling this line:

nextTurn(RED, player1, player2);

Therefore, the playerToTakeTurnNow will always be red, and will always go first. And playerToTakeTurnNow could be either player, so their color could be switched between games. Very silly. 😜

tannerkrewson commented 4 years ago

I bet I never caught this because I always lose to the AI 😆

kevin-shannon commented 3 years ago

31c6c2153df60de6d140fcb8eaabd29bc01131e0