Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redo Board Game
#1
Quote:Hello All,

Thanks to the new features of v1.2, I was able to write this game in just 2 days. My biggest problem has been careless mistakes, misspelled variable names that can take days, weeks or months to find.

Redo is a 2 player board game played on a 7x8 board with 28 double sided pieces. Each player has 14 pieces lined up in the last 2 columns on their side of the board. Player 1 plays the white side pieces and player 2 plays the red. Piece are similar to those in Othello with the same goal, to have the most pieces flipped to their color at the end of the game. The game is tracked by points. The game ends in 1 of 2 ways, if neither player can make any move or if both players skip their turn consecutively.

player's pieces move forward direction only, straight, diagonally forward right or diagonally forward left. The can not move sideways or backwards. A single piece counts as 1 point. A single piece can move 1 space in it's allowed direction and land on 1 of it's own single pieces, then a tower is formed of the 2 pieces together. The tower is identified by having double sets of rings in it. However, the tower only counts for 1 point and now you have less pieces on the board your color. But, you can use the tower to jump over an opponent's piece, moving in it's allowed direction, and landing in an empty space just beyond the jumped piece. The jumped piece is flipped to your color.

After a piece is moved, some of the pieces surrounding it is flipped to your color. The piece that flip is in front you, straight, diagonally forward left and diagonally forward right and both sides. And, of course if you jump over a piece, that pieces is also flipped, even if it's behind you.

If on your turn, the only move you can make is forming a tower, than you can skip your turn. But only if it is the only move you can make. There is a Pass Move but that is grey during normal game play. If making towers is the only moves left, then the button should change to white and you are allowed to pass your turn by pressing the button and the play goes to the next player. If by chance that player on its next turn also presses the pass Move button, the game will end.

At the end of the game, if both players have the same score, the game ends in a tie, else the winner is the player with the highest score.

Hope you enjoy playing.

Donald

   


.docx   Redo Board Game Rules.docx (Size: 341.47 KB / Downloads: 21)

Code: (Select All)
Option _Explicit

_Title "Redo - Programmed by Donald L. Foster Jr. 2018"

Screen _NewImage(1084, 734, 256)

_PaletteColor 1, _RGB32(99, 29, 0) 'Board Color
_PaletteColor 2, _RGB32(255, 255, 255) ' Player 1 Piece Color
_PaletteColor 3, _RGB32(220, 0, 0) ' Player 2 Piece Color
_PaletteColor 4, _RGB32(222, 222, 0) ' Yellow Color
_PaletteColor 5, _RGB32(0, 227, 0) ' Cursor Color
_PaletteColor 6, _RGB32(80, 80, 80) ' Pass Move Grey Color

_Limit 10

Dim A As String
Dim U As Integer
Dim V As Integer
Dim W As Integer
Dim X As Integer
Dim Y As _Unsigned _Byte
Dim Z As _Unsigned _Byte

Dim X1 As _Unsigned Integer
Dim X2 As _Unsigned Integer
Dim X3 As _Unsigned Integer
Dim X4 As _Unsigned Integer

Dim Player As _Unsigned _Byte
Dim Opponent As _Unsigned _Byte
Dim Winner As _Unsigned _Byte
Dim NoMoves As _Unsigned _Byte
Dim PassMove As _Unsigned _Byte
Dim Passed As _Unsigned _Byte
Dim BoardX1 As _Unsigned Integer
Dim BoardY1 As _Unsigned Integer
Dim BoardX2 As _Unsigned Integer
Dim BoardY2 As _Unsigned Integer

Dim Piece As _Unsigned _Byte

Dim Row1 As _Unsigned _Byte
Dim Column1 As _Unsigned _Byte
Dim Row2 As _Unsigned _Byte
Dim Column2 As _Unsigned _Byte

Dim PlayerColor(2) As Integer
Dim Score(2) As _Unsigned _Byte

Dim BoardX(7, 8) As _Unsigned Integer
Dim BoardY(7, 8) As _Unsigned Integer
Dim BoardPlayer(7, 8) As _Unsigned _Byte
Dim BoardPiece(7, 8) As _Unsigned _Byte
Dim Playable(9, 10) As _Unsigned _Byte

