Tictactoe QB64 stuff
#1
Tictactoe programs written in QB64:

.rar   tictactoe.rar (Size: 3.17 KB / Downloads: 1)
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply
#2
nth dimensional three player tictactoe:

Code:
REM three-player nth-tictactoe v1.0a pd 2018
REM $dynamic
DIM SHARED b(1) AS INTEGER
startloop:
DO
    PRINT "Board size(3-10)";: INPUT z
    IF z >= 3 AND z <= 10 THEN
        N = z ^ 2
        EXIT DO
    END IF
LOOP
REDIM b(N) AS INTEGER
FOR l = 1 TO N: b(l) = 0: NEXT: c = 0: w = 0
GOSUB displayboard
DO
    FOR q = 1 TO 3
        GOSUB getuserinput
        b(x) = q ' store array selection
        c = c + 1: IF c = N THEN EXIT DO
        GOSUB displayboard
        IF w THEN PRINT "Player"; w; "wins": GOTO endloop
    NEXT
LOOP
GOSUB displayboard
IF w THEN PRINT "Player"; w; "wins" ELSE PRINT "Game is draw"
endloop:
PRINT "Play again(y/n)";
DO
    _LIMIT 100
    x$ = INKEY$
    IF LCASE$(x$) = "y" THEN PRINT: GOTO startloop
    IF LCASE$(x$) = "n" THEN PRINT: EXIT DO
LOOP
END

getuserinput:
DO
    PRINT "Player#"; q; " position(1-"; LTRIM$(STR$(N)); ")";: INPUT x
    IF x >= 1 AND x <= N THEN
        IF b(x) <> 0 THEN
            PRINT "Not empty slot"
        ELSE
            EXIT DO
        END IF
    ELSE
        PRINT "Value is not 1-"; LTRIM$(STR$(N))
    END IF
LOOP
RETURN

displayboard:
FOR l = 1 TO N - SQR(N) + 1 STEP SQR(N)
    FOR m = l TO l + SQR(N) - 1
        IF b(m) = 1 THEN
            PRINT "X ";
        ELSE
            IF b(m) = 2 THEN
                PRINT "O ";
            ELSE
                IF b(m) = 3 THEN
                    PRINT "Z ";
                ELSE
                    PRINT ". ";
                END IF
            END IF
        END IF
        IF m < l + SQR(N) - 1 THEN PRINT "| ";
    NEXT
    PRINT
    IF l < N - SQR(N) + 1 THEN PRINT STRING$((SQR(N) - 1) * 4 + 1, "-")
NEXT

REM checkboard : returns winner

REM horizontal
FOR l = 1 TO N - SQR(N) + 1 STEP SQR(N)
    IF b(l) > 0 THEN
        w = b(l)
        FOR m = l TO l + SQR(N) - 2
            IF b(m) <> b(m + 1) THEN w = 0: EXIT FOR
        NEXT
        IF w THEN RETURN
    END IF
NEXT

REM vertical
FOR l = 1 TO SQR(N)
    IF b(l) > 0 THEN
        w = b(l)
        FOR m = l TO l + N - SQR(N) STEP SQR(N)
            IF b(l) <> b(m) THEN w = 0: EXIT FOR
        NEXT
        IF w THEN RETURN
    END IF
NEXT

REM diagonal
IF b(1) > 0 THEN
    w = b(1)
    FOR l = 1 TO N - SQR(N) - 1 STEP SQR(N) + 1
        IF b(l) <> b(l + SQR(N) + 1) THEN w = 0: EXIT FOR
    NEXT
END IF
IF w THEN RETURN

IF b(SQR(N)) > 0 THEN
    w = b(SQR(N))
    FOR l = SQR(N) TO N - SQR(N) - 1 STEP SQR(N) - 1
        IF b(l) <> b(l + SQR(N) - 1) THEN w = 0: EXIT FOR
    NEXT
