You are not logged in or registered. Please login or register to use the full functionality of this board...
The QB64 Edition
Othello in QB64 - Printable Version

+- The QB64 Edition (http://www.thejoyfulprogrammer.com/qb64/forum)
+-- Forum: QB64 (/forumdisplay.php?fid=483)
+--- Forum: QB64 Coders Delight (/forumdisplay.php?fid=8)
+---- Forum: Video Games of the Programming Guru's (/forumdisplay.php?fid=445)
+----- Forum: Donald Foster (/forumdisplay.php?fid=449)
+------ Forum: Donald Foster's games (/forumdisplay.php?fid=461)
+------ Thread: Othello in QB64 (/showthread.php?tid=118)



Othello in QB64 - Donald Foster - 07-30-2014 10:50 PM

I originally wrote Othello on then TRS-80 Model 4.

Controls: Arrow keys to move cursor. Enter to choose location.


RE: Othello in QB64 - Anthony.R.Brown - 07-31-2014 04:52 AM

Very Nice Donald Wink

Can your Version Beat other Versions of Othello ?


Anthony.


RE: Othello in QB64 - Donald Foster - 07-31-2014 09:00 PM

Quote:
Very Nice Donald Wink

Can your Version Beat other Versions of Othello ?


Anthony.
I wouldn't say they beat other versions, many of them use A.I. and mine is a two player game. This version was reproduced from the Tandy 2000 listing I wrote over 25 years ago. It is a quick mock up and some features I made in the original game is not completed yet. 

I originally wrote this on the TRS-80 Model 4 over 30 years ago and did not use a cursor an arrow keys. Instead it used letters and numbers representing board positions. And was in B&W.

After I finish making the rest of my games, I planning a version 2 of this game that uses a mouse to select and animated sprite graphics to add appeal to the game. The pieces will be animated flipping from one side of the piece to the other side. Actually I was going to try the animated pieces with this version, but I wanted to quickly get it done and this version is more true to the way it was made on the Tandy 2000.

Thank you for checking it out Anthony. Rolleyes

Donald


RE: Othello in QB64 - Anthony.R.Brown - 08-01-2014 03:32 AM

Sounds Great Donald I will look out for Version 2 and if I can help with any A.I Ideas then I will try...

I am Quite good at figuring out (IF A + B  = C ) Type of Stuff Wink


Anthony.


RE: Othello in QB64 - Donald Foster - 08-01-2014 09:05 PM

Quote:
Sounds Great Donald I will look out for Version 2 and if I can help with any A.I Ideas then I will try...

I am Quite good at figuring out (IF A + B  = C ) Type of Stuff Wink


Anthony.
Thank you very much Anthony. It may not be for quite some time. I have many more games to get done first.

But I am thinking about using objects for that game. I have previously messed around with GameMaker a little before I got into QB64 and learned a little about objects, sprites, events, actions and a little GML which is an extension of C++.

Maybe by the time I get most of my games done, I'll try to learn some A.I. for new projects.

Thanks again.

Donald
 


RE: Othello in QB64 - Donald Foster - 08-04-2014 12:53 AM

I made some changes to Othello.
1) I changed the board color to a lighter green.
2) I changed the cursor from a small block to a larger yellow outline.
3) I added gray blocks to indicate player's legal moves.

I removed some of the cluttered coded that did not function. When I originally wrote the code on the Tandy 2000, I must had used a key input ASCII code of 18 to display player's legal moves and 127 to remove the blocks that displayed the legal moves. I changed it so it shows the player's legal moves all the time.

You have to realize I going by memory on how the games looked and performed written over 25 years ago on the Tandy 2000. However each game may have some slight changes for the better.

Donald

Code Snippet: [Select]
_TITLE "Othello by Donald L. Foster Jr."


SCREEN _NEWIMAGE(1010, 736, 256)

_PALETTECOLOR 1, _RGB32(150, 150, 150) '    Grey
_PALETTECOLOR 2, _RGB32(0, 100, 0) '         Green
_PALETTECOLOR 3, _RGB32(1, 1, 1) '          Lt Black
_PALETTECOLOR 4, _RGB32(255, 255, 0) '        Yellow

A = 1: B = 2: C = 4: D = 4: E = 4: F = 4: O = 2: T = 0
C(1) = 15: C(2) = 0
D(4, 4) = 2: D(4, 5) = 1: D(5, 4) = 1: D(5, 5) = 2
F(1) = 2: F(2) = 2

LINE (0, 0)-(736, 736), 2, BF: LINE (7, 7)-(729, 729), 0, BF: LINE (737, 0)-(1010, 737), 1, BF