Dim Cursor As String
Dim Cursor1 As String

Player = 1: Opponent = 2: NoMoves = 0: PassMove = 0: Passed = 0

PlayerColor(1) = 15: PlayerColor(2) = 3: Score(1) = 14: Score(2) = 14

Cursor$ = "BU46BL46C5D92R92U92L92BF3D86R86U86L86BH1P5,5"
Cursor1$ = "BU46BL46C1D92R92U92L92BF3D86R86U86L86BH1P1,1"

' Draw Board
Line (10, 10)-(820, 724), 1, BF: Line (30, 30)-(800, 704), 15, BF
X = 79
For Z = 1 To 7
W = 79
For Y = 1 To 8
Line (W - 46, X - 46)-(W + 46, X + 46), 1, BF
If Y < 3 Then BoardPlayer(Z, Y) = 1: BoardPiece(Z, Y) = 1: Circle (W, X), 40, 15: Paint (W, X), 15
If Y > 6 Then BoardPlayer(Z, Y) = 2: BoardPiece(Z, Y) = 1: Circle (W, X), 40, 3: Paint (W, X), 3
BoardX(Z, Y) = W: BoardY(Z, Y) = X
W = W + 96
Next
X = X + 96
Next

Locate 2, 112: Print "R E D O";

Locate 16, 112: Print "S C O R E S";
Locate 17, 110: Print "--------------------";
Locate 19, 114: Print "Player 1:";
Locate 21, 114: Print "Player 2:";

StartGame:
' Draw Player Indicator
Circle (949, 100), 40, PlayerColor(Player): Paint (949, 100), PlayerColor(Player)
Color 15, 0: Locate 11, 115: Print "Player:"; Player;

' Draw Scores
Color 4, 0: Locate 19, 123: Print Score(1);
Color 4, 0: Locate 21, 123: Print Score(2);

' Check Playable Moves
For Z = 1 To 7
For Y = 1 To 8
If BoardPlayer(Z, Y) = Player Then Piece = BoardPiece(Z, Y): GoSub CheckPlayableMoves
Next
Next

' Check if No Moves
If X = 0 Then
Color 4, 0: Locate 45, 107: Print " No Moves to Play";: Color 15, 0: Print " <ENTER> ";
PressENTER: A$ = InKey$: If A$ = "" GoTo PressENTER Else If Asc(A$) <> 13 GoTo PressENTER
NoMoves = NoMoves + 1: If NoMoves = 2 GoTo Winner Else GoTo EndTurn
End If

' Check if Tower Move is The Only Move, Allow Pass Move
If V = 0 And X = 1 Then PassMove = 1 Else PassMove = 0

' Draw Pass Move Button
If PassMove = 1 Then W = 15 Else W = 6
Color W, 0: Locate 38, 111: Print "P A S S M O V E";
Line (850, 570)-(1054, 630), W, B

Color 4, 0: Locate 45, 107: Print " Choose A Piece To Move ";

ChooseAPieceInput:
Do While _MouseInput
If _MouseButton(1) = -1 And _MouseX > 850 And _MouseX < 1054 And _MouseY > 570 And _MouseY < 630 And PassMove = 1 Then
Passed = Passed + 1: GoSub ReleaseMouseButton: GoTo EndTurn
End If
For Z = 1 To 7
For Y = 1 To 8
If _MouseButton(1) = -1 And _MouseX > BoardX(Z, Y) - 47 And _MouseX < BoardX(Z, Y) + 47 And _MouseY > BoardY(Z, Y) - 47 And _MouseY < BoardY(Z, Y) + 47 Then
If BoardPlayer(Z, Y) = Player Then Row1 = Z: Column1 = Y: GoSub ReleaseMouseButton: GoTo EndChoice1
End If
Next
Next
Loop
GoTo ChooseAPieceInput

EndChoice1:
NoMoves = 0: Passed = 0: Piece = BoardPiece(Row1, Column1): BoardX1 = BoardX(Row1, Column1): BoardY1 = BoardY(Row1, Column1)

