A-level Computing/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code/2015 Exam/Section D

I just wanted to say good luck to all on results day after that nightmare of a paper! And good luck to any future years who attempt this in class, you'll need it!

It isn't an extremely bad paper, the FEN question (if someone wants to make a solution) just needed you to do something similar to the display board function, and then express blanks as numbers (I admit, I didn't have time to do that!)

Give user option to selectively place pieces onto board.
Currently when the sample game is set up, all of the pieces are positioned in certain places. Edit the program to give the user an option to create their own sample game.

Python Solution

VB.NET solution

Give an option to exit game
When asking for the coordinates for the startPosition, give an option for the user to exit game.

VB.Net Solution

Java Solution

void getMove(Position startPosition, Position finishPosition) { String ExitGame = console.readLine("Enter cooordinates of square containing piece to move (file first) OR press X to exit: "); if (ExitGame.equalsIgnoreCase("x")) {           System.exit(0); }   else {       try {           Integer.parseInt (ExitGame); startPosition.coordinates = Integer.parseInt (ExitGame);; finishPosition.coordinates = console.readInteger("Enter cooordinates of square to move piece to (file first): "); //coordinate entered here will be for the position of the board intended to be moved to          } catch (Exception e)       { console.writeLine(e.getMessage); }           }     }

Pascal Solution

Procedure GetMove(Var StartSquare, FinishSquare : Integer); Begin // change made was 00 is now to quit Write('Enter coordinates of square containing piece to move (file first or 00 will quit): '); Readln(StartSquare); if (StartSquare = 00) then halt; Write('Enter coordinates of square to move piece to (file first): '); Readln(FinishSquare);

End;

Python Solution

Skill trees and levelling up
Add skill trees to the game so that pieces can learn new abilities and skills upon capturing enemy pieces. For students seeking a challenge at some advanced programming.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Add more options to menu
When you start capture the Sarrum you are asked: "Do you want to play the sample game (enter Y for Yes)? ", Add an option that would allow you to say No to start a new game and then an option to close the program.

VB.Net solution

OR

Python Solution

Java Solution

char getTypeOfGame { char sampleGame; console.println("Welcome to 'CAPTURE THE SARRUM!'"); console.println(""); console.println("Choose your option:"); console.println("1. Play the real game (enter N for No)"); console.println("2. Play the sample game (enter Y for Yes)"); console.println("3. Exit CAPTURE THE SARRUM (enter Q for Yes)"); console.println(""); sampleGame = console.readChar; return sampleGame; }

Pascal Solution

C# Solution

VB6.0 Solution

Give user option to randomly place pieces onto board
Currently when the board is initialised, all of the pieces are positioned in the same place. Edit the program to give the user an option to randomly place the pieces onto the board.

VB.Net solution

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Promote Marzaz Pani to Kashshaptu when it reaches home rank
Add a rule that Marzaz Pani (royal attendant) pieces can be promoted to a Kashshaptu (witch) piece if it reaches the front rank (the eighth rank for a white redum, the first rank for a black redum). (NB Makemove already contains code for promoting Redum to Marzaz Pani) This would involve adding the Kashshaptu (witch) piece - which could have the same movement as a queen in chess.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Prevent pieces from moving backwards
Add a rule to CheckMoveIsLegal that means all pieces can only move forward and can not retreat

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Add new piece that behaves like knight in chess
Add a new piece that behaves like a knight in chess - see here for details

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution Jamal Arif of Nelson and Colne College

VB6.0 Solution

Allow Sarrum and Gisgigir to castle (as with king and rook in chess)
Allow a Sarrum (king) and Gisgigir (chariot) to castle (as in chess with a king and rook).

See here for details on castling in chess

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Track number of moves
Add variables to keep track of how many moves each player has had. Add an option to limit a game to 10, 20, or 50 moves - with who ever has the most pieces left after said moves declared the winner.

VB.Net solution

VB.Net solution alternative

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Allow the player to save the game
This is not a short game, so allow a player to save the game by saving the board array and which play goes first.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

OR alternative answer

Prevent program from crashing, when entering incorrect coordinates
There are 2 coordinates to enter. If the first is entered incorrectly, you can still enter the second and then it crashes. Fix this.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

OR can change getMove

VB6.0 Solution

Add a new piece to the game: Kashshaptu
Add the Kashshaptu to the game, the Kashshaptu can move in any direction, any number of spaces, but cannot jump. Replace the Marzaz Pani with this piece.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Add a variable to display the number of pieces each player has
An option will appear after or before a move is made so that the user can choose to see the number of pieces he or she has left on the board.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Add taken pieces Counter
Separate taken pieces counter for White and Black

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Prevent pieces moving off the top or left edge of the board
Currently, you can move pieces into the 0 files or ranks.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

A-level Computing/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code/2015 Exam/Section D

Allow the Redum to move two pieces as its first move.
Pawns in chess are allowed a "double" move, however only out of their starting position.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Print if moving piece does not belong to current player
The initial program does not allow a player to move their enemy's pieces but only prints the normal "please try again" message. This prints a specialised message if you try to move a piece which does not belong to you.

VB.Net solution

Python Solution

Patch file: not-your-piece.patch

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Remove the restriction of one tile on the Nabu
Make the Nabu like a bishop in chess, can move any number of tiles diagonally.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Add a way to forfeit the game
Add an option to forfeit each turn (similar to the way you can knock over your king in chess).

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Use GetTypeOfGame to ask the user what type of game they want to play
Currently the program does not use GetTypeOfGame when asking the user whether they want to play a sample game or not. Make the program use GetTypeOfGame to ask the user whether they want to play a sample game or not.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Change the size of the board
The size of the two dimensional array that holds the board is defined by the constant BoardDimension. Change the size of the board to be bigger (for example: 10 by 10)

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Add a point scoring system
Give players a score based on how many pieces they have taken. Additionally give each piece taken its own unique score. Display the score on the players move and display both scores at the end of the game.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Allow the Redum to perform an 'en passant' move
En passant "is a special pawn capture, that can only occur immediately after a pawn moves two ranks forward from its starting position, and an enemy pawn could have captured it had the pawn moved only one square forward". The program code could be adapted to allow Redums to use such a move.

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Only allow the user to enter one character when choosing the type of game
Currently, when the user is able to choose the type of game they are able to enter multiple characters, this should be limited to one character excluding numbers

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Allow the user to undo a move
Possibly save the game after every move and allow them to load a previous state of the board?

VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Prevent the program from crashing when enter is pressed without any input
VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

VB6.0 Solution

Change Colour of pieces
Currently the board is in Black and white text, This is difficult to read and understand. Add visible different colours to the pieces to make it easier to distinguish between the two sides.

VB.Net solution

Python solution

Change the Etlu to behave like a knight in chess
VB.Net solution

Python Solution

Java Solution

Pascal Solution

C# Solution

Perhaps add demonstration game to demonstrate a move eg Castling
VB.Net

Java Solution

Choose what piece the redum is promoted to when it reaches the end of the board
VB.Net

Python

Make program exit upon a wrong input entered
VB.NET Solution

Python Solution

Modify the program such that you can play against the computer
'Advanced' Solution

The code for this solution is too long to post here. It can be found at github with an explanation for the code at Hillsoft Blog. It is also able to win against everyone in my class.

Pascal Solution

Java Solution

Java Solution

Python Solution

Promote Redum to Kashshaptu when it reaches home rank
Add the rule that the Redum (Soldier) pieces is promoted to a Kashshaptu (Witch) piece if it reaches the other side of the board from where it stated. The Kashshaptu will then move like the Queen in chess.

Python Solution

def CheckKashshaptuMoveIsLegal(Board, StartRank, StartFile, FinishRank, FinishFile): KashshaptuMoveIsLegal = False RankDifference = FinishRank - StartRank FileDifference = FinishFile - StartFile if abs(RankDifference) == abs(FileDifference): KashshaptuMoveIsLegal = True for Count in range(1, FileDifference): if Board[StartRank + Count][StartFile + Count] != " ": KashshaptuMoveIsLegal = False elif FileDifference <= -1: KashshaptuMoveIsLegal = True for Count in range(-1, FileDifference, -1): if Board[StartRank + Count][StartFile + Count] != " ": KashshaptuMoveIsLegal = False elif RankDifference == 0: if FileDifference >= 1: KashshaptuMoveIsLegal = True for Count in range(1, FileDifference): if Board[StartRank][StartFile + Count] != " ": KashshaptuMoveIsLegal = False elif FileDifference <= -1: KashshaptuMoveIsLegal = True for Count in range(-1, FileDifference, -1): if Board[StartRank][StartFile + Count] != " ": KashshaptuMoveIsLegal = False elif FileDifference == 0: if RankDifference >= 1: KashshaptuMoveIsLegal = True for Count in range(1, RankDifference): if Board[StartRank + Count][StartFile] != " ": KashshaptuMoveIsLegal = False elif RankDifference <= -1: KashshaptuMoveIsLegal = True for Count in range(-1, RankDifference, -1): if Board[StartRank + Count][StartFile] != " ": KashshaptuMoveIsLegal = False return KashshaptuMoveIsLegal