Nim game: Difference between revisions
Content added Content deleted
m (→{{header|Red}}) |
Basicgames (talk | contribs) |
||
Line 1,166: | Line 1,166: | ||
=={{header|Craft Basic}}== |
=={{header|Craft Basic}}== |
||
<syntaxhighlight lang="basic">title "NIM" |
<syntaxhighlight lang="basic">title "NIM" |
||
bgcolor 0,180,0 |
|||
cls |
|||
wait |
|||
let h = 12 |
let h = 12 |
||
label loop |
|||
do |
|||
print "There are ", h ," tokens remaining." |
print "There are ", h ," tokens remaining." |
||
Line 1,180: | Line 1,184: | ||
endif |
endif |
||
if |
if h - t < 0 then |
||
print "You cannot take that many. There's only ", h ," left." |
|||
endif |
|||
if t <= 3 and t >= 1 and h - t >= 0 then |
|||
let h = h - t |
let h = h - t |
||
Line 1,192: | Line 1,202: | ||
let t = 4 - t |
let t = 4 - t |
||
if h >= 15 then |
|||
let t = 3 |
|||
endif |
|||
if h <= 3 then |
|||
let t = h |
|||
endif |
|||
print "I will take ", t ," tokens." |
print "I will take ", t ," tokens." |
||
let h = h - t |
let h = h - t |
||
Line 1,204: | Line 1,227: | ||
endif |
endif |
||
loop</syntaxhighlight> |
goto loop</syntaxhighlight> |
||
=={{header|Crystal}}== |
=={{header|Crystal}}== |