' Set Playable Moves to 0
For Z = 1 To 7: For Y = 1 To 8: Playable(Z, Y) = 0: Next: Next

' Check Playable Moves
Playable(Row1, Column1) = 1: Z = Row1: Y = Column1: GoSub CheckPlayableMoves: If X = 0 GoTo ChooseAPieceInput

' Draw Cursor
PSet (BoardX1, BoardY1), PlayerColor(Player): Draw Cursor

Color 4, 0: Locate 45, 107: Print "Choose Location To Move To";

ChooseALocationInput:
Do While _MouseInput
For Z = 1 To 7
For Y = 1 To 8
If _MouseButton(1) = -1 And _MouseX > BoardX(Z, Y) - 44 And _MouseX < BoardX(Z, Y) + 44 And _MouseY > BoardY(Z, Y) - 44 And _MouseY < BoardY(Z, Y) + 44 Then
If Playable(Z, Y) > 0 Then Row2 = Z: Column2 = Y: GoSub ReleaseMouseButton: GoTo EndChoice2
End If
Next
Next
Loop
GoTo ChooseALocationInput

EndChoice2:
BoardX2 = BoardX(Row2, Column2): BoardY2 = BoardY(Row2, Column2)

' Check If New Location Same as Old
If Row2 = Row1 And Column2 = Column1 Then PSet (BoardX1, BoardY1), PlayerColor(Player): Draw Cursor1: GoTo ChooseAPieceInput

' Clear Piece From Old Location
Line (BoardX1 - 46, BoardY1 - 46)-(BoardX1 + 46, BoardY1 + 46), 1, BF
BoardPlayer(Row1, Column1) = 0: BoardPiece(Row1, Column1) = 0

' Check if Piece is Now a Tower
If Playable(Row2, Column2) = 2 Then Piece = 2: Score(Player) = Score(Player) - 1

' Draw Piece in New Location
Circle (BoardX2, BoardY2), 40, PlayerColor(Player): Paint (BoardX2, BoardY2), PlayerColor(Player)
BoardPlayer(Row2, Column2) = Player: BoardPiece(Row2, Column2) = Piece

' If Piece is a Tower Draw Extra Rings
If Piece = 2 Then
Circle (BoardX2, BoardY2), 35, PlayerColor(Opponent): Paint (BoardX2, BoardY2), PlayerColor(Opponent)
Circle (BoardX2, BoardY2), 30, PlayerColor(Player): Paint (BoardX2, BoardY2), PlayerColor(Player)
End If

' Check if Move was a Jump
If Playable(Row2, Column2) = 3 Then
Score(Player) = Score(Player) + 1: Score(Opponent) = Score(Opponent) - 1
If Row2 - Row1 = 2 Then V = 1 Else If Row2 - Row1 = -2 Then V = -1 Else V = 0
If Column2 - Column1 = 2 Then W = 1 Else If Column2 - Column1 = -2 Then W = -1 Else W = 0
BoardPlayer(Row1 + V, Column1 + W) = Player
Circle (BoardX(Row1 + V, Column1 + W), BoardY(Row1 + V, Column1 + W)), 40, PlayerColor(Player)
Paint (BoardX(Row1 + V, Column1 + W), BoardY(Row1 + V, Column1 + W)), PlayerColor(Player)
End If

