• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

help write a pseudocode


cfoy2    0

i have a homework assignment that is due next week. i am trying to create a game of the amazons type of game. we are using c language. i need someone to write a pseudocode because im not sure how.


more info:

The software to be developed is inspired by the Game of the Amazons board game, with four queens to both players, of which move before firing an ‘arrow’ that obstructs tiles. In short, the objective is to block off the movement of the opponent’s teams, and the game concludes whenever someone can no longer move any of their queens. This task requires the game to check many conditions before and after moves are made.

As follows, this is the scope of the aforementioned project:

·         The application will be programmed in Java, and therefore should be able to operate on multiple platforms as java allows, however it is not designed with mobile devices in mind.

·         It functions as a standalone application without any network functionality.

·         The application will support two player local play and player vs AI. The mouse should be implemented as a control that allows characters to select pieces and direct them to move or fire an arrow. The AI should at minimum should be able to move and fire arrows according to the rules.

·         The application will consist of a GUI that allows a user to interact with it without need of a console. This includes a menu that allows players to start the game, designate game mode, and forfeit games, as well as a window that displays the grid in which the game takes place (10x10 grid).



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


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 player’s 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 queen’s arrow is selected (aiming is centered on the queen’s 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#.

Share this post

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.