Tic Tac Toe in 3DAuthor:
@qbguySource: [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] Forum
URL:
/forum/index.php?topic=56.0]http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=56.0Version: 2008
Tags: [3d], [game], [ai], [mouse]
Description:
The goal is to get four in a row while preventing the computer from doing the same. Move by clicking the mouse. Source Code:
E(1) = 254: E(2) = 18: E(3) = 2: E(4) = 1: E(5) = 2: E(6) = 66: E(7) = 255
Q = 564: G = 628: L = 768
PEEKB(K) = 128
PEEKB(K) = 128
100 CALL GETMOVE
(C
, R
, p
) X = 16 * (p - 1) + 4 * (R - 1) + C - 1
CALL MAKEMOVE
(C
, R
, p
, 1)
1000
PEEKB(G + X) = 128 + M
Y = S + (K - L) \ 4: V = PEEKB(Y)
V = V - 128
V = M + 128
V = V + M + 128
V = 0
PEEKB(Y) = V
2000
W = 0: T = 1
V = PEEKB(K)
3000
PEEKB(K) = 0
N = PEEKB(K) - 128
Z = E(N + 4)
F = L + 4 * (K - S)
X = PEEKB(J)
V = PEEKB(Q + X)
V
= V
+ Z:
IF Z
>= 254 THEN V
= Z
PEEKB(Q + X) = V
V9 = 0
V = PEEKB(Q + K)
PEEKB(Q + K) = V
3800 X = 0
X = X + 1
4000 P4 = 16
p = 0
p = p + PEEKB(PEEKB(J) + G) - 128
P4 = p: V4 = 0: N4 = 0
X1 = PEEKB(J)
V = PEEKB(Q + X1)
V4 = V: N4 = 1
N4 = N4 + 1
X = X1
7000
p = X \ 16 + 1
X = X - 16 * (p - 1)
R = X \ 4 + 1
CALL MAKEMOVE
(C
, R
, p
, 4)
INIT:
L = 768
PEEKB(L + K) = K
L = L + 64
a = 4: B = 16
a = 16: B = 1
S
= 1: a
= 5: B
= 16:
GOSUB 19000S
= 13: a
= -3: B
= 16:
GOSUB 19000S
= 1: a
= 20: B
= 1:
GOSUB 19000S
= 49: a
= -12: B
= 1:
GOSUB 19000S
= 1: a
= 17: B
= 4:
GOSUB 19000S
= 49: a
= -15: B
= 4:
GOSUB 19000S
= 1: D
= 21:
GOSUB 18000S
= 16: D
= 11:
GOSUB 18000S
= 4: D
= 19:
GOSUB 18000S
= 13: D
= 13:
GOSUB 18000
18000
PEEKB(L) = K - 1: L = L + 1
19000
PEEKB(L) = K - 1: L = L + 1
DRAWBD:
LINE (0, 0)-(639, 479), 7, BF
LINE (23, 23)-(616, 456), 0, B
LINE (24, 24)-(615, 455), 14, BF
GRID:
LINE (120 + 20 * K
, Y
- 20 * K
)-(440 + 20 * K
, Y
- 20 * K
), 0 LINE (120 + 80 * K
, Y
)-(200 + 80 * K
, Y
- 80), 0 LINE (117 - K
, Y
+ 2)-(201 - K
, Y
- 82), 0 LINE (437 + K
, Y
+ 2)-(521 + K
, Y
- 82), 0 LINE (117 - K
, Y
+ K
+ 1)-(437 + K
, Y
+ K
+ 1), 0 LINE (201 - K
, Y
- 81 - K
)-(521 + K
, Y
- 81 - K
), 0
GETPOS:
CALL getmouse
(XX
, YY
, ZZ
) Z = (YY - 30) \ 100 + 1
Y
= ((YY
- 30) \
20) MOD 5 X = (XX + YY - 150 - 100 * Z) \ 80 + 1
SUB MAKEMOVE
(X
, Y
, Z
, COLOUR
) CIRCLE (80 * X
- 20 * Y
+ 170, 100 * Z
+ 20 * Y
- 60), 35, 8, , , 4 * (8 / 35) / 3 CIRCLE (80 * X
- 20 * Y
+ 170, 100 * Z
+ 20 * Y
- 60), 15, 8, , , 4 * (3 / 15) / 3
SUB SHOWWIN
(C
, R
, p
, COLOUR
) NDX = 0
ID
= POINT(80 * (C
+ K
* DC
) - 20 * (R
+ K
* DR
) + 170, 100 * (p
+ K
* DP
) + 20 * (R
+ K
* DR
) - 60) CC(NDX) = C + K * DC
RR(NDX) = R + K * DR
PP(NDX) = p + K * DP
NDX = NDX + 1
SHOW:
CIRCLE (80 * CC
(K
) - 20 * RR
(K
) + 170, 100 * PP
(K
) + 20 * RR
(K
) - 60), 35, COLOUR
+ 8, , , 4 * (8 / 35) / 3
SUB getmouse
(x%
, y%
, b%
) b% = 0
wheel% = 0