X = 0
FOR Z = 1 TO 8
    W = 0
    FOR Y = 1 TO 8
        LINE (10 + W, 10 + X)-(96 + W, 96 + X), 2, BF
        A(Z, Y) = 53 + W: B(Z, Y) = 53 + X
        IF D(Z, Y) > 0 THEN CIRCLE (A(Z, Y), B(Z, Y)), 37, C(D(Z, Y)): PAINT (A(Z, Y), B(Z, Y)), C(D(Z, Y))
        W = W + 90
    NEXT
    X = X + 90
NEXT

CIRCLE (188, 188), 8, 3: PAINT (188, 188), 3: CIRCLE (548, 188), 8, 3: PAINT (548, 188), 3: CIRCLE (188, 548), 8, 3: PAINT (188, 548), 3: CIRCLE (548, 548), 8, 3: PAINT (548, 548), 3

COLOR 15, 1
LOCATE 3, 101: PRINT "O  T  H  E  L  L  O";

LINE (820, 90)-(926, 196), 2, BF: LINE (827, 97)-(919, 189), 0, BF: LINE (830, 100)-(916, 186), 2, BF

LOCATE 14, 106: PRINT "Player:";
COLOR 0, 1
LOCATE 20, 100: PRINT "Player: 1   Score:";
LOCATE 22, 100: PRINT "Player: 2   Score:";

STARTGAME:
CIRCLE (873, 143), 37, C(A): PAINT (873, 143), C(A)

COLOR 15, 1
LOCATE 14, 113: PRINT A;
COLOR 0, 1
LOCATE 20, 118: PRINT F(1);
LOCATE 22, 118: PRINT F(2);

IF T = 0 THEN GOTO LINE310

CURSOR1:
LINE (A(C, D) - 39, B(C, D) - 39)-(A(C, D) + 39, B(C, D) + 39), 2, B
LINE (A(E, F) - 39, B(E, F) - 39)-(A(E, F) + 39, B(E, F) + 39), 4, B

GETINPUT:
A$ = INKEY$
IF A$ = "" THEN GOTO GETINPUT
IF (F = 8) * (A$ = CHR$(0) + CHR$(77)) THEN C = E: D = F: F = 1: GOTO CURSOR1
IF A$ = CHR$(0) + CHR$(77) THEN C = E: D = F: F = F + 1: GOTO CURSOR1
IF (F = 1) * (A$ = CHR$(0) + CHR$(75)) THEN C = E: D = F: F = 8: GOTO CURSOR1
IF A$ = CHR$(0) + CHR$(75) THEN C = E: D = F: F = F - 1: GOTO CURSOR1
IF (E = 1) * (A$ = CHR$(0) + CHR$(72)) THEN C = E: D = F: E = 8: GOTO CURSOR1
IF A$ = CHR$(0) + CHR$(72) THEN C = E: D = F: E = E - 1: GOTO CURSOR1
IF (E = 8) * (A$ = CHR$(0) + CHR$(80)) THEN C = E: D = F: E = 1: GOTO CURSOR1
IF A$ = CHR$(0) + CHR$(80) THEN C = E: D = F: E = E + 1: GOTO CURSOR1
IF ASC(A$) <> 13 THEN GOTO GETINPUT

IF D(E, F) > 0 THEN GOTO GETINPUT

G = 0: H = 0: I = 0: J = 0: K = 0: L = 0: M = 0: N = 0

LINE180:
IF E - G - 1 >= 1 THEN
    IF D(E - G - 1, F) = B THEN G = G + 1: GOTO LINE180 ELSE IF D(E - G - 1, F) = 0 THEN G = 0
ELSE G = 0
END IF

LINE190:
IF F + H + 1 <= 8 THEN
    IF D(E, F + H + 1) = B THEN H = H + 1: GOTO LINE190 ELSE IF D(E, F + H + 1) = 0 THEN H = 0
ELSE H = 0
END IF

LINE200:
IF E + I + 1 <= 8 THEN
    IF D(E + I + 1, F) = B THEN I = I + 1: GOTO LINE200 ELSE IF D(E + I + 1, F) = 0 THEN I = 0
ELSE I = 0
END IF

LINE210:
IF F - J - 1 >= 1 THEN
    IF D(E, F - J - 1) = B THEN J = J + 1: GOTO LINE210 ELSE IF D(E, F - J - 1) = 0 THEN J = 0
ELSE J = 0
END IF

LINE220:
IF (E - K - 1 >= 1) * (F + K + 1 <= 8) THEN
    IF D(E - K - 1, F + K + 1) = B THEN K = K + 1: GOTO LINE220 ELSE IF D(E - K - 1, F + K + 1) = 0 THEN K = 0
