Octogo Board Game
#1


Hello All,
Here is my take on the abstract strategy board game 'Octogo'. 
Hope you enjoy playing.

Donald

Code: (Select All)
_TITLE "Octogo Board Game 1986 - Programmed by Donald L. Foster Jr. 2023"

SCREEN _NEWIMAGE(1305, 735, 256)

_PALETTECOLOR 1, _RGB32(40, 40, 40) '  Board Color
_PALETTECOLOR 2, _RGB32(60, 60, 60) '  Board Space Color
_PALETTECOLOR 3, _RGB32(240, 140, 0) ' Player 1 Piece Orange Base Color
_PALETTECOLOR 6, _RGB32(170, 70, 0) '  Player 1 Piece Orange Arrow Color
_PALETTECOLOR 7, _RGB32(0, 90, 210) '  Player 2 Piece Blue Base Color
_PALETTECOLOR 9, _RGB32(0, 30, 150) '  Player 2 Piece Med Blue Color
_PALETTECOLOR 4, _RGB32(210, 100, 0) ' Red Game Title Color
_PALETTECOLOR 8, _RGB32(0, 130, 210) ' Blue Game Title Color

DIM AS _UNSIGNED INTEGER V, W, X, Y, Z, X1, X2, X3, X4
DIM AS _UNSIGNED _BYTE Player, Opponent, Rotation, Move, NextRotation, PreviousRotation
DIM AS _UNSIGNED _BIT Selected, CanRotateNext, CanRotatePrevious, RotatePlay, BoardSpace(6, 7), Playable(6, 7)
DIM AS _UNSIGNED _BYTE BoardPlayer(6, 7), BoardRotation(6, 7), CapturedPieces(2)
DIM AS _UNSIGNED INTEGER BoardX(6, 7), BoardY(6, 7), CapturedX(2, 10), CapturedY(2, 10), RotateX(2)

Player = 1: Opponent = 2:
CapturedPieces(1) = 0: CapturedPieces(2) = 0

' Setup Board Players
FOR Z = 1 TO 6: FOR Y = 1 TO 7: BoardSpace(Z, Y) = 1: NEXT: NEXT
BoardSpace(1, 1) = 0: BoardSpace(1, 7) = 0: BoardSpace(6, 1) = 0: BoardSpace(6, 7) = 0

' Setup Board Piece Rotations
FOR Z = 2 TO 5: BoardPlayer(Z, 1) = 1: BoardRotation(Z, 1) = 3: BoardPlayer(Z, 7) = 2: BoardRotation(Z, 7) = 7: NEXT
FOR Z = 1 TO 6: BoardPlayer(Z, 2) = 1: BoardRotation(Z, 2) = 3: BoardPlayer(Z, 6) = 2: BoardRotation(Z, 6) = 7: NEXT

' Setup Captured Pieces Storage Section
X = 350
FOR Z = 1 TO 9 STEP 2
   CapturedX(2, Z) = 923: CapturedY(2, Z) = X
   CapturedX(2, Z + 1) = 993: CapturedY(2, Z + 1) = X
   CapturedX(1, Z) = 1151: CapturedY(1, Z) = X
   CapturedX(1, Z + 1) = 1221: CapturedY(1, Z + 1) = X
   X = X + 70
NEXT

' Set Playing Piece Arrows
Arrow$(1, 1) = "C6TA0BR16TA23U40TA157U40TA115D17TA65D17TA35BU20P6,6" '    Player 1 Up Arrow
Arrow$(1, 2) = "C6TA0BR9BD12TA157D40TA23L40TA65D17TA115L17TA0BU10P6,6" '  Player 1 Up Right Arrow
Arrow$(1, 3) = "C6TA0BD16TA23R40TA157R40TA115L17TA65L17TA35BR20P6,6" '    Player 1 Right Arrow
Arrow$(1, 4) = "C6TA0BL12BD9TA157L40TA23U40TA65L17TA115U17TA0BR10P6,6" '  Player 1 Down Right Arrow
Arrow$(1, 5) = "C6TA0BL16TA23D40TA157D40TA115U17TA65U17TA35BD20P6,6" '    Player 1 Down Arrow
Arrow$(1, 6) = "C6TA0BR12BD9TA23L40TA157D40TA115L17TA65D17TA0BL10P6,6" '  Player 1 Down Left Arrow
Arrow$(1, 7) = "C6TA0BU16TA23L40TA157L40TA115R17TA65R17TA35BL20P6,6" '    Player 1 Left Arrow
Arrow$(1, 8) = "C6TA0BR10BU10TA157R40TA23D40TA65R17TA115D17TA0BL10P6,6" ' Player 1 Up Left Arrow
Arrow$(2, 1) = "C9TA0BR16TA23U40TA157U40TA115D17TA65D17TA35BU20P9,9" '    Player 2 Up Arrow
Arrow$(2, 2) = "C9TA0BR9BD12TA157D40TA23L40TA65D17TA115L17TA0BU10P9,9" '  Player 2 Up Right Arrow
Arrow$(2, 3) = "C9TA0BD16TA23R40TA157R40TA115L17TA65L17TA35BR20P9,9" '    Player 2 Right Arrow
Arrow$(2, 4) = "C9TA0BL12BD9TA157L40TA23U40TA65L17TA115U17TA0BR10P9,9" '  Player 2 Down Right Arrow
Arrow$(2, 5) = "C9TA0BL16TA23D40TA157D40TA115U17TA65U17TA35BD20P9,9" '    Player 2 Down Arrow
Arrow$(2, 6) = "C9TA0BR12BD9TA23L40TA157D40TA115L17TA65D17TA0BL10P9,9" '  Player 2 Down Left Arrow
Arrow$(2, 7) = "C9TA0BU16TA23L40TA157L40TA115R17TA65R17TA35BL20P9,9" '    Player 2 Right Arrow
Arrow$(2, 8) = "C9TA0BR10BU10TA157R40TA23D40TA65R17TA115D17TA0BL10P9,9" ' Player 2 Up Left Arrow
Arrow$(3, 1) = "C1TA0BR16TA23U40TA157U40TA115D17TA65D17TA35BU20P1,1" '    No Rotate Up Arrow
Arrow$(3, 2) = "C1TA0BR9BD12TA157D40TA23L40TA65D17TA115L17TA0BU10P1,1" '  No Rotate Up Right Arrow
Arrow$(3, 3) = "C1TA0BD16TA23R40TA157R40TA115L17TA65L17TA35BR20P1,1" '    No Rotate Right Arrow
Arrow$(3, 4) = "C1TA0BL12BD9TA157L40TA23U40TA65L17TA115U17TA0BR10P1,1" '  No Rotate Down Right Arrow
Arrow$(3, 5) = "C1TA0BL16TA23D40TA157D40TA115U17TA65U17TA35BD20P1,1" '    No Rotate Down Arrow
Arrow$(3, 6) = "C1TA0BR12BD9TA23L40TA157D40TA115L17TA65D17TA0BL10P1,1" '  No Rotate Down Left Arrow
Arrow$(3, 7) = "C1TA0BU16TA23L40TA157L40TA115R17TA65R17TA35BL20P1,1" '    No Rotate Left Arrow
Arrow$(3, 8) = "C1TA0BR10BU10TA157R40TA23D40TA65R17TA115D17TA0BL10P1,1" ' No Rotate Up Left Arrow