' Check Surrounding Pieces for Opponent to Flip
If Row2 - 1 >= 1 Then If BoardPlayer(Row2 - 1, Column2) = Opponent Then V = -1: W = 0: GoSub ChangePiece
If Row2 + 1 <= 7 Then If BoardPlayer(Row2 + 1, Column2) = Opponent Then V = 1: W = 0: GoSub ChangePiece
If Player = 1 Then
If Row2 - 1 >= 1 And Column2 + 1 <= 8 Then If BoardPlayer(Row2 - 1, Column2 + 1) = Opponent Then V = -1: W = 1: GoSub ChangePiece
If Column2 + 1 <= 8 Then If BoardPlayer(Row2, Column2 + 1) = Opponent Then V = 0: W = 1: GoSub ChangePiece
If Row2 + 1 <= 7 And Column2 + 1 <= 8 Then If BoardPlayer(Row2 + 1, Column2 + 1) = Opponent Then V = 1: W = 1: GoSub ChangePiece
ElseIf Player = 2 Then
If Row2 - 1 >= 1 And Column2 - 1 >= 1 Then If BoardPlayer(Row2 - 1, Column2 - 1) = Opponent Then V = -1: W = -1: GoSub ChangePiece
If Column2 - 1 >= 1 Then If BoardPlayer(Row2, Column2 - 1) = Opponent Then V = 0: W = -1: GoSub ChangePiece
If Row2 + 1 <= 7 And Column2 - 1 >= 1 Then If BoardPlayer(Row2 + 1, Column2 - 1) = Opponent Then V = 1: W = -1: GoSub ChangePiece
End If

EndTurn:
If Passed = 2 GoTo Winner

Swap Player, Opponent

GoTo StartGame


ReleaseMouseButton:
Do While _MouseInput
If _MouseButton(1) = 0 Then Return
Loop
GoTo ReleaseMouseButton


CheckPlayableMoves:
X = 0: V = 0
If Player = 1 Then
' Check Up Right
If Z - 1 >= 1 And Y + 1 <= 8 Then
If BoardPlayer(Z - 1, Y + 1) = 0 Then X = 1: V = 1: Playable(Z - 1, Y + 1) = 1
If BoardPlayer(Z - 1, Y + 1) = Player And BoardPiece(Z - 1, Y + 1) = 1 And Piece = 1 Then X = 1: Playable(Z - 1, Y + 1) = 2
If Z - 2 >= 1 And Y + 2 <= 8 Then
If BoardPlayer(Z - 1, Y + 1) = Opponent And BoardPiece(Z - 1, Y + 1) = 1 And BoardPlayer(Z - 2, Y + 2) = 0 And Piece = 2 Then X = 1: V = 1: Playable(Z - 2, Y + 2) = 3
End If
End If
' Check Right
If Y + 1 <= 8 Then
If BoardPlayer(Z, Y + 1) = 0 Then X = 1: V = 1: Playable(Z, Y + 1) = 1
If BoardPlayer(Z, Y + 1) = Player And BoardPiece(Z, Y + 1) = 1 And Piece = 1 Then X = 1: Playable(Z, Y + 1) = 2
If Y + 2 <= 8 Then
If BoardPlayer(Z, Y + 1) = Opponent And BoardPiece(Z, Y + 1) = 1 And BoardPlayer(Z, Y + 2) = 0 And Piece = 2 Then X = 1: V = 1: Playable(Z, Y + 2) = 3
End If
End If
' Check Down Right
If Z + 1 <= 7 And Y + 1 <= 8 Then
If BoardPlayer(Z + 1, Y + 1) = 0 Then X = 1: V = 1: Playable(Z + 1, Y + 1) = 1
If BoardPlayer(Z + 1, Y + 1) = Player And BoardPiece(Z + 1, Y + 1) = 1 And Piece = 1 Then X = 1: Playable(Z + 1, Y + 1) = 2
If Z + 2 <= 7 And Y + 2 <= 8 Then
If BoardPlayer(Z + 1, Y + 1) = Opponent And BoardPiece(Z + 1, Y + 1) = 1 And BoardPlayer(Z + 2, Y + 2) = 0 And Piece = 2 Then X = 1: V = 1: Playable(Z + 2, Y + 2) = 3
End If
End If
ElseIf Player = 2 Then
' Check Up Left
If Z - 1 >= 1 And Y - 1 >= 1 Then
If BoardPlayer(Z - 1, Y - 1) = 0 Then X = 1: V = 1: Playable(Z - 1, Y - 1) = 1
If BoardPlayer(Z - 1, Y - 1) = Player And BoardPiece(Z - 1, Y - 1) = 1 And Piece = 1 Then X = 1: Playable(Z - 1, Y - 1) = 2
If Z - 2 >= 1 And Y - 2 >= 1 Then
If BoardPlayer(Z - 1, Y - 1) = Opponent And BoardPiece(Z - 1, Y - 1) = 1 And BoardPlayer(Z - 2, Y - 2) = 0 And Piece = 2 Then X = 1: V = 1: Playable(Z - 2, Y - 2) = 3
End If
End If
' Check Left
If Y - 1 >= 1 Then
If BoardPlayer(Z, Y - 1) = 0 Then X = 1: V = 1: Playable(Z, Y - 1) = 1
If BoardPlayer(Z, Y - 1) = Player And BoardPiece(Z, Y - 1) = 1 And Piece = 1 Then X = 1: Playable(Z, Y - 1) = 2
If Y - 2 >= 1 Then
If BoardPlayer(Z, Y - 1) = Opponent And BoardPiece(Z, Y - 1) = 1 And BoardPlayer(Z, Y - 2) = 0 And Piece = 2 Then X = 1: V = 1: Playable(Z, Y - 2) = 3
End If
End If
' Check Down Left
If Z + 1 <= 7 And Y - 1 >= 1 Then
If BoardPlayer(Z + 1, Y - 1) = 0 Then X = 1: V = 1: Playable(Z + 1, Y - 1) = 1
If BoardPlayer(Z + 1, Y - 1) = Player And BoardPiece(Z + 1, Y - 1) = 1 And Piece = 1 Then X = 1: Playable(Z + 1, Y - 1) = 2
If Z + 2 <= 7 And Y - 2 >= 1 Then
If BoardPlayer(Z + 1, Y - 1) = Opponent And BoardPiece(Z + 1, Y - 1) = 1 And BoardPlayer(Z + 2, Y - 2) = 0 And Piece = 2 Then X = 1: V = 1: Playable(Z + 2, Y - 2) = 3
End If
End If
End If
Return


