-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathExamples.txt
105 lines (87 loc) · 1.86 KB
/
Examples.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Obligatory:
10 print "Hello, World!"
20 goto 10
Fibs (thanks, avpx):
0 x = 0
1 y = 1
2 z = x + y
3 x = y
4 y = z
5 print y
6 goto 2
Die roller:
10 c = 10
20 print rnd(6)+1;
30 c = c - 1
40 if c > 0 then goto 20
Guess the number:
10 n = rnd(100)+1
20 print "What's your guess? ";
30 input g
40 if n < g then print "Too High!"
50 if n > g then print "Too Low!"
60 if n != g then goto 20
70 print "Correct!"
A simple text-based Lunar Lander game:
10 a = 100 + rnd(20)
11 v = rnd(5)
12 f = 80 + rnd(10)
20 print "a: ",a,"v: ",v,"f: ",f
30 print "thrust? ";
40 input t
50 if t > f then t = 0
60 if t > 30 then t = 30
70 f = f - t
80 v = v + 4 - t
90 a = a - v
100 if a > 0 then goto 20
110 if v > 5 then print "CRASH!"
120 if v <= 5 then print "success!"
Submarine Hunt:
10 x = rnd(10)
11 y = rnd(10)
20 x = (x+rnd(3)-1)%10
21 y = (y+rnd(3)-1)%10
30 print "fire at?"
40 input a, b
50 d = min(abs(a-x),abs(b-y))
60 if d == 0 then goto 100
70 if d > 3 then print "Missed."
80 if d <= 3 then print "Close: ", d
90 goto 20
100 print "hit!"
Number Guesser: (The tables have turned!)
10 l = 0
11 h = 99
20 g = (l+h)/2
30 print "is ",g,"low, high or right?";
40 input i
50 if i == "low" then l = g
60 if i == "high" then h = g
70 if i != "right" then goto 20
NIM (two player):
10 g = 20
11 p = 0
20 print "player: ", p, "gold: ",g
21 print "take how much? ";
30 input t
31 if (t<1) or (t>3) then goto 21
40 g = g - t
50 if g <= 0 then goto 80
60 p = (p + 1) % 2
70 goto 20
80 print "Player ",p,"Loses!"
NIM (versus computer):
10 g = 20
20 print "gold: ",g,"take how much? ";
30 input t
31 if (t<1) or (t>3) then goto 20
40 g = g - t
41 if g <= 0 then goto 110
50 t = (((g % 3)+1)%3)+1
60 print "I will take ",t
70 g = g - t
80 if g >= 0 then goto 20
90 print "Argh, foiled!"
100 end
110 print "Pitiful Human!"