ELSE K = 0
END IF

LINE230:
IF (E + L + 1 <= 8) * (F + L + 1 <= 8) THEN
    IF D(E + L + 1, F + L + 1) = B THEN L = L + 1: GOTO LINE230 ELSE IF D(E + L + 1, F + L + 1) = 0 THEN L = 0
ELSE L = 0
END IF

LINE240:
IF (E + M + 1 <= 8) * (F - M - 1 >= 1) THEN
    IF D(E + M + 1, F - M - 1) = B THEN M = M + 1: GOTO LINE240 ELSE IF D(E + M + 1, F - M - 1) = 0 THEN M = 0
ELSE M = 0
END IF

LINE250:
IF (E - N - 1 >= 1) * (F - N - 1 >= 1) THEN
    IF D(E - N - 1, F - N - 1) = B THEN N = N + 1: GOTO LINE250 ELSE IF D(E - N - 1, F - N - 1) = 0 THEN N = 0
ELSE N = 0
END IF

IF (G = 0) * (H = 0) * (I = 0) * (J = 0) * (K = 0) * (L = 0) * (M = 0) * (N = 0) THEN GOTO GETINPUT

FOR Z = 1 TO 8
    FOR Y = 1 TO 8
        IF T(Z, Y) = 1 THEN LINE (A(Z, Y) - 10, B(Z, Y) - 10)-(A(Z, Y) + 10, B(Z, Y) + 10), 2, BF
    NEXT
NEXT

O = A: F(A) = F(A) + 1: D(E, F) = A: CIRCLE (A(E, F), B(E, F)), 37, C(A): PAINT (A(E, F), B(E, F)), C(A)

IF G > 0 THEN FOR Z = 1 TO G: D(E - Z, F) = A: CIRCLE (A(E - Z, F), B(E - Z, F)), 37, C(A): PAINT (A(E - Z, F), B(E - Z, F)), C(A): NEXT
IF H > 0 THEN FOR Z = 1 TO H: D(E, F + Z) = A: CIRCLE (A(E, F + Z), B(E, F + Z)), 37, C(A): PAINT (A(E, F + Z), B(E, F + Z)), C(A): NEXT
IF I > 0 THEN FOR Z = 1 TO I: D(E + Z, F) = A: CIRCLE (A(E + Z, F), B(E + Z, F)), 37, C(A): PAINT (A(E + Z, F), B(E + Z, F)), C(A): NEXT
IF J > 0 THEN FOR Z = 1 TO J: D(E, F - Z) = A: CIRCLE (A(E, F - Z), B(E, F - Z)), 37, C(A): PAINT (A(E, F - Z), B(E, F - Z)), C(A): NEXT
IF K > 0 THEN FOR Z = 1 TO K: D(E - Z, F + Z) = A: CIRCLE (A(E - Z, F + Z), B(E - Z, F + Z)), 37, C(A): PAINT (A(E - Z, F + Z), B(E - Z, F + Z)), C(A): NEXT
IF L > 0 THEN FOR Z = 1 TO L: D(E + Z, F + Z) = A: CIRCLE (A(E + Z, F + Z), B(E + Z, F + Z)), 37, C(A): PAINT (A(E + Z, F + Z), B(E + Z, F + Z)), C(A): NEXT
IF M > 0 THEN FOR Z = 1 TO M: D(E + Z, F - Z) = A: CIRCLE (A(E + Z, F - Z), B(E + Z, F - Z)), 37, C(A): PAINT (A(E + Z, F - Z), B(E + Z, F - Z)), C(A): NEXT
IF N > 0 THEN FOR Z = 1 TO N: D(E - Z, F - Z) = A: CIRCLE (A(E - Z, F - Z), B(E - Z, F - Z)), 37, C(A): PAINT (A(E - Z, F - Z), B(E - Z, F - Z)), C(A): NEXT

F(A) = F(A) + G + H + I + J + K + L + M + N
F(B) = F(B) - G - H - I - J - K - L - M - N

LOCATE 20, 118: PRINT F(1);
LOCATE 22, 118: PRINT F(2);