ChangePiece:
BoardPlayer(Row2 + V, Column2 + W) = Player: Score(Player) = Score(Player) + 1: Score(Opponent) = Score(Opponent) - 1
Line (BoardX(Row2 + V, Column2 + W) - 46, BoardY(Row2 + V, Column2 + W) - 46)-(BoardX(Row2 + V, Column2 + W) + 46, BoardY(Row2 + V, Column2) + W + 46), 1, BF
Circle (BoardX(Row2 + V, Column2 + W), BoardY(Row2 + V, Column2 + W)), 40, PlayerColor(Player)
Paint (BoardX(Row2 + V, Column2 + W), BoardY(Row2 + V, Column2 + W)), PlayerColor(Player)
If BoardPiece(Row2 + V, Column2 + W) = 2 Then
Circle (BoardX(Row2 + V, Column2 + W), BoardY(Row2 + V, Column2 + W)), 35, PlayerColor(Opponent)
Paint (BoardX(Row2 + V, Column2 + W), BoardY(Row2 + V, Column2 + W)), PlayerColor(Opponent)
Circle (BoardX(Row2 + V, Column2 + W), BoardY(Row2 + V, Column2 + W)), 30, PlayerColor(Player)
Paint (BoardX(Row2 + V, Column2 + W), BoardY(Row2 + V, Column2 + W)), PlayerColor(Player)
End If
Return


Winner:
If Score(1) > Score(2) Then Winner = 1 Else If Score(2) > Score(1) Then Winner = 2 Else Winner = 3

If Winner = 3 Then
Paint (949, 100), 0
Circle (899, 100), 40, PlayerColor(1): Paint (899, 100), PlayerColor(1)
Circle (999, 100), 40, PlayerColor(2): Paint (999, 100), PlayerColor(2)

Color 15, 0: Locate 11, 115: Print " ";

Locate 43, 105: Print " The Game Ended in a Draw ";
Else
Circle (949, 100), 40, PlayerColor(Winner): Paint (949, 100), PlayerColor(Winner)

Color 15, 0: Locate 11, 115: Print "Player:"; Winner;

Locate 43, 105: Print " Player"; Winner; "is the Winner! ";
End If

Locate 45, 104: Print " Play Another Game? (Y or N) ";

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




Users browsing this thread: 2 Guest(s)