Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
70
Task/Nim-game/Pebble/nim-game.pebble
Normal file
70
Task/Nim-game/Pebble/nim-game.pebble
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
;NIM game example program for x86 DOS
|
||||
;Compiles with Pebble to com file under 1kb.
|
||||
|
||||
program examples\nim
|
||||
|
||||
data
|
||||
|
||||
int tokens[12]
|
||||
int take[0]
|
||||
|
||||
begin
|
||||
|
||||
call intro
|
||||
|
||||
label gameloop
|
||||
|
||||
echo "There are"
|
||||
echo [tokens]
|
||||
echo " tokens remaining."
|
||||
crlf
|
||||
echo "How many would you like to take? "
|
||||
input [take]
|
||||
|
||||
if [take] > 3 | [take] < 1 then
|
||||
|
||||
echo "You must take between 1 to 3 tokens."
|
||||
|
||||
endif
|
||||
|
||||
if [take] <= 3 & [take] >= 1 then
|
||||
|
||||
[tokens] = [tokens] - [take]
|
||||
|
||||
if [tokens] = 0 then
|
||||
|
||||
bell
|
||||
echo "Congratulations. You got the last token."
|
||||
pause
|
||||
kill
|
||||
|
||||
endif
|
||||
|
||||
[take] = 4 - [take]
|
||||
|
||||
echo "I will take"
|
||||
echo [take]
|
||||
echo " tokens.
|
||||
[tokens] = [tokens] - [take]
|
||||
|
||||
if [tokens] = 0 then
|
||||
|
||||
echo "I got the last token. I win. Better luck next time."
|
||||
pause
|
||||
kill
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
goto gameloop
|
||||
|
||||
end
|
||||
|
||||
sub intro
|
||||
|
||||
cls
|
||||
echo "NIM game"
|
||||
crlf
|
||||
|
||||
ret
|
||||
Loading…
Add table
Add a link
Reference in a new issue