NIM Game

sorry I removed the code because the instructor of the class I am in wanted me too.
Last edited on
It compiles so what doesnt work ?
it seems to get stuck about halfway through and never finishes the program
Added statements to report the number of marbles all thru the program using various language so I could see where it hung exactly:

while (numMarbles > 1);

On that spurious semicolon.

After removing it, the program gets into an infinite loop with the number of marbles never changing... "The computers turn" over and over and over

Added:
turn = 1-turn;

at the end of your while loop, so the player gets a turn (or the computer, depending how it started..) and it started reporting the computers turn then the players turn every other as it should. The game still isn't functioning properly, the computer takes away zero marbles, and when it got down to 5 marbles there was no valid move left to make for the player, but at least it's not hanging anymore... I'll leave the rest to you.

Finding them semicolons can be a real headache huh? :-)
OMG!!!!!!!!!

it was one semicolon!!!!!!!!!

Thank you very much!

I really didn't think to even look at the semicolon.

Thank you!
Topic archived. No new replies allowed.