I figured for myself the strategy: after my turn stone count shoud be 4n+1 for examle 4+1=5 or 16+1=17
then at the end you leve your opponent with 5 stones, if he takes any amount, you take the rest, leave him 1 stone = you won!
Great implementation of the 'Nim' game, i believe