gistfile1.txt
· 945 B · Text
原始檔案
Playground
|| :: 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 = Math.floor(Math.random() * (100 - 1) + 1)"
| :: read a number |
:comment: replacing this with a hardcoded number because i can't figure js out
:guess: 48
| :: 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
| 1 | || :: 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 = Math.floor(Math.random() * (100 - 1) + 1)" |
| 16 | |
| 17 | | :: read a number | |
| 18 | :comment: replacing this with a hardcoded number because i can't figure js out |
| 19 | :guess: 48 |
| 20 | |
| 21 | | :: compare guess with target :guess: $n :target: $n | |
| 22 | :state: win |
| 23 | |
| 24 | | :: compare guess with target :guess: $n :target: $m | |
| 25 | :state: $state :target: $m :@js: " |
| 26 | if tonumber($n) < tonumber($m) then |
| 27 | $state = "too low" |
| 28 | else |
| 29 | $state = "too high" |
| 30 | end |
| 31 | " |
| 32 | |
| 33 | | :: decide on next step :state: "win" | |
| 34 | :print: "you win!" |
| 35 | |
| 36 | | :: decide on next step :state: $s | |
| 37 | :print: $s |
| 38 | :: begin game loop |