-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtic_tac_toe.imp
261 lines (218 loc) · 8.28 KB
/
tic_tac_toe.imp
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
[
TIC TAC TOE
Gra odbywa się na zmianę.
W pierwszej kolejności podajemy rząd (1, 3), następnie kolumnę (1, 3).
Jeżeli spyta cię ponownie o liczbę, to znaczy, że na tym miejscu ktoś już zaznaczył ruch.
Gra kończy się. gdy na ekranie pojawi się
111111111 222222222 888888888
111111111 222222222 888888888
111111111 222222222 888888888
111111111 222222222 888888888
111111111 222222222 888888888
111111111 222222222 888888888
gdy wygra gracz 1 - jedynki, 2 - gdy gracz 2 i 8 w przypadku remisu.
Na Gębalang w wersji 2k20::alfa przerobił: Maciej Górski
Autor: Maciej Hajduk
**"THE COFFEEWARE LICENSE" (Revision 2):**
https://github.com/okkindel/GCCompiler
]
DECLARE
rowa(1:3),
rowb(1:3),
rowc(1:3),
a, b, sum, temp, ite
BEGIN
FOR i FROM 1 TO 3 DO
rowa(i) ASSIGN 8;
ENDFOR
FOR i FROM 1 TO 3 DO
rowb(i) ASSIGN 8;
ENDFOR
FOR i FROM 1 TO 3 DO
rowc(i) ASSIGN 8;
ENDFOR
ite ASSIGN 1;
sum ASSIGN 100 TIMES rowa(1);
temp ASSIGN 10 TIMES rowa(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowa(3);
WRITE sum;
sum ASSIGN 100 TIMES rowb(1);
temp ASSIGN 10 TIMES rowb(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowb(3);
WRITE sum;
sum ASSIGN 100 TIMES rowc(1);
temp ASSIGN 10 TIMES rowc(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowc(3);
WRITE sum;
WHILE ite EQ 1 DO
WRITE 1111111111111;
READ a;
READ b;
WHILE a LE 1 DO
READ a;
ENDWHILE
WHILE a GE 3 DO
READ a;
ENDWHILE
IF a EQ 1 THEN
WHILE rowa(b) NEQ 8 DO
READ b;
ENDWHILE
rowa(b) ASSIGN 1;
ENDIF
IF a EQ 2 THEN
WHILE rowb(b) NEQ 8 DO
READ b;
ENDWHILE
rowb(b) ASSIGN 1;
ENDIF
IF a EQ 3 THEN
WHILE rowc(b) NEQ 8 DO
READ b;
ENDWHILE
rowc(b) ASSIGN 1;
ENDIF
sum ASSIGN 100 TIMES rowa(1);
temp ASSIGN 10 TIMES rowa(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowa(3);
WRITE sum;
sum ASSIGN 100 TIMES rowb(1);
temp ASSIGN 10 TIMES rowb(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowb(3);
WRITE sum;
sum ASSIGN 100 TIMES rowc(1);
temp ASSIGN 10 TIMES rowc(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowc(3);
WRITE sum;
IF rowa(1) EQ 1 THEN IF rowa(2) EQ 1 THEN IF rowa(3) EQ 1 THEN
WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowb(1) EQ 1 THEN IF rowb(2) EQ 1 THEN IF rowb(3) EQ 1 THEN
WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowc(1) EQ 1 THEN IF rowc(2) EQ 1 THEN IF rowc(3) EQ 1 THEN
WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(1) EQ 1 THEN IF rowb(1) EQ 1 THEN IF rowc(1) EQ 1 THEN
WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(2) EQ 1 THEN IF rowb(2) EQ 1 THEN IF rowc(2) EQ 1 THEN
WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(3) EQ 1 THEN IF rowb(3) EQ 1 THEN IF rowc(3) EQ 1 THEN
WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(1) EQ 1 THEN IF rowb(2) EQ 1 THEN IF rowc(3) EQ 1 THEN
WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(3) EQ 1 THEN IF rowb(2) EQ 1 THEN IF rowc(1) EQ 1 THEN
WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111; WRITE 111111111;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF ite EQ 1 THEN
IF rowa(1) NEQ 8 THEN IF rowa(2) NEQ 8 THEN IF rowa(3) NEQ 8 THEN
IF rowb(1) NEQ 8 THEN IF rowb(2) NEQ 8 THEN IF rowb(3) NEQ 8 THEN
IF rowc(1) NEQ 8 THEN IF rowc(2) NEQ 8 THEN IF rowc(3) NEQ 8 THEN
WRITE 888888888; WRITE 888888888; WRITE 888888888; WRITE 888888888; WRITE 888888888;
ite ASSIGN 0;
ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF
ENDIF
IF ite EQ 1 THEN
WRITE 2222222222222;
READ a;
READ b;
WHILE a LE 1 DO
READ a;
ENDWHILE
WHILE a GE 3 DO
READ a;
ENDWHILE
IF a EQ 1 THEN
WHILE rowa(b) NEQ 8 DO
READ b;
ENDWHILE
rowa(b) ASSIGN 2;
ENDIF
IF a EQ 2 THEN
WHILE rowb(b) NEQ 8 DO
READ b;
ENDWHILE
rowb(b) ASSIGN 2;
ENDIF
IF a EQ 3 THEN
WHILE rowc(b) NEQ 8 DO
READ b;
ENDWHILE
rowc(b) ASSIGN 2;
ENDIF
sum ASSIGN 100 TIMES rowa(1);
temp ASSIGN 10 TIMES rowa(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowa(3);
WRITE sum;
sum ASSIGN 100 TIMES rowb(1);
temp ASSIGN 10 TIMES rowb(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowb(3);
WRITE sum;
sum ASSIGN 100 TIMES rowc(1);
temp ASSIGN 10 TIMES rowc(2);
sum ASSIGN sum PLUS temp;
sum ASSIGN sum PLUS rowc(3);
WRITE sum;
ENDIF
IF rowa(1) EQ 2 THEN IF rowa(2) EQ 2 THEN IF rowa(3) EQ 2 THEN
WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowb(1) EQ 2 THEN IF rowb(2) EQ 2 THEN IF rowb(3) EQ 2 THEN
WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowc(1) EQ 2 THEN IF rowc(2) EQ 2 THEN IF rowc(3) EQ 2 THEN
WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(1) EQ 2 THEN IF rowb(1) EQ 2 THEN IF rowc(1) EQ 2 THEN
WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(2) EQ 2 THEN IF rowb(2) EQ 2 THEN IF rowc(2) EQ 2 THEN
WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(3) EQ 2 THEN IF rowb(3) EQ 2 THEN IF rowc(3) EQ 2 THEN
WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(1) EQ 2 THEN IF rowb(2) EQ 2 THEN IF rowc(3) EQ 2 THEN
WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF rowa(3) EQ 2 THEN IF rowb(2) EQ 2 THEN IF rowc(1) EQ 2 THEN
WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222; WRITE 222222222;
ite ASSIGN 0;
ENDIF ENDIF ENDIF
IF ite EQ 1 THEN
IF rowa(1) NEQ 8 THEN IF rowa(2) NEQ 8 THEN IF rowa(3) NEQ 8 THEN
IF rowb(1) NEQ 8 THEN IF rowb(2) NEQ 8 THEN IF rowb(3) NEQ 8 THEN
IF rowc(1) NEQ 8 THEN IF rowc(2) NEQ 8 THEN IF rowc(3) NEQ 8 THEN
WRITE 888888888; WRITE 888888888; WRITE 888888888; WRITE 888888888; WRITE 888888888;
ite ASSIGN 0;
ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF
ENDIF
ENDWHILE
END