BoardSpace$ = "C15TA0BR33BU14U20L20TA45U20TA135U20TA0L20D20TA135U20TA225U20TA0D20R20TA225U20TA45R20TA0R20U20TA45R20U20TA0BL3P2,15"
GameTitle$ = "C15TA0BR33BU14U13L13TA45U13TA135U13TA0L13D13TA135U13TA225U13TA0D13R13TA225U13TA45R13TA0R13U13TA45R13U13TA0BL3P15,15"
CapturedPieces$ = "CAPTURED PIECES"

' Draw Board
PSET (378, 10), 15: DRAW "TA0L214TA45L218TA0D407TA45D218TA0R522TA45R218TA0U407TA45U218TA0L330BD3P1,15"

X = 80
FOR Z = 1 TO 6
   W = 80
   FOR Y = 1 TO 7
      IF BoardSpace(Z, Y) THEN PSET (W, X), 1: DRAW BoardSpace$
      IF BoardPlayer(Z, Y) THEN X1 = W: X2 = X: X3 = BoardPlayer(Z, Y): X4 = BoardRotation(Z, Y): GOSUB DrawPiece
      BoardX(Z, Y) = W: BoardY(Z, Y) = X
      W = W + 115
   NEXT
   X = X + 115
NEXT

' Draw Game Title
X = 883
FOR Z = 1 TO 6

   PSET (X, 45), 15: DRAW GameTitle$

   SELECT CASE Z
      CASE 1, 4, 6
         IF Z = 1 THEN W = 4 ELSE W = 8
         CIRCLE (X + 11, 40), 18, W: CIRCLE (X + 11, 40), 10, W: PAINT (X - 5, 40), W
      CASE 2
         CIRCLE (X + 11, 40), 18, 8, .80, 5.40: CIRCLE (X + 11, 40), 10, 8, .80, 5.25:
         PSET (X + 11, 40), 15: DRAW "C8TA45BR10R7BL17BD10D7": PAINT (X - 5, 40), 8
      CASE 3
         PSET (X + 11, 60), 4: DRAW "TA0R4U29R5E8L34F8R5D29R4BU3P4,4"
      CASE 5
         CIRCLE (X + 11, 40), 18, 4, .80, 0.25: CIRCLE (X + 11, 40), 10, 4, .80, 5.5
         PSET (X + 11, 40), 4: DRAW "TA45BR10R7BL17TA0BR17BU3L20D8R12": PAINT (X - 5, 40), 4
   END SELECT

   X = X + 71
NEXT

' Draw Captured Pieces Stoage Sections
LINE (883, 310)-(1033, 670), 1, BF: LINE (883, 310)-(1033, 670), 15, B
LINE (1111, 310)-(1261, 670), 1, BF: LINE (1111, 310)-(1261, 670), 15, B

X = 310
FOR Z = 1 TO 15
   _PRINTSTRING (1068, X), MID$(CapturedPieces$, Z, 1)
   X = X + 25
NEXT

StartGame:
Move = 1: CanRotateNext = 1: CanRotatePrevious = 1

' Draw Player Indicator
X1 = 1072: X2 = 121: X3 = Player: X4 = 1: GOSUB DrawPiece
LOCATE 8, 116: PRINT "Player:"; Player;
LOCATE 8, 146: PRINT "Move #:"; Move;

ChoosePiece:
LOCATE 45, 117: PRINT "       Choose a Piece to Play       ";

GetBoardLocation:
DO WHILE _MOUSEINPUT
   FOR Z = 1 TO 6
      FOR Y = 1 TO 7
         IF _MOUSEX > BoardX(Z, Y) - 30 AND _MOUSEX < BoardX(Z, Y) + 30 AND _MOUSEY > BoardY(Z, Y) - 30 AND _MOUSEY < BoardY(Z, Y) + 30 THEN Selected = 1 ELSE Selected = 0
         IF _MOUSEBUTTON(1) AND BoardPlayer(Z, Y) = Player AND Selected THEN
            GOSUB ReleaseButton: CIRCLE (BoardX(Z, Y), BoardY(Z, Y)), 55, 15
            Row = Z: Column = Y: Rotation = BoardRotation(Z, Y): GOTO ChoosePlay
         END IF
      NEXT
   NEXT
