QB64 Phoenix Edition
The Brain Game from Australia - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Games (https://qb64phoenix.com/forum/forumdisplay.php?fid=57)
+----- Forum: Donald Foster (https://qb64phoenix.com/forum/forumdisplay.php?fid=58)
+----- Thread: The Brain Game from Australia (/showthread.php?tid=2290)



The Brain Game from Australia - SMcNeill - 12-23-2023

Quote:Hello All,.

The Brain from Australia is a 2 player board game originally made on my Tandy 2000. I could not find a copy of the rules, I peeked at my source code from the Tandy 2000 printout to figure out the rules. Hopefully I got it right.

The Game is played on a 13x13 game board with alternating orange and green spots on the board for players to place their pieces on. There are also groups of 2x2 grey squares grouped under the color spots around the board. One player plays with 26 white pieces and the other plays with 26 black pieces.

The game came be won by placing 4 of your pieces in a row and skipping one space in between each of your pieces or by occupying all 4 grey squares that are grouped of your color.

If after each player has placed all 26 of their pieces on the board and there is no winner yet, places can move the their pieces already on the board.

Hope you enjoy playing.

Donald

   

Code: (Select All)
_Title "The Brain Game From Australia by Donald L. Foster Jr. 2018"

Screen _NewImage(1020, 735, 256)

_PaletteColor 1, _RGB32(200, 200, 200) ' Lt Grey
_PaletteColor 2, _RGB32(180, 180, 180) ' Med Grey
_PaletteColor 3, _RGB32(255, 100, 0) ' Orange
_PaletteColor 4, _RGB32(0, 200, 50) ' Green
_PaletteColor 5, _RGB32(0, 50, 255) ' Blue

Dim Player As Integer
Dim Opponent As Integer

Dim V As Integer
Dim W As Integer
Dim X As Integer
Dim Y As Integer
Dim Z As Integer

Dim PlayerColor(2) As Integer
Dim PlayerPieces(2) As Integer

Dim X(2) As Integer

Dim BoardX(13, 13) As Integer
Dim BoardY(13, 13) As Integer

Dim StorageX(2, 26) As Integer
Dim StorageY(2, 26) As Integer

Dim BoardPlayer(13, 13) As Integer
Dim BoardSquare(13, 13) As Integer
Dim WinningSquare(13, 13) As Integer

Dim C(2) As String
Dim Cursor As String

Player = 1: Opponent = 2
PlayerColor(1) = 15: PlayerColor(2) = 0
PlayerPieces(1) = 1: PlayerPieces(2) = 1

C$(1) = "C15": C$(2) = "C0"
Cursor$ = "C0BU25RL26D50R50U50L51D51R52U52L52"

' Setup Grey Board Squares
For Z = 2 To 11 Step 3: For Y = 2 To 11 Step 3: BoardSquare(Z, Y) = 1: BoardSquare(Z, Y + 1) = 1: BoardSquare(Z + 1, Y) = 1: BoardSquare(Z + 1, Y + 1) = 1: Next: Next

Cls , 5
Color 15, 5: Locate 2, 96: Print "The Brain Game from Australia";


' Daw Board
Line (10, 10)-(725, 725), 2, BF: Line (16, 16)-(719, 719), 3, BF: Line (20, 20)-(715, 715), 15, BF
X = 56
For Z = 1 To 13
W = 56
For Y = 1 To 13
If BoardSquare(Z, Y) = 1 Then Line (W - 25, X - 25)-(W + 25, X + 25), 1, BF
If (Z + Y) / 2 = Fix((Z + Y) / 2) Then V = 3 Else V = 4
Circle (W, X), 24, V: Paint (W, X), V
BoardX(Z, Y) = W: BoardY(Z, Y) = X
W = W + 52
Next
X = X + 52
Next

' Setup Storage Pieces
X = 145: X(1) = 1: X(2) = 1
For Z = 1 To 13
W = 780
For Y = 1 To 4
If Y < 3 Then V = 1 Else V = 2
Circle (W, X), 20, PlayerColor(V): Paint (W, X), PlayerColor(V)
StorageX(V, X(V)) = W: StorageY(V, X(V)) = X
W = W + 60: X(V) = X(V) + 1
Next
X = X + 44
Next

StartGame:
' Display Player Indicator
Circle (872, 65), 21, PlayerColor(Player): Paint (872, 65), PlayerColor(Player)
Locate 7, 106: Print "Player:"; Player;

Locate 45, 94: If PlayerPieces(Player) = 27 Then Print " Choose a Piece to Move. "; Else Print " Choose Location to Place Piece. ";

GetMouseInput1:
While (_MouseInput)
For Z = 1 To 13
For Y = 1 To 13
If _MouseX > BoardX(Z, Y) - 26 And _MouseX < BoardX(Z, Y) + 26 And _MouseY > BoardY(Z, Y) - 26 And _MouseY < BoardY(Z, Y) + 26 And _MouseButton(1) = -1 Then
If (BoardPlayer(Z, Y) = 0 And PlayerPieces(Player) < 27) Or (BoardPlayer(Z, Y) = Player And PlayerPieces(Player) = 27) Then
Row1 = Z: Column1 = Y: GoSub ButtonRelease: GoTo EndMouseInput1
End If
End If
Next
Next
Wend
GoTo GetMouseInput1

EndMouseInput1:
If PlayerPieces(Player) < 27 Then
Pieces = PlayerPieces(Player)
BoardPlayer(Row1, Column1) = Player
Circle (BoardX(Row1, Column1), BoardY(Row1, Column1)), 20, PlayerColor(Player): Paint (BoardX(Row1, Column1), BoardY(Row1, Column1)), PlayerColor(Player)
Line (StorageX(Player, Pieces) - 21, StorageY(Player, Pieces) - 21)-(StorageX(Player, Pieces) + 21, StorageY(Player, Pieces) + 21), 5, BF
PlayerPieces(Player) = PlayerPieces(Player) + 1
GoTo EndTurn
End If

' Place Cursor Around Select Piece
PSet (BoardX(Row1, Column1), BoardY(Row1, Column1)), PlayerColor(Player): Draw C$(Player) + Cursor$

Locate 45, 94: Print " Choose a Location to Move to. ";

GetMouseInput2:
While (_MouseInput)
For Z = 1 To 13
For Y = 1 To 13
If _MouseX > BoardX(Z, Y) - 26 And _MouseX < BoardX(Z, Y) + 26 And _MouseY > BoardY(Z, Y) - 26 And _MouseY < BoardY(Z, Y) + 26 And _MouseButton(1) = -1 Then
If BoardPlayer(Z, Y) = 0 Then Row2 = Z: Column2 = Y: GoSub ButtonRelease: GoTo EndMouseInput2
End If
Next
Next
Wend
GoTo GetMouseInput2

EndMouseInput2:
BoardPlayer(Row1, Column1) = 0: BoardPlayer(Row2, Column2) = Player
Line (BoardX(Row1, Column1) - 26, BoardY(Row1, Column1) - 26)-(BoardX(Row1, Column1) + 26, BoardY(Row1, Column1) + 26), 15, BF
If BoardSquare(Row1, Column1) = 1 Then Line (BoardX(Row1, Column1) - 25, BoardY(Row1, Column1) - 25)-(BoardX(Row1, Column1) + 25, BoardY(Row1, Column1) + 25), 1, BF
If (Row1 + Column1) / 2 = Fix((Row1 + Column1) / 2) Then V = 3 Else V = 4
Circle (BoardX(Row1, Column1), BoardY(Row1, Column1)), 24, V: Paint (BoardX(Row1, Column1), BoardY(Row1, Column1)), V
Circle (BoardX(Row2, Column2), BoardY(Row2, Column2)), 20, PlayerColor(Player): Paint (BoardX(Row2, Column2), BoardY(Row2, Column2)), PlayerColor(Player)

EndTurn:
' Set WinningSquares to Zero
For Z = 1 To 13: For Y = 1 To 13: WinningSquare(Z, Y) = 0: Next: Next

' Check for Winner
X = 0
For Z = 2 To 11 Step 3
For Y = 2 To 11 Step 3
If BoardPlayer(Z, Y) = Player And BoardPlayer(Z, Y + 1) = Player And BoardPlayer(Z + 1, Y) = Player And BoardPlayer(Z + 1, Y + 1) = Player Then
X = 1: WinningSquare(Z, Y) = 1: WinningSquare(Z, Y + 1) = 1: WinningSquare(Z + 1, Y) = 1: WinningSquare(Z + 1, Y + 1) = 1
End If
Next
Next

For Z = 1 To 7
For Y = 1 To 13
If BoardPlayer(Y, Z) = Player And BoardPlayer(Y, Z + 2) = Player And BoardPlayer(Y, Z + 4) = Player And BoardPlayer(Y, Z + 6) = Player Then
X = 1: WinningSquare(Y, Z) = 1: WinningSquare(Y, Z + 2) = 1: WinningSquare(Y, Z + 4) = 1: WinningSquare(Y, Z + 6) = 1
End If
If BoardPlayer(Z, Y) = Player And BoardPlayer(Z + 2, Y) = Player And BoardPlayer(Z + 4, Y) = Player And BoardPlayer(Z + 6, Y) = Player Then
X = 1: WinningSquare(Z, Y) = 1: WinningSquare(Z + 2, Y) = 1: WinningSquare(Z + 4, Y) = 1: WinningSquare(Z + 6, Y) = 1
End If
Next
Next

For Z = 1 To 7
For Y = 1 To 7
If BoardPlayer(Z, Y) = Player And BoardPlayer(Z + 2, Y + 2) = Player And BoardPlayer(Z + 4, Y + 4) = Player And BoardPlayer(Z + 6, Y + 6) = Player Then
X = 1: WinningSquare(Z, Y) = 1: WinningSquare(Z + 2, Y + 2) = 1: WinningSquare(Z + 4, Y + 4) = 1: WinningSquare(Z + 6, Y + 6) = 1
End If
If BoardPlayer(14 - Y, Z) = Player And BoardPlayer(12 - Y, Z + 2) = Player And BoardPlayer(10 - Y, Z + 4) = Player And BoardPlayer(8 - Y, Z + 6) = Player Then
X = 1: WinningSquare(14 - Y, Z) = 1: WinningSquare(12 - Y, Z + 2) = 1: WinningSquare(10 - Y, Z + 4) = 1: WinningSquare(8 - Y, Z + 6) = 1
End If
Next
Next

If X = 1 GoTo Winner

Swap Player, Opponent: GoTo StartGame


ButtonRelease:
While (_MouseInput)
If _MouseButton(1) = 0 Then Return
Wend
GoTo ButtonRelease


Winner:
For Z = 1 To 13
For Y = 1 To 13
If WinningSquare(Z, Y) = 1 Then PSet (BoardX(Z, Y), BoardY(Z, Y)), PlayerColor(Player): Draw C$(Player) + Cursor$
Next
Next

Locate 45, 94: Print " Winner! Play Again? ( Y / N ) ";

YorN:
A$ = UCase$(InKey$)
If A$ = "" GoTo YorN
If A$ = "Y" Then Run
If A$ = "N" Then System
GoTo YorN