Jump to content

Tic-tac-toe: Difference between revisions

Line 2,836:
[https://easylang.online/apps/tictactoe.html Run it]
 
<syntaxhighlight lang="text">len f[] 9
len f[] 9
state = 0
textsize 14
Line 2,853 ⟶ 2,854:
line 86 56
linewidth 2.5
for i range= 1 to 9
f[i] = 0
.
Line 2,861 ⟶ 2,862:
.
func draw ind . .
c = (ind - 1) mod 3
r = (ind - 1) div 3
x = c * 28 + 20
y = r * 28 + 14
Line 2,880 ⟶ 2,881:
.
func sum3 a d . st .
for i range= 1 to 3
s += f[a]
a += d
Line 2,892 ⟶ 2,893:
func rate . res done .
res = 0
for i range= 1 step 3 to 7
call sum3 i * 3 1 res
.
for i range= 1 to 3
call sum3 i 3 res
.
call sum3 01 4 res
call sum3 23 2 res
cnt = 1
for i range= 1 to 9
if f[i] = 0
cnt += 1
Line 2,933 ⟶ 2,934:
.
.
mov = (mov + 1) mod 9 + 1
until mov = start or rval >= beta
.
Line 2,962 ⟶ 2,963:
.
func human . .
mov = floor ((mouse_x - 6) / 28) + 3 * floor (mouse_y / 28) + 1
if f[mov] = 0
f[mov] = 1
Line 2,988 ⟶ 2,989:
.
.
call init</syntaxhighlight>
</syntaxhighlight>
 
=={{header|Erlang}}==
2,043

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.