END IF
IF w THEN RETURN
RETURN
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply
#3
nth-player nth-dimensional tictactoe program QB64

Code:
REM nth-player nth-tictactoe v1.0a pd 2018
REM $dynamic
DIM SHARED b(1) AS INTEGER
startloop:

DO
    PRINT "Board size(3-9)";: INPUT z
    z = INT(z)
    IF z >= 3 AND z <= 9 THEN
        N = z ^ 2
        EXIT DO
    END IF
LOOP
REDIM b(N) AS INTEGER

DO
    PRINT "Number of players(2-"; LTRIM$(STR$(SQR(N))); ")";: INPUT z
    z = INT(z)
    IF z >= 2 AND z <= SQR(N) THEN
        p = z
        EXIT DO
    END IF
LOOP

FOR l = 1 TO N: b(l) = 0: NEXT: c = 0: w = 0
GOSUB displayboard
DO
    FOR q = 1 TO p
        GOSUB getuserinput
        b(x) = q ' store array selection
        c = c + 1: IF c = N THEN EXIT DO
        GOSUB displayboard
        IF w THEN PRINT "Player"; w; "wins": GOTO endloop
    NEXT
LOOP
GOSUB displayboard
IF w THEN PRINT "Player"; w; "wins" ELSE PRINT "Game is draw"
endloop:
PRINT "Play again(y/n)";
DO
    _LIMIT 100
    x$ = INKEY$
    IF LCASE$(x$) = "y" THEN PRINT: GOTO startloop
    IF LCASE$(x$) = "n" THEN PRINT: EXIT DO
LOOP
END

getuserinput:
DO
    PRINT "Player#"; q; " position(1-"; LTRIM$(STR$(N)); ")";: INPUT x
    x = INT(x)
    IF x >= 1 AND x <= N THEN
        IF b(x) <> 0 THEN
            PRINT "Not empty slot"
        ELSE
            EXIT DO
        END IF
    ELSE
        PRINT "Value is not 1-"; LTRIM$(STR$(N))
    END IF
LOOP
RETURN

displayboard:
FOR l = 1 TO N - SQR(N) + 1 STEP SQR(N)
    FOR m = l TO l + SQR(N) - 1
        IF b(m) > 0 THEN
            PRINT LTRIM$(STR$(b(m))); " ";
        ELSE
            PRINT ". ";
        END IF
        IF m < l + SQR(N) - 1 THEN PRINT "| ";
    NEXT
    PRINT
    IF l < N - SQR(N) + 1 THEN PRINT STRING$((SQR(N) - 1) * 4 + 1, "-")
NEXT

REM checkboard : returns winner

REM horizontal
FOR l = 1 TO N - SQR(N) + 1 STEP SQR(N)
    IF b(l) > 0 THEN
        w = b(l)
        FOR m = l TO l + SQR(N) - 2
            IF b(m) <> b(m + 1) THEN w = 0: EXIT FOR
        NEXT
        IF w THEN RETURN
    END IF
NEXT

REM vertical
FOR l = 1 TO SQR(N)
    IF b(l) > 0 THEN
        w = b(l)
        FOR m = l TO l + N - SQR(N) STEP SQR(N)
            IF b(l) <> b(m) THEN w = 0: EXIT FOR
        NEXT
        IF w THEN RETURN
    END IF
NEXT

REM diagonal
IF b(1) > 0 THEN
    w = b(1)
    FOR l = 1 TO N - SQR(N) - 1 STEP SQR(N) + 1
        IF b(l) <> b(l + SQR(N) + 1) THEN w = 0: EXIT FOR
    NEXT
END IF
IF w THEN RETURN

IF b(SQR(N)) > 0 THEN
    w = b(SQR(N))
    FOR l = SQR(N) TO N - SQR(N) - 1 STEP SQR(N) - 1
        IF b(l) <> b(l + SQR(N) - 1) THEN w = 0: EXIT FOR
    NEXT
END IF
IF w THEN RETURN
RETURN
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply