Nim game: Difference between revisions
Content added Content deleted
(add comments to Smalltalk) |
|||
Line 1,142: | Line 1,142: | ||
| take | |
| take | |
||
<category: 'gameplay'> |
<category: 'gameplay'> |
||
take := tokens - (4 * (tokens // 4)). |
take := tokens - (4 * (tokens // 4)). "tokens % 4" |
||
Transcript nextPutAll: 'Computer takes '. |
Transcript nextPutAll: 'Computer takes '. |
||
take printOn: Transcript. |
take printOn: Transcript. |
||
Line 1,155: | Line 1,155: | ||
tokens printOn: Transcript. |
tokens printOn: Transcript. |
||
Transcript nextPutAll: ' tokens';nl;nl. |
Transcript nextPutAll: ' tokens';nl;nl. |
||
1 to: |
1 to: 3 do: [ :n | "The computer always wins on the 3rd turn" |
||
self pTurn. |
self pTurn. |
||
self printRemaining. |
self printRemaining. |