Question: Write a pseudocode for this: Speculated classes, functions and data This document is more or less a rough draft for the design process. Build on

Write a pseudocode for this:

Speculated classes, functions and data

This document is more or less a rough draft for the design process. Build on the ideas of these classes

// Main menu content goes here. There may be classes for buttons and functionality in the menus.

//

//

// End main menu content

Main

The main file here operates the cycle of the game. The general flow will be as follows

  • Begin player turn. Check the 8 neighbors of all tiles that have the queen tag matching the current players turn. Use a special check neighbor function here. Game ends if no free queens are found on the grid.

  • Begin loop that waits for user input. It repeats until a valid queen is selected.

  • Begin loop that waits for user input. Repeats until a valid destination for the selected queen is selected. Queens can only move in 8 directions.

  • Begin loop that waits for user input. Repeats until a valid destination for the queens arrow is selected (aiming is centered on the queens selected destination.) Like queens, can only go in 8 directions.

  • With all loops completed, move the queen and place the arrow token in their respective destinations, and end turn. Return to top.

Constant: int MAX = 10

Board(int MAX, int MAX)

  • 2D array of integers. Given how simple the game is, this is all that should be necessary.

  • A 0 means the tile is unoccupied.

  • A 1 means it is occupied by a player1 queen.

  • A 2 means it is occupied by a player2 queen.

  • A 3 means it is occupied by an arrow.

Function: boolean checkOpen (source Board(int X, int Y))

  • Checks neighbors of a specific board tile. Used at the start to determine if there are any free queens.

  • That means the eight neighboring cells: (X+1, Y-1) (X+1, Y) (X+1, Y+1) (X, Y+1) (X, Y-1) (X-1, Y-1) (X-1, Y) (X-1, Y+1).

  • If none are unoccupied (have a value of 0), then return false.

  • If at least one is unoccupied (has a value of 0), then return true.

Function: Boolean checkMove(source Board(int X1, int Y1), destination Board(int X2, int Y2))

  • Checks if move is legal. Can be used for both moving queens and choosing an arrow destination.

  • First, checks if the destination is in one of the eight directions.

    • If both have an equal X value AND Y value, it is illegal

      • Return false.

    • If both have an equal X value OR an equal Y value, it is in a valid direction.

    • If it is in one of the diagonal directions, it is a valid direction.

      • Will have to use math. If X2 is greater than X1 by 3, and Y2 is also greater than Y2 by 3, it should be diagonal. Can replace the 3 with any value, positive or negative. So the formula looks like:

        • If ((X2 X1) = (Y2 Y1)) then it is a valid direction.

  • Check if all tiles between them are unoccupied.

    • Formula differs based on which direction.

      • If there is an occupied tile in the path, it is illegal.

        • Return false.

      • Is there are only unoccupied tiles in the path, it is legal.

        • Return true.

Function: void commitMovement( source Board(int X1, int Y1), queendestination Board(int X2, int Y2), arrowdestination Board(int X3, int Y3))

  • With all loops finished and changes ready to commit, this makes changes to the board.

  • Sets queendestination Board(int X2, int Y2)s integer equal to source Board(int X1, int Y1)s integer (1 or 2).

  • Sets source Board(int X1, int Y1)s integer to 0.

  • Sets arrowdestination Board(int X3, int Y3)s integer to 3.

  • This is all done by inputting Board( x, y) = int. Or whatever equivalent in C#.

Write a pseudocode for this: Speculated classes, functions and data This document

Menu here. Board control options Player vs Player content / Player vs Al content Build selected board and choose who goes first Current player loses, Game ends Can any of the queens move? Find all tiles with matching queens that have at least one unoccupied neighboring tile No Yes Invalid queen selected (no unoccupied neighbors) Player must select a queen Valid queen selected End Turn Set it to the other player's turn Invalid destination (obstructed, out of range, or occupied tile) Choose Destination Valid Destination Update Tiles Remove target queen tag from previously occupied tile, add the tag to the destination tile, and add an arrow tag to the second destination tile Invalid destination (obstructed, out of range, or occupied tile) Choose Arrow Target Valid Destination Menu here. Board control options Player vs Player content / Player vs Al content Build selected board and choose who goes first Current player loses, Game ends Can any of the queens move? Find all tiles with matching queens that have at least one unoccupied neighboring tile No Yes Invalid queen selected (no unoccupied neighbors) Player must select a queen Valid queen selected End Turn Set it to the other player's turn Invalid destination (obstructed, out of range, or occupied tile) Choose Destination Valid Destination Update Tiles Remove target queen tag from previously occupied tile, add the tag to the destination tile, and add an arrow tag to the second destination tile Invalid destination (obstructed, out of range, or occupied tile) Choose Arrow Target Valid Destination

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!