So I'm working on several 2v2 programs like tic-tac-toe, connect four and battleship. Generally what would be the best way to alternate players?
So I'm working on several 2v2 programs like tic-tac-toe, connect four and battleship. Generally what would be the best way to alternate players?
An if statement usually works.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Welcome to the forum, ktype!
Most chess programs use the simple: player=!player, where player is a bool or int value acting like a bool, with value of true/false, or 1/0.