the NIM is a game where you have two (or more) piles of stones. Each player can remove stones from one pile on every turn. Whoever take the last stone wins.
The trick is that depending on the configuration if you have the choise to be first or second - you always have winning strategy. However if you make even a single mistake - the other oponent have a winning strategy immediately. The Fruit game is exactly the same - if you make a single mistake the computer wins (even wrongly choosing to be first or second).
The whole trick to solve it mathematically is to convert the number of piles into binary sum without transfer. For example:
011 3 Heap A
011 3 Heap B
001 1 Heap C
---
001
* 1+1+1 = (1+1)+1 = 0+1 = 1
1+1+0 = (1+1)+0 = 0+0 = 0
0+0+0 = 0
The Theorem is that:
1. Every
non-null (not 000) can be converted to full one by removing stones from one of the heaps
2. A null sum cannot remain num sum if you remove stone(s) from any the heaps
And finally - if your oponent is in null sum - it means that you win you win
For example you have
011 3 Heap A
010 2 Heap B
001 1 Heap C
---
000
No matter how many stones from which pile he take - he will make it a non-null sum... And on you will immediately convert him to a null one... He will end up in 1 stone in heap A and 1 stone in heap B and he have nothing to do but loose