LOOP
A$ = INKEY$: IF A$ <> "" THEN IF ASC(A$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(A$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
GOTO GetBoardLocation

ChoosePlay:
LOCATE 8, 146: PRINT "Move #:"; Move;

' Display Piece for Rotation
X1 = 1072: X2 = 230: X3 = Player: X4 = Rotation: GOSUB DrawPiece

' Get Next and Previous Rotations
IF Rotation = 1 THEN PreviousRotation = 8 ELSE PreviousRotation = Rotation - 1
IF Rotation = 8 THEN NextRotation = 1 ELSE NextRotation = Rotation + 1

' Display Next and Previous Piece Rotations
X = 960
FOR Z = 1 TO 2
   X1 = X: X2 = 230
   IF (Z = 1 AND CanRotatePrevious = 1) OR (Z = 2 AND CanRotateNext = 1) THEN X3 = Player ELSE X3 = 3
   IF Z = 1 THEN X4 = PreviousRotation ELSE X4 = NextRotation
   GOSUB DrawPiece: RotateX(Z) = X
   X = X + 224
NEXT

LOCATE 19, 112: PRINT "Counter Clockwise                Clockwise";

' Set Board Playable Locations to 0
FOR Z = 1 TO 6: FOR Y = 1 TO 7: Playable(Z, Y) = 0: NEXT: NEXT

' Check Playable Board Locations
X = 0
IF Move = 1 THEN Playable(Row, Column) = 1
IF Row - 1 >= 1 THEN IF BoardSpace(Row - 1, Column) AND BoardPlayer(Row - 1, Column) <> Player AND BoardRotation(Row, Column) = 1 THEN Playable(Row - 1, Column) = 1: X = 1
IF Row + 1 <= 6 THEN IF BoardSpace(Row + 1, Column) AND BoardPlayer(Row + 1, Column) <> Player AND BoardRotation(Row, Column) = 5 THEN Playable(Row + 1, Column) = 1: X = 1
IF Column - 1 >= 1 THEN IF BoardSpace(Row, Column - 1) AND BoardPlayer(Row, Column - 1) <> Player AND BoardRotation(Row, Column) = 7 THEN Playable(Row, Column - 1) = 1: X = 1
IF Column + 1 <= 7 THEN IF BoardSpace(Row, Column + 1) AND BoardPlayer(Row, Column + 1) <> Player AND BoardRotation(Row, Column) = 3 THEN Playable(Row, Column + 1) = 1: X = 1
IF Row - 1 >= 1 AND Column - 1 >= 1 THEN IF BoardSpace(Row - 1, Column - 1) AND BoardPlayer(Row - 1, Column - 1) <> Player AND BoardRotation(Row, Column) = 8 THEN Playable(Row - 1, Column - 1) = 1: X = 1
IF Row + 1 <= 6 AND Column + 1 <= 7 THEN IF BoardSpace(Row + 1, Column + 1) AND BoardPlayer(Row + 1, Column + 1) <> Player AND BoardRotation(Row, Column) = 4 THEN Playable(Row + 1, Column + 1) = 1: X = 1
IF Row - 1 >= 1 AND Column + 1 <= 7 THEN IF BoardSpace(Row - 1, Column + 1) AND BoardPlayer(Row - 1, Column + 1) <> Player AND BoardRotation(Row, Column) = 2 THEN Playable(Row - 1, Column + 1) = 1: X = 1
IF Row + 1 <= 6 AND Column - 1 >= 1 THEN IF BoardSpace(Row + 1, Column - 1) AND BoardPlayer(Row + 1, Column - 1) <> Player AND BoardRotation(Row, Column) = 6 THEN Playable(Row + 1, Column - 1) = 1: X = 1

LOCATE 45, 117: PRINT "Choose Rotation or Board Location";

GetPlayChoice:
DO WHILE _MOUSEINPUT
   ' Piece Rotation
   RotatePlay = 0
   FOR Z = 1 TO 2
      IF _MOUSEX > RotateX(Z) - 50 AND _MOUSEX < RotateX(Z) + 50 AND _MOUSEY > 180 AND _MOUSEY < 280 THEN Selected = 1 ELSE Selected = 2
      IF Selected AND ((Z = 1 AND CanRotatePrevious) OR (Z = 2 AND CanRotateNext)) THEN
         LINE (RotateX(Z) - 50, 180)-(RotateX(Z) + 50, 280), 15, B
      ELSE
         LINE (RotateX(Z) - 50, 180)-(RotateX(Z) + 50, 280), 0, B
      END IF
      IF _MOUSEBUTTON(1) AND Selected THEN
         GOSUB ReleaseButton
         ' Rotate Piece Counter Clockwise
         IF Z = 1 AND CanRotatePrevious THEN
            RotatePlay = 1: Rotation = PreviousRotation: CanRotateNext = 0: GOTO MakeMove
         END IF
         ' Rotate Piece Clockwise
         IF Z = 2 AND CanRotateNext THEN
            RotatePlay = 1: Rotation = NextRotation: CanRotatePrevious = 0: GOTO MakeMove
         END IF
      END IF
   NEXT

   ' Move Piece
   FOR Z = 1 TO 6
      FOR Y = 1 TO 7
         IF _MOUSEX > BoardX(Z, Y) - 30 AND _MOUSEX < BoardX(Z, Y) + 30 AND _MOUSEY > BoardY(Z, Y) - 30 AND _MOUSEY < BoardY(Z, Y) + 30 THEN Selected = 1 ELSE Selected = 0
         IF _MOUSEBUTTON(1) AND Playable(Z, Y) AND Selected THEN
            IF Z = Row AND Y = Column AND Move = 1 THEN CIRCLE (BoardX(Z, Y), BoardY(Z, Y)), 55, 1: LINE (880, 180)-(1234, 308), 0, BF: GOTO ChoosePiece ELSE GOTO MakeMove
         END IF
      NEXT
   NEXT

LOOP
A$ = INKEY$: IF A$ <> "" THEN IF ASC(A$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(A$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
GOTO GetPlayChoice

MakeMove:
' Remove Piece from Board
BoardPlayer(Row, Column) = 0: BoardRotation(Row, Column) = 0
PAINT (BoardX(Row, Column), BoardY(Row, Column)), 2, 15
CIRCLE (BoardX(Row, Column), BoardY(Row, Column)), 55, 1

IF RotatePlay = 0 THEN
   ' Check for Capture
   IF BoardPlayer(Z, Y) = Opponent THEN
      PAINT (BoardX(Z, Y), BoardY(Z, Y)), 2, 15
      CapturedPieces(Opponent) = CapturedPieces(Opponent) + 1
      X1 = CapturedX(Opponent, CapturedPieces(Opponent))
      X2 = CapturedY(Opponent, CapturedPieces(Opponent))
      X3 = Opponent: IF Opponent = 1 THEN X4 = 8 ELSE X4 = 2
      GOSUB DrawPiece
   END IF
   ' Move Piece on Board
   Row = Z: Column = Y: BoardPlayer(Z, Y) = Player: BoardRotation(Z, Y) = Rotation
   X1 = BoardX(Z, Y): X2 = BoardY(Z, Y): X3 = Player: X4 = Rotation: GOSUB DrawPiece
ELSE
   ' Rotate Piece
   BoardPlayer(Row, Column) = Player: BoardRotation(Row, Column) = Rotation
   X1 = BoardX(Row, Column): X2 = BoardY(Row, Column): X3 = Player: X4 = Rotation: GOSUB DrawPiece
END IF

EndPlay:
' Remove Rotate Piece Area from View
LINE (880, 180)-(1234, 308), 0, BF

' Check for Winner
IF CapturedPieces(Opponent) = 10 GOTO Winner

IF Move = 1 THEN Move = 2: GOTO ChoosePlay

' Remove Board Position Cursor
CIRCLE (BoardX(Row, Column), BoardY(Row, Column)), 55, 1

Move = 1: SWAP Player, Opponent: GOTO StartGame

ReleaseButton:
DO WHILE _MOUSEINPUT
   IF _MOUSEBUTTON(1) = 0 THEN RETURN
LOOP
GOTO ReleaseButton

DrawPiece:
' Draw Piece Base
SELECT CASE X4
   CASE 1, 3, 5, 7
      PSET (X1, X2), 2
      IF X3 = 1 THEN DRAW "C3TA0BU42TA45L59D59R59U59TA0BD10P3,3"
      IF X3 = 2 THEN DRAW "C7TA0BU42TA45L59D59R59U59TA0BD10P7,7"
      IF X3 = 3 THEN DRAW "C2TA0BU42TA45L59D59R59U59TA0BD10P2,2"
   CASE 2, 4, 6, 8
      IF X3 = 1 THEN V = 3 ELSE IF X3 = 2 THEN V = 7 ELSE V = 2
      LINE (X1 - 30, X2 - 29)-(X1 + 28, X2 + 29), V, BF
END SELECT
' Draw Piece Arrow
PSET (X1, X2), POINT(X1, X2): DRAW Arrow$(X3, X4)
RETURN

Winner:
LOCATE 44, 123: PRINT "Player"; Player; "is the Winner!";
LOCATE 45, 117: PRINT "    Play Another Game? (Y or N)    ";

GetYorN: A$ = UCASE$(INKEY$): IF A$ = "" GOTO GetYorN
IF A$ = "Y" THEN RUN
IF A$ = "N" THEN SYSTEM
IF ASC(A$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(A$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
GOTO GetYorN


Attached Files
.pdf   Octogo-Board-Game-Description.pdf (Size: 220.32 KB / Downloads: 48)
Reply
#2
Hello Donald, thank you for the games!

This program might be another one that will have to be modified for _MOUSEINPUT as bplus suggested in the other thread.

ie. put _MOUSEINPUT into a loop that does nothing but check its status. Then right after check the status of device movement and buttons.
Reply
#3
Hi mnrvovrfc,
Thanks for the advice. This game was functioning perfect until I made a last minute change to the code before I uploaded it and didn't test it. Line 254 needs to be changed to:
Code: (Select All)
IF Move = 1 THEN Move = 2: CIRCLE (BoardX(Row, Column), BoardY(Row, Column)), 55, 15: GOTO ChoosePlay
 
The code should work perfectly with the mouse input loops.
Reply
#4
Nice looking game!
The link https://boardgamegeek.com/boardgame/19299/octogo
says: ".. you may either move one piece 1 or 2 spaces ..".
Does your game allow moving 1 space?
___________________________________________________________________________________
I am mostly grateful for the people who came before me.  Will the people after me be grateful for me?
Reply
#5
Hi dcromley,

 Thanks for checking out my game. To answer your question, it's my understanding that a player must perform 2 moves per turn. With that said, if you move 1 space only, you must follow that move with a 45 degree rotation. I just read the description of the game in Board Game Geek and found that the number of moves is unclear. It seems that you have the option of making 1 or 2 moves per turn. I don't own the game nor do I have a copy of the rules. And I can't find a copy of the rules anywhere. I got my information from the Youtube video I posted and it seemed to me that you must make 2 moves per turn. He gave examples of types of move you can make: Move 1 piece 2 spaces or Rotate a piece 2 steps forming a 90 degree rotation or Rotate a piece then move it 1 space or Move a piece and then rotate it 45 degrees. All of those = 2 moves per turn. Ok, I just watched the video again and he does say you can make 1 or 2 actions per turn. It seems I need to make a modification to the game. Thanks for pointing that out. I will make the necessary changes and re-post the updated code in this tread as a new replay. I think the best way to end your turn after performing 1 move is having the player click on the same piece in it's current location on the board.

Donald
Reply
#6
Ok, the code has been updated and posted here. I chose not to click on the selected piece during Move # 2, for it may cause an unintended or accidental turn ending when unwanted and was intending on making a second move. So I chose to use the unused middle (current rotation) piece on the right side of the screen (the rotation section). This option is only available during Move # 2. When you hover over the middle piece. the Counter Clockwise and Clockwise messages disappear and the End Turn message appears under the center piece. This way an unintentional ending move will be avoided.

Donald

Code: (Select All)
_TITLE "Octogo Board Game 1986 - Programmed by Donald L. Foster Jr. 2023"

SCREEN _NEWIMAGE(1305, 735, 256)

_PALETTECOLOR 1, _RGB32(40, 40, 40) '  Board Color
_PALETTECOLOR 2, _RGB32(60, 60, 60) '  Board Space Color
_PALETTECOLOR 3, _RGB32(240, 140, 0) ' Player 1 Piece Orange Base Color
_PALETTECOLOR 6, _RGB32(170, 70, 0) '  Player 1 Piece Orange Arrow Color
_PALETTECOLOR 7, _RGB32(0, 90, 210) '  Player 2 Piece Blue Base Color
_PALETTECOLOR 9, _RGB32(0, 30, 150) '  Player 2 Piece Med Blue Color
_PALETTECOLOR 4, _RGB32(210, 100, 0) ' Red Game Title Color
_PALETTECOLOR 8, _RGB32(0, 130, 210) ' Blue Game Title Color

DIM AS _UNSIGNED INTEGER V, W, X, Y, Z, X1, X2, X3, X4
DIM AS _UNSIGNED _BYTE Player, Opponent, Rotation, Move, NextRotation, PreviousRotation
DIM AS _UNSIGNED _BIT Selected, CanRotateNext, CanRotatePrevious, RotatePlay, BoardSpace(6, 7), Playable(6, 7)
DIM AS _UNSIGNED _BYTE BoardPlayer(6, 7), BoardRotation(6, 7), CapturedPieces(2)
DIM AS _UNSIGNED INTEGER BoardX(6, 7), BoardY(6, 7), CapturedX(2, 10), CapturedY(2, 10), RotateX(3)

Player = 1: Opponent = 2:
CapturedPieces(1) = 0: CapturedPieces(2) = 0

' Setup Board Players
FOR Z = 1 TO 6: FOR Y = 1 TO 7: BoardSpace(Z, Y) = 1: NEXT: NEXT
BoardSpace(1, 1) = 0: BoardSpace(1, 7) = 0: BoardSpace(6, 1) = 0: BoardSpace(6, 7) = 0

' Setup Board Piece Rotations
FOR Z = 2 TO 5: BoardPlayer(Z, 1) = 1: BoardRotation(Z, 1) = 3: BoardPlayer(Z, 7) = 2: BoardRotation(Z, 7) = 7: NEXT
FOR Z = 1 TO 6: BoardPlayer(Z, 2) = 1: BoardRotation(Z, 2) = 3: BoardPlayer(Z, 6) = 2: BoardRotation(Z, 6) = 7: NEXT

' Setup Captured Pieces Storage Section
X = 350
FOR Z = 1 TO 9 STEP 2
   CapturedX(2, Z) = 923: CapturedY(2, Z) = X
   CapturedX(2, Z + 1) = 993: CapturedY(2, Z + 1) = X
   CapturedX(1, Z) = 1151: CapturedY(1, Z) = X
   CapturedX(1, Z + 1) = 1221: CapturedY(1, Z + 1) = X
   X = X + 70
NEXT

' Set Playing Piece Arrows
Arrow$(1, 1) = "C6TA0BR16TA23U40TA157U40TA115D17TA65D17TA35BU20P6,6" '    Player 1 Up Arrow
Arrow$(1, 2) = "C6TA0BR9BD12TA157D40TA23L40TA65D17TA115L17TA0BU10P6,6" '  Player 1 Up Right Arrow
Arrow$(1, 3) = "C6TA0BD16TA23R40TA157R40TA115L17TA65L17TA35BR20P6,6" '    Player 1 Right Arrow
Arrow$(1, 4) = "C6TA0BL12BD9TA157L40TA23U40TA65L17TA115U17TA0BR10P6,6" '  Player 1 Down Right Arrow
Arrow$(1, 5) = "C6TA0BL16TA23D40TA157D40TA115U17TA65U17TA35BD20P6,6" '    Player 1 Down Arrow
Arrow$(1, 6) = "C6TA0BR12BD9TA23L40TA157D40TA115L17TA65D17TA0BL10P6,6" '  Player 1 Down Left Arrow
Arrow$(1, 7) = "C6TA0BU16TA23L40TA157L40TA115R17TA65R17TA35BL20P6,6" '    Player 1 Left Arrow
Arrow$(1, 8) = "C6TA0BR10BU10TA157R40TA23D40TA65R17TA115D17TA0BL10P6,6" ' Player 1 Up Left Arrow
Arrow$(2, 1) = "C9TA0BR16TA23U40TA157U40TA115D17TA65D17TA35BU20P9,9" '    Player 2 Up Arrow
Arrow$(2, 2) = "C9TA0BR9BD12TA157D40TA23L40TA65D17TA115L17TA0BU10P9,9" '  Player 2 Up Right Arrow
Arrow$(2, 3) = "C9TA0BD16TA23R40TA157R40TA115L17TA65L17TA35BR20P9,9" '    Player 2 Right Arrow
Arrow$(2, 4) = "C9TA0BL12BD9TA157L40TA23U40TA65L17TA115U17TA0BR10P9,9" '  Player 2 Down Right Arrow
Arrow$(2, 5) = "C9TA0BL16TA23D40TA157D40TA115U17TA65U17TA35BD20P9,9" '    Player 2 Down Arrow
Arrow$(2, 6) = "C9TA0BR12BD9TA23L40TA157D40TA115L17TA65D17TA0BL10P9,9" '  Player 2 Down Left Arrow
Arrow$(2, 7) = "C9TA0BU16TA23L40TA157L40TA115R17TA65R17TA35BL20P9,9" '    Player 2 Right Arrow
Arrow$(2, 8) = "C9TA0BR10BU10TA157R40TA23D40TA65R17TA115D17TA0BL10P9,9" ' Player 2 Up Left Arrow
Arrow$(3, 1) = "C1TA0BR16TA23U40TA157U40TA115D17TA65D17TA35BU20P1,1" '    No Rotate Up Arrow
Arrow$(3, 2) = "C1TA0BR9BD12TA157D40TA23L40TA65D17TA115L17TA0BU10P1,1" '  No Rotate Up Right Arrow
Arrow$(3, 3) = "C1TA0BD16TA23R40TA157R40TA115L17TA65L17TA35BR20P1,1" '    No Rotate Right Arrow
Arrow$(3, 4) = "C1TA0BL12BD9TA157L40TA23U40TA65L17TA115U17TA0BR10P1,1" '  No Rotate Down Right Arrow
Arrow$(3, 5) = "C1TA0BL16TA23D40TA157D40TA115U17TA65U17TA35BD20P1,1" '    No Rotate Down Arrow
Arrow$(3, 6) = "C1TA0BR12BD9TA23L40TA157D40TA115L17TA65D17TA0BL10P1,1" '  No Rotate Down Left Arrow
Arrow$(3, 7) = "C1TA0BU16TA23L40TA157L40TA115R17TA65R17TA35BL20P1,1" '    No Rotate Left Arrow
Arrow$(3, 8) = "C1TA0BR10BU10TA157R40TA23D40TA65R17TA115D17TA0BL10P1,1" ' No Rotate Up Left Arrow

BoardSpace$ = "C15TA0BR33BU14U20L20TA45U20TA135U20TA0L20D20TA135U20TA225U20TA0D20R20TA225U20TA45R20TA0R20U20TA45R20U20TA0BL3P2,15"
GameTitle$ = "C15TA0BR33BU14U13L13TA45U13TA135U13TA0L13D13TA135U13TA225U13TA0D13R13TA225U13TA45R13TA0R13U13TA45R13U13TA0BL3P15,15"
CapturedPieces$ = "CAPTURED PIECES"

' Draw Board
PSET (378, 10), 15: DRAW "TA0L214TA45L218TA0D407TA45D218TA0R522TA45R218TA0U407TA45U218TA0L330BD3P1,15"

X = 80
FOR Z = 1 TO 6
   W = 80
   FOR Y = 1 TO 7
      IF BoardSpace(Z, Y) THEN PSET (W, X), 1: DRAW BoardSpace$
      IF BoardPlayer(Z, Y) THEN X1 = W: X2 = X: X3 = BoardPlayer(Z, Y): X4 = BoardRotation(Z, Y): GOSUB DrawPiece
      BoardX(Z, Y) = W: BoardY(Z, Y) = X
      W = W + 115
   NEXT
   X = X + 115
NEXT

' Draw Game Title
X = 883
FOR Z = 1 TO 6

   PSET (X, 45), 15: DRAW GameTitle$

   SELECT CASE Z
      CASE 1, 4, 6
         IF Z = 1 THEN W = 4 ELSE W = 8
         CIRCLE (X + 11, 40), 18, W: CIRCLE (X + 11, 40), 10, W: PAINT (X - 5, 40), W
      CASE 2
         CIRCLE (X + 11, 40), 18, 8, .80, 5.40: CIRCLE (X + 11, 40), 10, 8, .80, 5.25:
         PSET (X + 11, 40), 15: DRAW "C8TA45BR10R7BL17BD10D7": PAINT (X - 5, 40), 8
      CASE 3
         PSET (X + 11, 60), 4: DRAW "TA0R4U29R5E8L34F8R5D29R4BU3P4,4"
      CASE 5
         CIRCLE (X + 11, 40), 18, 4, .80, 0.25: CIRCLE (X + 11, 40), 10, 4, .80, 5.5
         PSET (X + 11, 40), 4: DRAW "TA45BR10R7BL17TA0BR17BU3L20D8R12": PAINT (X - 5, 40), 4
   END SELECT

   X = X + 71
NEXT

' Draw Captured Pieces Stoage Sections
LINE (883, 310)-(1033, 670), 1, BF: LINE (883, 310)-(1033, 670), 15, B
LINE (1111, 310)-(1261, 670), 1, BF: LINE (1111, 310)-(1261, 670), 15, B

X = 310
FOR Z = 1 TO 15
   _PRINTSTRING (1068, X), MID$(CapturedPieces$, Z, 1)
   X = X + 25
NEXT

StartGame:
Move = 1: CanRotateNext = 1: CanRotatePrevious = 1

' Draw Player Indicator
X1 = 1072: X2 = 121: X3 = Player: X4 = 1: GOSUB DrawPiece
LOCATE 8, 116: PRINT "Player:"; Player;
LOCATE 8, 146: PRINT "Move #:"; Move;

ChoosePiece:
LOCATE 45, 117: PRINT "       Choose a Piece to Play       ";

GetBoardLocation:
DO WHILE _MOUSEINPUT
   FOR Z = 1 TO 6
      FOR Y = 1 TO 7
         IF _MOUSEX > BoardX(Z, Y) - 30 AND _MOUSEX < BoardX(Z, Y) + 30 AND _MOUSEY > BoardY(Z, Y) - 30 AND _MOUSEY < BoardY(Z, Y) + 30 THEN Selected = 1 ELSE Selected = 0
         IF _MOUSEBUTTON(1) AND BoardPlayer(Z, Y) = Player AND Selected THEN
            GOSUB ReleaseButton: CIRCLE (BoardX(Z, Y), BoardY(Z, Y)), 55, 15
            Row = Z: Column = Y: Rotation = BoardRotation(Z, Y): GOTO ChoosePlay
         END IF
      NEXT
   NEXT
LOOP
A$ = INKEY$: IF A$ <> "" THEN IF ASC(A$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(A$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
GOTO GetBoardLocation

ChoosePlay:
LOCATE 8, 146: PRINT "Move #:"; Move;

' Display Piece for Rotation
X1 = 1072: X2 = 230: X3 = Player: X4 = Rotation: GOSUB DrawPiece

' Get Next and Previous Rotations
IF Rotation = 1 THEN PreviousRotation = 8 ELSE PreviousRotation = Rotation - 1
IF Rotation = 8 THEN NextRotation = 1 ELSE NextRotation = Rotation + 1

' Display Next and Previous Piece Rotations
X = 960
FOR Z = 1 TO 2
   X1 = X: X2 = 230
   IF (Z = 1 AND CanRotatePrevious = 1) OR (Z = 2 AND CanRotateNext = 1) THEN X3 = Player ELSE X3 = 3
   IF Z = 1 THEN X4 = PreviousRotation ELSE X4 = NextRotation
   GOSUB DrawPiece: RotateX(Z) = X
   X = X + 224
NEXT
RotateX(3) = 1072

LOCATE 19, 112: PRINT "Counter Clockwise                Clockwise";

' Set Board Playable Locations to 0
FOR Z = 1 TO 6: FOR Y = 1 TO 7: Playable(Z, Y) = 0: NEXT: NEXT

' Check Playable Board Locations
X = 0
IF Move = 1 THEN Playable(Row, Column) = 1
IF Row - 1 >= 1 THEN IF BoardSpace(Row - 1, Column) AND BoardPlayer(Row - 1, Column) <> Player AND BoardRotation(Row, Column) = 1 THEN Playable(Row - 1, Column) = 1: X = 1
IF Row + 1 <= 6 THEN IF BoardSpace(Row + 1, Column) AND BoardPlayer(Row + 1, Column) <> Player AND BoardRotation(Row, Column) = 5 THEN Playable(Row + 1, Column) = 1: X = 1
IF Column - 1 >= 1 THEN IF BoardSpace(Row, Column - 1) AND BoardPlayer(Row, Column - 1) <> Player AND BoardRotation(Row, Column) = 7 THEN Playable(Row, Column - 1) = 1: X = 1
IF Column + 1 <= 7 THEN IF BoardSpace(Row, Column + 1) AND BoardPlayer(Row, Column + 1) <> Player AND BoardRotation(Row, Column) = 3 THEN Playable(Row, Column + 1) = 1: X = 1
IF Row - 1 >= 1 AND Column - 1 >= 1 THEN IF BoardSpace(Row - 1, Column - 1) AND BoardPlayer(Row - 1, Column - 1) <> Player AND BoardRotation(Row, Column) = 8 THEN Playable(Row - 1, Column - 1) = 1: X = 1
IF Row + 1 <= 6 AND Column + 1 <= 7 THEN IF BoardSpace(Row + 1, Column + 1) AND BoardPlayer(Row + 1, Column + 1) <> Player AND BoardRotation(Row, Column) = 4 THEN Playable(Row + 1, Column + 1) = 1: X = 1
IF Row - 1 >= 1 AND Column + 1 <= 7 THEN IF BoardSpace(Row - 1, Column + 1) AND BoardPlayer(Row - 1, Column + 1) <> Player AND BoardRotation(Row, Column) = 2 THEN Playable(Row - 1, Column + 1) = 1: X = 1
IF Row + 1 <= 6 AND Column - 1 >= 1 THEN IF BoardSpace(Row + 1, Column - 1) AND BoardPlayer(Row + 1, Column - 1) <> Player AND BoardRotation(Row, Column) = 6 THEN Playable(Row + 1, Column - 1) = 1: X = 1

LOCATE 45, 117: PRINT "Choose Rotation or Board Location";

GetPlayChoice:
DO WHILE _MOUSEINPUT
   ' Piece Rotation
   RotatePlay = 0
   FOR Z = 1 TO 3
      IF _MOUSEX > RotateX(Z) - 50 AND _MOUSEX < RotateX(Z) + 50 AND _MOUSEY > 180 AND _MOUSEY < 280 THEN Selected = 1 ELSE Selected = 2
      IF Selected AND ((Z = 1 AND CanRotatePrevious) OR (Z = 2 AND CanRotateNext) OR Z = 3) THEN
         IF Move = 2 AND Z = 3 THEN W = 15 ELSE IF Z = 3 THEN W = 0 ELSE W = 15
         LINE (RotateX(Z) - 50, 180)-(RotateX(Z) + 50, 280), W, B
         IF Move = 2 THEN LOCATE 19, 112: PRINT "                   End Turn               ";
      ELSE
         LINE (RotateX(Z) - 50, 180)-(RotateX(Z) + 50, 280), 0, B
         LOCATE 19, 112: PRINT "Counter Clockwise                Clockwise";
      END IF
      IF _MOUSEBUTTON(1) AND Selected THEN
         GOSUB ReleaseButton
         ' Rotate Piece Counter Clockwise
         IF Z = 1 AND CanRotatePrevious THEN
            RotatePlay = 1: Rotation = PreviousRotation: CanRotateNext = 0: GOTO MakeMove
         END IF
         ' Rotate Piece Clockwise
         IF Z = 2 AND CanRotateNext THEN
            RotatePlay = 1: Rotation = NextRotation: CanRotatePrevious = 0: GOTO MakeMove
         END IF
         ' End Turn After First Move
         IF Z = 3 THEN
            GOTO EndPlay
         END IF
      END IF
   NEXT

   ' Move Piece
   FOR Z = 1 TO 6
      FOR Y = 1 TO 7
         IF _MOUSEX > BoardX(Z, Y) - 30 AND _MOUSEX < BoardX(Z, Y) + 30 AND _MOUSEY > BoardY(Z, Y) - 30 AND _MOUSEY < BoardY(Z, Y) + 30 THEN Selected = 1 ELSE Selected = 0
         IF _MOUSEBUTTON(1) AND Playable(Z, Y) AND Selected THEN
            IF Z = Row AND Y = Column AND Move = 1 THEN CIRCLE (BoardX(Z, Y), BoardY(Z, Y)), 55, 1: LINE (880, 180)-(1234, 308), 0, BF: GOTO ChoosePiece ELSE GOTO MakeMove
         END IF
      NEXT
   NEXT

LOOP
A$ = INKEY$: IF A$ <> "" THEN IF ASC(A$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(A$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
GOTO GetPlayChoice

MakeMove:
' Remove Piece from Board
BoardPlayer(Row, Column) = 0: BoardRotation(Row, Column) = 0
PAINT (BoardX(Row, Column), BoardY(Row, Column)), 2, 15
CIRCLE (BoardX(Row, Column), BoardY(Row, Column)), 55, 1

IF RotatePlay = 0 THEN
   ' Check for Capture
   IF BoardPlayer(Z, Y) = Opponent THEN
      PAINT (BoardX(Z, Y), BoardY(Z, Y)), 2, 15
      CapturedPieces(Opponent) = CapturedPieces(Opponent) + 1
      X1 = CapturedX(Opponent, CapturedPieces(Opponent))
      X2 = CapturedY(Opponent, CapturedPieces(Opponent))
      X3 = Opponent: IF Opponent = 1 THEN X4 = 8 ELSE X4 = 2
      GOSUB DrawPiece
   END IF
   ' Move Piece on Board
   Row = Z: Column = Y: BoardPlayer(Z, Y) = Player: BoardRotation(Z, Y) = Rotation
   X1 = BoardX(Z, Y): X2 = BoardY(Z, Y): X3 = Player: X4 = Rotation: GOSUB DrawPiece
ELSE
   ' Rotate Piece
   BoardPlayer(Row, Column) = Player: BoardRotation(Row, Column) = Rotation
   X1 = BoardX(Row, Column): X2 = BoardY(Row, Column): X3 = Player: X4 = Rotation: GOSUB DrawPiece
END IF

EndPlay:
' Remove Rotate Piece Area from View
LINE (880, 180)-(1234, 308), 0, BF

' Check for Winner
IF CapturedPieces(Opponent) = 10 GOTO Winner

IF Move = 1 THEN Move = 2: CIRCLE (BoardX(Row, Column), BoardY(Row, Column)), 55, 15: GOTO ChoosePlay

' Remove Board Position Cursor
CIRCLE (BoardX(Row, Column), BoardY(Row, Column)), 55, 1

Move = 1: SWAP Player, Opponent: GOTO StartGame

ReleaseButton:
DO WHILE _MOUSEINPUT
   IF _MOUSEBUTTON(1) = 0 THEN RETURN
LOOP
GOTO ReleaseButton

DrawPiece:
' Draw Piece Base
SELECT CASE X4
   CASE 1, 3, 5, 7
      PSET (X1, X2), 2
      IF X3 = 1 THEN DRAW "C3TA0BU41BL1TA45L59D59R59U59TA0BD10P3,3"
      IF X3 = 2 THEN DRAW "C7TA0BU41BL1TA45L59D59R59U59TA0BD10P7,7"
      IF X3 = 3 THEN DRAW "C2TA0BU41BL1TA45L59D59R59U59TA0BD10P2,2"
   CASE 2, 4, 6, 8
      IF X3 = 1 THEN V = 3 ELSE IF X3 = 2 THEN V = 7 ELSE V = 2
      LINE (X1 - 30, X2 - 29)-(X1 + 28, X2 + 29), V, BF
END SELECT
' Draw Piece Arrow
PSET (X1, X2), POINT(X1, X2): DRAW Arrow$(X3, X4)
RETURN

Winner:
LOCATE 44, 123: PRINT "Player"; Player; "is the Winner!";
LOCATE 45, 117: PRINT "    Play Another Game? (Y or N)    ";

GetYorN: A$ = UCASE$(INKEY$): IF A$ = "" GOTO GetYorN
IF A$ = "Y" THEN RUN
IF A$ = "N" THEN SYSTEM
IF ASC(A$) = 27 AND FullScreen = 0 THEN FullScreen = -1: _FULLSCREEN _SQUAREPIXELS , _SMOOTH ELSE IF ASC(A$) = 27 THEN FullScreen = 0: _FULLSCREEN _OFF
GOTO GetYorN
Reply
#7
Very good (easy) solution.  I hope somebody gets the "definitive" rules.
___________________________________________________________________________________
I am mostly grateful for the people who came before me.  Will the people after me be grateful for me?
Reply




Users browsing this thread: 3 Guest(s)