Ultima attività 6 days ago Unlisted

translated from wul

Revisione e13831ff895d415428167dbf61122f2460647995

gistfile1.txt Raw Playground
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