c - Marienbad game wrong XOR -


i working on programming puzzle, need code ai best current move win game.

the loser 1 picks last sticks.

here board :

|   |||   |||||   |   

so use xor operator on numbers number of sticks need remove give me : 1 xor 3 xor 5 xor 1 = 6

now :
1 xor 6 = 7 (since increased won't select case)
3 xor 6 = 5 (since increased won't select case)
5 xor 6 = 3 (since decreased reduce 5 3 removing 2 sticks.

the problem playing in "misere" version of game loser if 1 take last sticks , seems method perfect normal play winner 1 take last stick.

could explain me should in case.

the winning strategy isn't xor piles , remove many sticks 1 pile. instead, want choose number of sticks remove such xor of piles zero. example, if remove 2 sticks pile containing 5 sticks, remaining xor 1 xor 3 xor 3 xor 1 = 0.

hope helps!


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -