gistfile1.txt
· 1.0 KiB · Text
Неформатований
Playground
|| :comment: play a guessing game from 1 to 100
| :: play a guessing game from $min to $max |
:: . pick a number from $min to $max
. begin game loop
| :: begin game loop |
:print: "enter a guess"
:: .read a number
. compare guess with target
. decide on next step
| :: pick a number from $min to $max |
:target: $n
:@js: $n = tostring(Math.floor(Math.random() * (@max - @min) + @min))
| :: read a number |
:guess: $n :@js:
repeat
$n = io.read(\"*line\")
until tonumber($n)
$n = tostring(tonumber($n))
| :: compare guess with target :guess: $n :target: $n |
:state: win
| :: compare guess with target :guess: $n :target: $m |
:state: $state :target: $m :@js: "
if tonumber($n) < tonumber($m) then
$state = \"too low\"
else
$state = \"too high\"
end
"
|:: decide on next step :state: "win" |
:print: "you win!"
| decide on next step :state: $s |
:print: $s
:: begin game loop
| :print: $message |
:@js: print($message)
| 1 | || :comment: play a guessing game from 1 to 100 |
| 2 | |
| 3 | | :: play a guessing game from $min to $max | |
| 4 | :: . pick a number from $min to $max |
| 5 | . begin game loop |
| 6 | |
| 7 | | :: begin game loop | |
| 8 | :print: "enter a guess" |
| 9 | :: .read a number |
| 10 | . compare guess with target |
| 11 | . decide on next step |
| 12 | |
| 13 | | :: pick a number from $min to $max | |
| 14 | :target: $n |
| 15 | :@js: $n = tostring(Math.floor(Math.random() * (@max - @min) + @min)) |
| 16 | |
| 17 | | :: read a number | |
| 18 | :guess: $n :@js: |
| 19 | repeat |
| 20 | $n = io.read(\"*line\") |
| 21 | until tonumber($n) |
| 22 | $n = tostring(tonumber($n)) |
| 23 | |
| 24 | | :: compare guess with target :guess: $n :target: $n | |
| 25 | :state: win |
| 26 | |
| 27 | | :: compare guess with target :guess: $n :target: $m | |
| 28 | :state: $state :target: $m :@js: " |
| 29 | if tonumber($n) < tonumber($m) then |
| 30 | $state = \"too low\" |
| 31 | else |
| 32 | $state = \"too high\" |
| 33 | end |
| 34 | " |
| 35 | |
| 36 | |:: decide on next step :state: "win" | |
| 37 | :print: "you win!" |
| 38 | |
| 39 | | decide on next step :state: $s | |
| 40 | :print: $s |
| 41 | :: begin game loop |
| 42 | |
| 43 | | :print: $message | |
| 44 | :@js: print($message) |