LINE310:
E(1) = 0: E(2) = 0
FOR Z = 1 TO 8: FOR Y = 1 TO 8: T(Z, Y) = 0: NEXT: NEXT
S = 0
FOR Z = 1 TO 8
    FOR Y = 1 TO 8
        IF D(Z, Y) = A THEN E(A) = E(A) + 1: GOTO ENDLOOP
        IF D(Z, Y) = B THEN E(B) = E(B) + 1: GOTO ENDLOOP

        G = 0: H = 0: I = 0: J = 0: K = 0: L = 0: M = 0: N = 0

        LINE320:
        IF Z - G - 1 >= 1 THEN
            IF D(Z - G - 1, Y) = O THEN G = G + 1: GOTO LINE320 ELSE IF D(Z - G - 1, Y) = 0 THEN G = 0
        ELSE G = 0
        END IF

        LINE330:
        IF Y + H + 1 <= 8 THEN
            IF D(Z, Y + H + 1) = O THEN H = H + 1: GOTO LINE330 ELSE IF D(Z, Y + H + 1) = 0 THEN H = 0
        ELSE H = 0
        END IF

        LINE340:
        IF Z + I + 1 <= 8 THEN
            IF D(Z + I + 1, Y) = O THEN I = I + 1: GOTO LINE340 ELSE IF D(Z + I + 1, Y) = 0 THEN I = 0
        ELSE I = 0
        END IF

        LINE350:
        IF Y - J - 1 >= 1 THEN
            IF D(Z, Y - J - 1) = O THEN J = J + 1: GOTO LINE350 ELSE IF D(Z, Y - J - 1) = 0 THEN J = 0
        ELSE J = 0
        END IF

        LINE360:
        IF (Z - K - 1 >= 1) * (Y + K + 1 <= 8) THEN
            IF D(Z - K - 1, Y + K + 1) = O THEN K = K + 1: GOTO LINE360 ELSE IF D(Z - K - 1, Y + K + 1) = 0 THEN K = 0
        ELSE K = 0
        END IF

        LINE370:
        IF (Z + L + 1 <= 8) * (Y + L + 1 <= 8) THEN
            IF D(Z + L + 1, Y + L + 1) = O THEN L = L + 1: GOTO LINE370 ELSE IF D(Z + L + 1, Y + L + 1) = 0 THEN L = 0
        ELSE L = 0
        END IF

        LINE380:
        IF (Z + M + 1 <= 8) * (Y - M - 1 >= 1) THEN
            IF D(Z + M + 1, Y - M - 1) = O THEN M = M + 1: GOTO LINE380 ELSE IF D(Z + M + 1, Y - M - 1) = 0 THEN M = 0
        ELSE M = 0
        END IF

        LINE390:
        IF (Z - N - 1 >= 1) * (Y - N - 1 >= 1) THEN
            IF D(Z - N - 1, Y - N - 1) = O THEN N = N + 1: GOTO LINE390 ELSE IF D(Z - N - 1, Y - N - 1) = 0 THEN N = 0
        ELSE N = 0
        END IF

        IF (G > 0) + (H > 0) + (I > 0) + (J > 0) + (K > 0) + (L > 0) + (M > 0) + (N > 0) THEN S = 1: T(Z, Y) = 1

        ENDLOOP:
    NEXT
NEXT

IF S = 1 THEN
    FOR Z = 1 TO 8
        FOR Y = 1 TO 8
            IF T(Z, Y) = 1 THEN LINE (A(Z, Y) - 10, B(Z, Y) - 10)-(A(Z, Y) + 10, B(Z, Y) + 10), 1, BF
        NEXT
    NEXT
END IF

IF T = 0 THEN T = 1: GOTO CURSOR1
IF (S = 1) * (O = A) THEN GOTO LINE1000
IF O = A THEN O = B: GOTO LINE310
IF (S = 1) * (O = B) THEN C = E: D = F: E = 4: F = 4: GOTO CURSOR1

LINE (A(E, F) - 39, B(E, F) - 39)-(A(E, F) + 39, B(E, F) + 39), 2, B

IF E(1) > E(2) THEN R = 1 ELSE IF E(1) < E(2) THEN R = 2 ELSE R = 3

COLOR 15, 1
LOCATE 32, 98

IF R < 3 THEN
    PRINT "Player"; R; "is the Winner !!";
    CIRCLE (873, 143), 37, C(R): PAINT (873, 143), C(R)
    LOCATE 14, 113: PRINT R;
END IF

IF R = 3 THEN
    PRINT " There has been a Tie.";
    PAINT (873, 143), 2
    LOCATE 14, 114: PRINT " ";
END IF

LOCATE 34, 101: PRINT "Play Another Game ?";

ANOTHERGAME:
A$ = INKEY$: IF A$ = "" THEN GOTO ANOTHERGAME
IF (A$ = "y") + (A$ = "Y") THEN RUN
IF (A$ = "n") + (A$ = "N") THEN END
GOTO ANOTHERGAME

LINE1000:
C = E: D = F: E = 4: F = 4
SWAP A, B: GOTO STARTGAME