In this game you will be playing against an AI. You can raise the counter by 1, 2, or 3. Then the AI will go. If the other person reaches 20, you basically lose.

Have fun!

You should let the AI go first sometimes... just to make it fair. ;)

Fun program!

@joshwood I am thinking of asking the user if they or the AI should go first. Thanks for the feedback!

Very nice! I remember playing this in school as a kid (I was a nerd).

@themaka: I did too.

My teacher teached me a trick to play this at my extra class when in was a kid. The objective is to hit n(the number that if u hit u will lose)-1 first. U have to go first if (n-1)/(k(the max value that u can add)+1)=m>0. Then u will add m. Else u have to let the opponent go first. Then on the other turns, the sum of your and your opponents point have to equal to m. But in this case (21-1)/(4+1)=0 so u have to let the bot go first but u cant do that because “0” is an invalid value so u cant win this.

But this is very good tho!!!

Good job.

@TuanNguyen8 Wow! that is really complex. I found another trick that works: I just added the a number that would make their and my number equal to 4.

HOW DO YOU WIN?!

@epicman702 You don't.

@gantr833 ... ~~win~~?

@epicman702 It is impossible to beat

The amazing game of NIM.

This game is evil.

Pure evil.

+1 though.

Super simple. Anyone could do it. The "AI" just always adds whatever number brings the total up to a multiple of four, which makes it impossible to beat.

@EzekielJeske: That was the trick I used at school.