I would like to know better way to implement alternatly switching of moves between computer and human in small game. Computer plays first, than human plays by clicking some of the buttons, again computer, again human etc.
frame.computerPlaysRandom();
while(!frame.end)
{
//if(frame.alreadyExecuted)
// {
frame.computerPlaysRandom();
// }
// frame.computerPlaysRandom();
}
I thought of putting boolean variable alreadyExecuted at the end of humanPlays method, but it doesnt work.
public void computerPlaysRandom()
{
......
if(activeColour == RED)
{
.....
}
activeColour = YELLOW;
}
I dont like this way first of all it looks unnatural like human and computer play at exactly same time. And another that it is constantly looping.
I tried my best to explain, please give me suggestion of better way to do this.