A-level Computing/AQA/Paper 1/Skeleton program/2023

This is for the AQA A Level Computer Science Specification.

This is where suggestions can be made about what some of the questions might be and how we can solve them.

Please be respectful and do not vandalise the page, as this would affect students' preparation for exams!

Please do not discuss questions on this page. Instead use the discussion page.

Section C PredictionsEdit

The 2023 paper 1 will contain 6 questions worth 13 marks. As long as you know the program well, this will be a walk in the park.

Section D PredictionsEdit

Programming Questions on Skeleton Program

  • The 2023 paper 1 contains 4 questions: a 5 mark, a 9 mark question, a 10 mark question and one 13 mark question - these marks include the screen capture(s), so the likely marks for the coding will be 1-2 marks lower.
  • The 2022 paper 1 contains 4 questions: a 5 mark, a 9 mark question, a 11 mark question and one 13 mark question - these marks include the screen capture(s), so the likely marks for the coding will be 1-2 marks lower.
  • The 2021 paper 1 contained ...
  • The 2020 paper 1 contained 4 questions: a 6 mark, an 8 mark question, a 11 mark question and one 12 mark question - these marks include the screen capture(s), so the likely marks for the coding will be 1-2 marks lower.
  • The 2019 paper 1 contained 4 questions: a 5 mark, an 8 mark question, a 9 mark question and one 13 mark question - these marks include the screen capture(s), so the marks for the coding will be 1-2 marks lower.
  • The 2018 paper 1 contained one 2 mark question, a 5 mark question, two 9 mark questions, and one 12 mark question - these marks include the screen capture(s).
  • The 2017 paper 1 contained a 5 mark question, three 6 mark questions, and one 12 mark question.

Current questions are speculation by contributors to this page.

New Move: TibbleCrossEdit

Description of problem: The program is to be extended with a new type of move called the "TibbleCross". This move can allow a piece to go up two spaces diagonally from its starting position in any direction ( NW, NE, SE, SW ).

Add this move so it appears first in the queue of moves for both players.

Select the move and test it by selecting piece "22" and then moving to row/column "44"

C#:

private void CreateMoveOptionOffer()
        {
            MoveOptionOffer.Add("tibblecross");
            MoveOptionOffer.Add("jazair");
            MoveOptionOffer.Add("chowkidar");
            MoveOptionOffer.Add("cuirassier");
            MoveOptionOffer.Add("ryott");
            MoveOptionOffer.Add("faujdar");
        }

        private MoveOption CreateRyottMoveOption(int Direction)
        {
            MoveOption NewMoveOption = new MoveOption("ryott");
            Move NewMove = new Move(0, 1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(0, -1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(1 * Direction, 0);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(-1 * Direction, 0);
            NewMoveOption.AddToPossibleMoves(NewMove);
            return NewMoveOption;
        }

        private MoveOption CreateFaujdarMoveOption(int Direction)
        {
            MoveOption NewMoveOption = new MoveOption("faujdar");
            Move NewMove = new Move(0, -1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(0, 1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(0, 2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(0, -2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            return NewMoveOption;
        }

        private MoveOption CreateJazairMoveOption(int Direction)
        {
            MoveOption NewMoveOption = new MoveOption("jazair");
            Move NewMove = new Move(2 * Direction, 0);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(2 * Direction, -2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(2 * Direction, 2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(0, 2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(0, -2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(-1 * Direction, -1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(-1 * Direction, 1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            return NewMoveOption;
        }

        private MoveOption CreateCuirassierMoveOption(int Direction)
        {
            MoveOption NewMoveOption = new MoveOption("cuirassier");
            Move NewMove = new Move(1 * Direction, 0);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(2 * Direction, 0);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(1 * Direction, -2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(1 * Direction, 2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            return NewMoveOption;
        }

        private MoveOption CreateChowkidarMoveOption(int Direction)
        {
            MoveOption NewMoveOption = new MoveOption("chowkidar");
            Move NewMove = new Move(1 * Direction, 1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(1 * Direction, -1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(-1 * Direction, 1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(-1 * Direction, -1 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(0, 2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(0, -2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            return NewMoveOption;
        }

        private MoveOption CreateTibbleCrossMoveOption(int Direction)
        {
            MoveOption NewMoveOption = new MoveOption("tibblecross");
            Move NewMove = new Move(2 * Direction, 2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(2 * Direction, -2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(-2 * Direction, 2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            NewMove = new Move(-2 * Direction, -2 * Direction);
            NewMoveOption.AddToPossibleMoves(NewMove);
            return NewMoveOption;
        }

        private MoveOption CreateMoveOption(string Name, int Direction)
        {
            if (Name == "tibblecross")
            {
                return CreateTibbleCrossMoveOption(Direction);
            }
            else if (Name == "chowkidar")
            {
                return CreateChowkidarMoveOption(Direction);
            }
            else if (Name == "ryott")
            {
                return CreateRyottMoveOption(Direction);
            }
            else if (Name == "faujdar")
            {
                return CreateFaujdarMoveOption(Direction);
            }
            else if (Name == "jazair")
            {
                return CreateJazairMoveOption(Direction);
            }
            else
            {
                return CreateCuirassierMoveOption(Direction);
            }
        }

        private void CreateMoveOptions()
        {
            Players[0].AddToMoveOptionQueue(CreateMoveOption("tibblecross", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("ryott", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("chowkidar", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("cuirassier", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("faujdar", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("jazair", 1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("tibblecross", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("ryott", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("chowkidar", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("jazair", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("faujdar", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("cuirassier", -1));
        }
    }


Delphi/Pascal:


Java:

private MoveOption createTibbleCrossMoveOption(int direction) {
        MoveOption newMoveOption = new MoveOption("tibblecross");
        Move newMove = new Move(2 * direction, 2 * direction);
        newMoveOption.addToPossibleMoves(newMove);
        newMove = new Move(-2 * direction, 2 * direction);
        newMoveOption.addToPossibleMoves(newMove);
        newMove = new Move(2 * direction, -2 * direction);
        newMoveOption.addToPossibleMoves(newMove);
        newMove = new Move(-2 * direction, -2 * direction);
        newMoveOption.addToPossibleMoves(newMove);     
        return newMoveOption;
    }

    private MoveOption createMoveOption(String name, int direction) {
        switch (name) {
            case "tibblecross":
                return createTibbleCrossMoveOption(direction);
            case "chowkidar":
                return createChowkidarMoveOption(direction);
            case "ryott":
                return createRyottMoveOption(direction);
            case "faujdar":
                return createFaujdarMoveOption(direction);
            case "jazair":
                return createJazairMoveOption(direction);
            default:
                return createCuirassierMoveOption(direction);
        }
    }

    private void createMoveOptions(){
        players.get(0).addToMoveOptionQueue(createMoveOption("tibblecross", 1));
        players.get(0).addToMoveOptionQueue(createMoveOption("ryott", 1));
        players.get(0).addToMoveOptionQueue(createMoveOption("chowkidar", 1));
        players.get(0).addToMoveOptionQueue(createMoveOption("cuirassier", 1));
        players.get(0).addToMoveOptionQueue(createMoveOption("faujdar", 1));
        players.get(0).addToMoveOptionQueue(createMoveOption("jazair", 1));        
        players.get(1).addToMoveOptionQueue(createMoveOption("tibblecross", -1));
        players.get(1).addToMoveOptionQueue(createMoveOption("ryott", -1));
        players.get(1).addToMoveOptionQueue(createMoveOption("chowkidar", -1));
        players.get(1).addToMoveOptionQueue(createMoveOption("jazair", -1));
        players.get(1).addToMoveOptionQueue(createMoveOption("faujdar", -1));
        players.get(1).addToMoveOptionQueue(createMoveOption("cuirassier", -1));
    }


Python:

def __CreateMoveOptionOffer(self):
    self._MoveOptionOffer.append("tibblecross") #append the new option
    self._MoveOptionOffer.append("jazair")
    self._MoveOptionOffer.append("chowkidar")
    self._MoveOptionOffer.append("cuirassier")
    self._MoveOptionOffer.append("ryott")
    self._MoveOptionOffer.append("faujdar")

def __CreateTibbleCrossMoveOption(self, Direction):
    NewMoveOption = MoveOption("tibblecross")
    NewMove = Move(2 * Direction,2 * Direction)
    NewMoveOption.AddToPossibleMoves(NewMove)
    NewMove = Move(-2 * Direction,2 * Direction)
    NewMoveOption.AddToPossibleMoves(NewMove)
    NewMove = Move(2 * Direction,-2 * Direction)
    NewMoveOption.AddToPossibleMoves(NewMove)
    NewMove = Move(-2 * Direction,-2 * Direction)
    NewMoveOption.AddToPossibleMoves(NewMove)
    return NewMoveOption

def __CreateMoveOption(self, Name, Direction):
    if Name == "tibblecross":
        return self.__CreateTibbleCrossMoveOption(Direction) ## add the move ##
    elif Name == "chowkidar":
        return self.__CreateChowkidarMoveOption(Direction)
    elif Name == "ryott":
        return self.__CreateRyottMoveOption(Direction)
    elif Name == "faujdar":
        return self.__CreateFaujdarMoveOption(Direction)
    elif Name == "jazair":
        return self.__CreateJazairMoveOption(Direction)
    else:
        return self.__CreateCuirassierMoveOption(Direction)

def __CreateMoveOptions(self):
    self._Players[0].AddToMoveOptionQueue(self.__CreateMoveOption("tibblecross", 1)) ## add to player 1 ##
    self._Players[0].AddToMoveOptionQueue(self.__CreateMoveOption("ryott", 1))
    self._Players[0].AddToMoveOptionQueue(self.__CreateMoveOption("chowkidar", 1))
    self._Players[0].AddToMoveOptionQueue(self.__CreateMoveOption("cuirassier", 1))
    self._Players[0].AddToMoveOptionQueue(self.__CreateMoveOption("faujdar", 1))
    self._Players[0].AddToMoveOptionQueue(self.__CreateMoveOption("jazair", 1))

    self._Players[1].AddToMoveOptionQueue(self.__CreateMoveOption("tibblecross", -1)) ## add to player 2 ##
    self._Players[1].AddToMoveOptionQueue(self.__CreateMoveOption("ryott", -1))
    self._Players[1].AddToMoveOptionQueue(self.__CreateMoveOption("chowkidar", -1))
    self._Players[1].AddToMoveOptionQueue(self.__CreateMoveOption("jazair", -1))
    self._Players[1].AddToMoveOptionQueue(self.__CreateMoveOption("faujdar", -1))
    self._Players[1].AddToMoveOptionQueue(self.__CreateMoveOption("cuirassier", -1))
  1. creds to ella and yani


VB.NET:

  Private Sub CreateMoveOptionOffer()
            MoveOptionOffer.Add("jazair")
            MoveOptionOffer.Add("chowkidar")
            MoveOptionOffer.Add("cuirassier")
            MoveOptionOffer.Add("ryott")
            MoveOptionOffer.Add("faujdar")
            MoveOptionOffer.Add("TibbleCross")
        End Sub
   Private Function CreateTibbleCrossMoveOption(ByVal Direction As Integer) As MoveOption
            Dim NewMoveOption As MoveOption = New MoveOption("TibbleCross")
            Dim NewMove As Move = New Move(2 * Direction, 2 * Direction)
            NewMoveOption.AddToPossibleMoves(NewMove)
            NewMove = New Move(-2 * Direction, 2 * Direction)
            NewMoveOption.AddToPossibleMoves(NewMove)
            NewMove = New Move(2 * Direction, -2 * Direction)
            NewMoveOption.AddToPossibleMoves(NewMove)
            NewMove = New Move(-2 * Direction, -2 * Direction)
            NewMoveOption.AddToPossibleMoves(NewMove)
            Return NewMoveOption
        End Function

        Private Function CreateMoveOption(ByVal Name As String, ByVal Direction As Integer) As MoveOption
            If Name = "chowkidar" Then
                Return CreateChowkidarMoveOption(Direction)
            ElseIf Name = "ryott" Then
                Return CreateRyottMoveOption(Direction)
            ElseIf Name = "faujdar" Then
                Return CreateFaujdarMoveOption(Direction)
            ElseIf Name = "jazair" Then
                Return CreateJazairMoveOption(Direction)
            ElseIf Name = "cuirassier" Then
                Return CreateCuirassierMoveOption(Direction)
            Else
                Return CreateTibbleCrossMoveOption(Direction)
            End If
        End Function

        Private Sub CreateMoveOptions()
            Players(0).AddToMoveOptionQueue(CreateMoveOption("TibbleCross", 1))
            Players(0).AddToMoveOptionQueue(CreateMoveOption("ryott", 1))
            Players(0).AddToMoveOptionQueue(CreateMoveOption("chowkidar", 1))
            Players(0).AddToMoveOptionQueue(CreateMoveOption("cuirassier", 1))
            Players(0).AddToMoveOptionQueue(CreateMoveOption("faujdar", 1))
            Players(0).AddToMoveOptionQueue(CreateMoveOption("jazair", 1))
            Players(1).AddToMoveOptionQueue(CreateMoveOption("TibbleCross", -1))
            Players(1).AddToMoveOptionQueue(CreateMoveOption("ryott", -1))
            Players(1).AddToMoveOptionQueue(CreateMoveOption("chowkidar", -1))
            Players(1).AddToMoveOptionQueue(CreateMoveOption("jazair", -1))
            Players(1).AddToMoveOptionQueue(CreateMoveOption("faujdar", -1))
            Players(1).AddToMoveOptionQueue(CreateMoveOption("cuirassier", -1))
        End Sub


New Move: rookEdit

Description of problem: Add a new move which moves forward until the piece hits the end of the board or hits another piece

C#:

// Line 35 should be moved to Line 38, underneath `CreatePieces(NoOfPieces)`
// The line content is `CreateMoveOptions()`

// Line 304
  private void CreateMoveOptionOffer() {
    MoveOptionOffer.Add("jazair");
    MoveOptionOffer.Add("chowkidar");
    MoveOptionOffer.Add("cuirassier");
    MoveOptionOffer.Add("ryott");
    MoveOptionOffer.Add("faujdar");
    MoveOptionOffer.Add("rook");
//  ^^ THIS LINE WAS ADDED ^^
  }

// Line 387

// START OF ADDED SECTION
  private MoveOption CreateRookMoveOption(int Direction) {
    MoveOption NewMoveOption = new MoveOption("rook");
    for (int row = 1; row < NoOfRows; ++row) {
      int Index = Direction < 0 ? (row - 1) * 10 : (NoOfRows - row - 2) * 10;
      if (Board[Index].GetPieceInSquare() != null) {
        break;
      }
      Move NewMove = new Move(row * Direction, 0);
      NewMoveOption.AddToPossibleMoves(NewMove);
    }
    return NewMoveOption;
  }
// END OF ADDED SECTION


// Line 410, within the `CreateMoveOption function`
...
else if (Name == "rook") {
      return CreateRookMoveOption(Direction);
}
...

// Modified `CreateMoveOptions` at Line 417
  private void CreateMoveOptions() {
    Players[0].AddToMoveOptionQueue(CreateMoveOption("rook", 1));
//  ^^^^^^^^^^^^^^^^^^ THIS LINE WAS ADDED ^^^^^^^^^^^^^^^^^^^^
    Players[0].AddToMoveOptionQueue(CreateMoveOption("ryott", 1));
    Players[0].AddToMoveOptionQueue(CreateMoveOption("chowkidar", 1));
    Players[0].AddToMoveOptionQueue(CreateMoveOption("cuirassier", 1));
    Players[0].AddToMoveOptionQueue(CreateMoveOption("faujdar", 1));
    Players[0].AddToMoveOptionQueue(CreateMoveOption("jazair", 1));
    Players[1].AddToMoveOptionQueue(CreateMoveOption("rook", -1));
//  ^^^^^^^^^^^^^^^^^^ THIS LINE WAS ADDED ^^^^^^^^^^^^^^^^^^^^
    Players[1].AddToMoveOptionQueue(CreateMoveOption("ryott", -1));
    Players[1].AddToMoveOptionQueue(CreateMoveOption("chowkidar", -1));
    Players[1].AddToMoveOptionQueue(CreateMoveOption("jazair", -1));
    Players[1].AddToMoveOptionQueue(CreateMoveOption("faujdar", -1));
    Players[1].AddToMoveOptionQueue(CreateMoveOption("cuirassier", -1));
  }

// This is not required, I just found it made the Illegal Moves a tad more
// obvious

// Line 264
if (MoveLegal) {
...
}
// START OF ADDED SECTION
else {
    Console.WriteLine("\x1b[31;1mIllegal Move ({0}, {1})\x1b[0;0m", StartSquareReference, FinishSquareReference);
}
// END OF ADDED SECTION


Delphi/Pascal:


Java:


Python:

while not SquareIsValid:
                StartSquareReference = self.__GetSquareReference("containing the piece to move")
                SquareIsValid = self.__CheckSquareIsValid(StartSquareReference, True)
            SquareIsValid = False
          
            #this is what changed   
            while not SquareIsValid:
               
                if self._CurrentPlayer.GetQueue(Choice) == "castle":
                    SquareIsValid = True
                    
                    FinishSquareReference = StartSquareReference
                    while SquareIsValid:
                        
                        FinishSquareReference =int(str((int(str(FinishSquareReference)[0])+(1)*self._CurrentPlayer.GetDirection()))+str(FinishSquareReference)[1])
                        
                        
                        SquareIsValid = self.__CheckSquareIsValid(FinishSquareReference, False)
                        if SquareIsValid == False:
                            FinishSquareReference =int(str((int(str(FinishSquareReference)[0])-(1)*self._CurrentPlayer.GetDirection()))+str(FinishSquareReference)[1])
                            
                        elif ( self.__CalculatePieceCapturePoints(FinishSquareReference))!=0:
                           
                            FinishSquareReference =int(str((int(str(FinishSquareReference)[0])-(1)*self._CurrentPlayer.GetDirection()))+str(FinishSquareReference)[1])
                            SquareIsValid = True
                            break
                else:
                    FinishSquareReference = self.__GetSquareReference("to move to")
                if SquareIsValid == False:
                    SquareIsValid = self.__CheckSquareIsValid(FinishSquareReference, False)
            #this is the end of what is changed    
                
    
                    
            MoveLegal = self._CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference)
           
            if MoveLegal:
                PointsForPieceCapture = self.__CalculatePieceCapturePoints(FinishSquareReference)
                self._CurrentPlayer.ChangeScore(-(Choice + (2 * (Choice - 1))))
                self._CurrentPlayer.UpdateQueueAfterMove(Choice)
                self.__UpdateBoard(StartSquareReference, FinishSquareReference)
                self.__UpdatePlayerScore(PointsForPieceCapture)
            print("New score: " + str(self._CurrentPlayer.GetScore()) + "\n")
            if self._CurrentPlayer.SameAs(self._Players[0]):
                self._CurrentPlayer = self._Players[1]
            else:
                self._CurrentPlayer = self._Players[0]
            GameOver = self.__CheckIfGameOver()
        self.__DisplayState()
        self.__DisplayFinalResult()
def GetQueue(self,Pos):
        Temp = self.__Queue.GetMoveOptionInPosition(Pos - 1).GetName()
        return Temp


VB.NET:


Checking validity of a moveEdit

Description of problem: When choosing where to move a piece, you must input the start square and finish square. If a valid start square is chosen, but an invalid destination square that does not contain a piece is given, the program will move on without prompting the player to re-enter.  

Alter the code to prompt the user to re-enter the finish square until a valid square is given.

C#:

// The changes for this are at the while loop at line 258 in the PlayGame method of the Dastan class

// Move the definition of MoveLegal in front of the while loop
bool MoveLegal = false;
// Make the while loop conditional on both the MoveLegal and SquareIsValid, could also be (!SquareIsValid || !MoveLegal)
while (!(SquareIsValid && MoveLegal))
{
    FinishSquareReference = GetSquareReference("to move to");
    SquareIsValid = CheckSquareIsValid(FinishSquareReference, false);
    // Check if the move is legal in the loop
    MoveLegal = CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference);
    
    // Give some output if it is an illegal move
    if (!MoveLegal)
        Console.WriteLine("Cannot move to that square with this move");
 
    if (!SquareIsValid)
        Console.WriteLine("Invalid position");
}
//bool MoveLegal = CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference);


Delphi/Pascal:


Java:

public void playGame() {
        boolean gameOver = false;
        while (!gameOver) {
            displayState();
            boolean squareIsValid = false;
            int choice;
            do {
                Console.write("Choose move option to use from queue (1 to 3) or 9 to take the offer: ");
                choice = Integer.parseInt(Console.readLine());
                if (choice == 9) {
                    useMoveOptionOffer();
                    displayState();
                }
            } while (choice < 1 || choice > 3);
            int startSquareReference = 0;
            while (!squareIsValid) {
                startSquareReference = getSquareReference("containing the piece to move");
                squareIsValid = checkSquareIsValid(startSquareReference, true);
            }
            int finishSquareReference = 0;

            boolean moveLegal = false; //set up move legal here

            while (!moveLegal) { //change the loop to look at moveLegal
                finishSquareReference = getSquareReference("to move to");
                squareIsValid = checkSquareIsValid(finishSquareReference, false);
                if (squareIsValid){
                    //Calculate moveLegal
                    moveLegal = currentPlayer.checkPlayerMove(choice, startSquareReference, finishSquareReference);
                }
            }
            
            //Can remove the chack to moveLegal here as it will be
            int pointsForPieceCapture = calculatePieceCapturePoints(finishSquareReference);
            currentPlayer.changeScore(-(choice + (2 * (choice - 1))));
 //etc.


Python:

class Dastan:
    ...
    def PlayGame(self):
        ...
        MoveLegal = False  # change from SqureIsValid = False
        while not MoveLegal:  # change from while not SquareIsValid:
            FinishSquareReference = self.__GetSquareReference("to move to")
            SquareIsValid = self.__CheckSquareIsValid(FinishSquareReference, False)
            MoveLegal = self._CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference)  # bring MoveLegal check into while loop so that it asks until the Finish Square move is legal

        # remove if MoveLegal: as it is now guaranteed to be True
        PointsForPieceCapture = self.__CalculatePieceCapturePoints(FinishSquareReference)
        self._CurrentPlayer.ChangeScore(-(Choice + (2 * (Choice - 1))))
        self._CurrentPlayer.UpdateQueueAfterMove(Choice)
        self.__UpdateBoard(StartSquareReference, FinishSquareReference)
        self.__UpdatePlayerScore(PointsForPieceCapture)
        print("New score: " + str(self._CurrentPlayer.GetScore()) + "\n")

        ...


VB.NET:

  While Not SquareIsValid Or MoveLegal = False
                    FinishSquareReference = GetSquareReference("to move to")
                    SquareIsValid = CheckSquareIsValid(FinishSquareReference, False)
                    MoveLegal = CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference)
  End While


New Move: spacejumpEdit

Description of problem: Add a new move called a spacejump which moves the chosen piece to a random place on the board. It can't land on your own pieces, but everywhere else is fine. The player cannot choose where the piece will end up. The spacejump move will not be added to the queue of moves, instead a player is allowed one per game that can be used whenever they choose in lieu of a queue choice. Test by allowing player 1 to use the option from square 22 and then player 2 from square 55. Player 1 will not have the option displayed on their next turn.

C#:

public void PlayGame()
        { 
            /* Only one time use is not implemented*/
            /* SUMMARY  - option of pressing 8 for a spacejump is implemented and the 'finishsquarereferance' is randomly generated instead of asking for user input*/
            bool GameOver = false;
            while (!GameOver)
            {
                DisplayState();
                bool SquareIsValid = false;
                int Choice;
                do
                {
                    Console.Write("Choose move option to use from queue (1 to 3) or 8 to make a space jump or 9 to take the offer: "); //added the option of pressubg 8 for a space jump
                    Choice = Convert.ToInt32(Console.ReadLine());
                    if (Choice == 9)
                    {
                        UseMoveOptionOffer();
                        DisplayState();
                    }
                }
                while (!(Choice != 1 || Choice != 2 || Choice != 3 || Choice != 8)); //adding 8 to the clause so that the loop can be escaped
                int StartSquareReference = 0;
                while (!SquareIsValid)
                {
                    StartSquareReference = GetSquareReference("containing the piece to move");
                    SquareIsValid = CheckSquareIsValid(StartSquareReference, true);
                }
                int FinishSquareReference = 0;
                if (Choice != 8) //if they choose 1, 2 or 3 then this asks the user to input their finish square referenace as normal
                {
                    SquareIsValid = false;
                    bool MoveLegal = false; //moved the definition of movelegal so the issue of user picking a valid square that is not within the bounds of a move skips their turn
                    while (!SquareIsValid || !MoveLegal)                                        
                    {
                        FinishSquareReference = GetSquareReference("to move to");
                        SquareIsValid = CheckSquareIsValid(FinishSquareReference, false);
                        MoveLegal = CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference);
                    }
                    //from here it updates the baord and calaculates points as normal
                    int PointsForPieceCapture = CalculatePieceCapturePoints(FinishSquareReference);
                    CurrentPlayer.ChangeScore(-(Choice + (2 * (Choice - 1))));
                    CurrentPlayer.UpdateQueueAfterMove(Choice);
                    UpdateBoard(StartSquareReference, FinishSquareReference);
                    UpdatePlayerScore(PointsForPieceCapture);
                    Console.WriteLine("New score: " + CurrentPlayer.GetScore() + Environment.NewLine);
                }
                else //if their choice is 8 then it randomly generates a finish square referance
                {
                    do
                    {       // do-while loop so that if the 'finishsquarereferance' does not equal the 'startsquarereferance'
                        FinishSquareReference = RGen.Next(1, NoOfRows) * 10 + RGen.Next(1, NoOfColumns); //1 to NoOfColumns & 1 to NoOfRows
SquareIsValid = CheckSquareIsValid(FinishSquareReference, false);
                    } while (FinishSquareReference == StartSquareReference && !SquareIsValid);                            //because lists are 0 based
                    //calcualtes points and updates the board
                    //removed line 'CurrentPlayer.UpdateQueueAfterMove(Choice);
                    int PointsForPieceCapture = CalculatePieceCapturePoints(FinishSquareReference);
                    CurrentPlayer.ChangeScore(-(Choice + (2 * (Choice - 1))));
                    UpdateBoard(StartSquareReference, FinishSquareReference);
                    UpdatePlayerScore(PointsForPieceCapture);
                    Console.WriteLine("New score: " + CurrentPlayer.GetScore() + Environment.NewLine);
                }
                if (CurrentPlayer.SameAs(Players[0]))
                {
                    CurrentPlayer = Players[1];
                }
                else
                {
                    CurrentPlayer = Players[0];
                }
                GameOver = CheckIfGameOver();
            }
            DisplayState();
            DisplayFinalResult();
        }


Delphi/Pascal:


Java:

class Player {
    private String name; 
    private int direction, score; 
    private MoveOptionQueue queue = new MoveOptionQueue();
    private boolean spaceJumpUsed;
    

    public Player(String n, int d) {
        score = 100;
        name = n;
        direction = d;
        spaceJumpUsed=false;
    }

    public boolean getspaceJumpUsed(){
        return spaceJumpUsed; 
    }
    
    public void setspaceJumpUsed(boolean newValue){
        spaceJumpUsed=newValue;
    }
    //etc.

public void playGame() {
        boolean gameOver = false;
        while (!gameOver) {
            displayState();
            boolean squareIsValid = false;
            char spaceJumpChoice = 'n';
            if (!currentPlayer.getSpaceJumpUsed()) {
                Console.println(" Do you want to space jump (y/n). "
                        + "You can only do this once in a game: ");
                spaceJumpChoice = Console.readLine().charAt(0);
            }

            if (spaceJumpChoice == 'n') {
                //Continue with normal execution
                int choice;
                do {
                    Console.write("Choose move option to use from queue (1 to 3) or 9 to take the offer: ");
                    choice = Integer.parseInt(Console.readLine());
                    if (choice == 9) {
                        useMoveOptionOffer();
                        displayState();
                    }
                } while (choice < 1 || choice > 3);
                int startSquareReference = 0;
                while (!squareIsValid) {
                    startSquareReference = getSquareReference("containing the piece to move");
                    squareIsValid = checkSquareIsValid(startSquareReference, true);
                }
                int finishSquareReference = 0;
                squareIsValid = false;
                while (!squareIsValid) {
                    finishSquareReference = getSquareReference("to move to");
                    squareIsValid = checkSquareIsValid(finishSquareReference, false);
                }
                boolean moveLegal = currentPlayer.checkPlayerMove(choice, startSquareReference, finishSquareReference);
                if (moveLegal) {
                    int pointsForPieceCapture = calculatePieceCapturePoints(finishSquareReference);
                    currentPlayer.changeScore(-(choice + (2 * (choice - 1))));
                    currentPlayer.updateQueueAfterMove(choice);
                    updateboard(startSquareReference, finishSquareReference);
                    updatePlayerScore(pointsForPieceCapture);
                    Console.writeLine("New score: " + currentPlayer.getScore() + System.lineSeparator());
                }
            } else {
                //do a spaceJump - use whatever can be used from normal execution above
                currentPlayer.setSpaceJumpUsed(true);
                int startSquareReference = 0;
                while (!squareIsValid) {
                    startSquareReference = getSquareReference("containing the piece to move");
                    squareIsValid = checkSquareIsValid(startSquareReference, true);
                }
                int finishSquareReference = 0;
                squareIsValid = false;
                while (!squareIsValid) {
                    //Generate a finish square reference within the range 0-99 and then validate it
                    finishSquareReference=rGen.nextInt(100);
                    squareIsValid = checkSquareIsValid(finishSquareReference, false);
                }
                    
                int pointsForPieceCapture = calculatePieceCapturePoints(finishSquareReference);                
                updateboard(startSquareReference, finishSquareReference);
                updatePlayerScore(pointsForPieceCapture);
                Console.writeLine("New score: " + currentPlayer.getScore() + System.lineSeparator());          
            }
            
            if (currentPlayer.sameAs(players.get(0))) {
                currentPlayer = players.get(1);
            } else {
                currentPlayer = players.get(0);
            }
            gameOver = checkIfGameOver();
        }
        displayState();
        displayFinalResult();
    }


Python:

class Dastan: #there is a bug where after choosing spacejump it will print a bunch of memory locations but do i care?
    def PlayGame(self):
        GameOver = False
        while not GameOver:
            self.__DisplayState()
            SquareIsValid = False
            Choice = 10 #different default value
            while Choice < 1 or Choice > 3:
                if self._CurrentPlayer.SpacejumpUsed==True:
                    Choice = int(input("Choose move option to use from queue (1 to 3) or 9 to take the offer: "))
                else:
                    Choice = int(input("Choose move option to use from queue (1 to 3) or 9 to take the offer or 0 to do Spacejump: ")) #ask only if spacejump not used
                if Choice == 9:
                    self.__UseMoveOptionOffer()
                    self.__DisplayState()
                if Choice==0:
                    if self._CurrentPlayer.SpacejumpUsed==True: #if already used
                        Choice=10 #reset and ask again
                    else: #else toggle flag
                        if self._CurrentPlayer==self._Players[0]:
                            self._Players[0].SpacejumpUsed=True
                        if self._CurrentPlayer==self._Players[1]:
                            self._Players[1].SpacejumpUsed=True
                        break #no need to ask again even though while loop condition is satisfied (spacejump IN LIEU of queue choice)
            while not SquareIsValid:
                StartSquareReference = self.__GetSquareReference("containing the piece to move")
                SquareIsValid = self.__CheckSquareIsValid(StartSquareReference, True)
            SquareIsValid = False

            if Choice!=0: #require finish square if not spacejump is chosen
                while not SquareIsValid:
                    FinishSquareReference = self.__GetSquareReference("to move to")
                    SquareIsValid = self.__CheckSquareIsValid(FinishSquareReference, False)
                MoveLegal = self._CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference)
            else:
                while not SquareIsValid:
                    FinishSquareReference = random.randint(1,self._NoOfRows)*10+random.randint(1,self._NoOfColumns) 
 #random row column that is in bounds of board
                    SquareIsValid = self.__CheckSquareIsValid(FinishSquareReference, False) #makes sure piece does not land on own piece
                    MoveLegal=True #move always legal as it can be anywhere

            if MoveLegal:
                PointsForPieceCapture = self.__CalculatePieceCapturePoints(FinishSquareReference)
                if Choice!=0: #relevant only if not spacejump is used
                    self._CurrentPlayer.ChangeScore(-(Choice + (2 * (Choice - 1))))
                    self._CurrentPlayer.UpdateQueueAfterMove(Choice)
                self.__UpdateBoard(StartSquareReference, FinishSquareReference)
                self.__UpdatePlayerScore(PointsForPieceCapture)
                print("New score: " + str(self._CurrentPlayer.GetScore()) + "\n")
            if self._CurrentPlayer.SameAs(self._Players[0]):
                self._CurrentPlayer = self._Players[1]
            else:
                self._CurrentPlayer = self._Players[0]
            GameOver = self.__CheckIfGameOver()
        self.__DisplayState()
        self.__DisplayFinalResult()

class Player:
    def __init__(self, N, D):
        self.__Score = 100
        self.__Name = N
        self.__Direction = D
        self.__Queue = MoveOptionQueue()
        self.SpacejumpUsed=False #add spacejump flag


VB.NET:

  #changes to PlayGame subroutine:
 Loop Until (Choice >= 1 And Choice <= 3) Or (CurrentPlayer.GetSpaceJump = False And Choice = 10)
                Dim StartSquareReference As Integer
                While Not SquareIsValid
                    StartSquareReference = GetSquareReference("containing the piece to move")
                    SquareIsValid = CheckSquareIsValid(StartSquareReference, True)
                End While
                Dim FinishSquareReference As Integer
                If Choice = 10 Then
                    FinishSquareReference = DoSpaceJump()
                Else
                    SquareIsValid = False
                    Console.WriteLine("Movelegal false")
                    Dim MoveLegal As Boolean = False
                    While Not SquareIsValid Or MoveLegal = False
                        FinishSquareReference = GetSquareReference("to move to")
                        SquareIsValid = CheckSquareIsValid(FinishSquareReference, False)
                        MoveLegal = CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference)
                    End While
                End If

#changes to Player class:

Private SpaceJump As Boolean = False
        Public Function GetSpaceJump()
            Return SpaceJump
        End Function
        Sub UseSpaceJump()
            SpaceJump = True
        End Sub

#Changes to Display Player State:

If CurrentPlayer.GetSpaceJump = False Then
                Console.WriteLine("Spacejump available! Write 10 for spacejump")
 End If

#New SpaceJump function(returns finish square reference):
Private Function DoSpaceJump() As Integer
            Dim random As New Random
            Dim ValidReference As Boolean = False
            Dim Reference As Integer
            While ValidReference = False
                Reference = random.Next(11, 66)
                If Board(GetIndexOfSquare(Reference)).GetPieceInSquare() IsNot Nothing Then
                    If   Board(GetIndexOfSquare(Reference)).GetPieceInSquare().GetBelongsTo() IsNot CurrentPlayer Then
                        ValidReference = True
                    End If
                End If
            End While
            CurrentPlayer.UseSpaceJump()
            Return Reference
 End Function


UserName inputEdit

At the beginning of the game allow each user to enter their own name to be used as a replacement to "Player One" and "Player Two"

C#:

 static void Main(string[] args)
        {
            //bercan

            Console.WriteLine("\t --- Welcome to DASTAN! --- \t");
            Console.WriteLine("\n");

            Console.WriteLine("Player a name for player one"); // get name for player 1
            string player1_name = Console.ReadLine();

            Console.WriteLine("Player a name for player two"); // get name for player 2
            string player2_name = Console.ReadLine();

            Console.WriteLine("\n");

            Dastan ThisGame = new Dastan(6, 6, 4, player1_name, player2_name); //enter the parameters
            ThisGame.PlayGame();
            Console.WriteLine("Goodbye!");
            Console.ReadLine();
        }
    }

    class Dastan
    {
        protected List<Square> Board;
        protected int NoOfRows, NoOfColumns, MoveOptionOfferPosition;
        protected List<Player> Players = new List<Player>();
        protected List<string> MoveOptionOffer = new List<string>();
        protected Player CurrentPlayer;
        protected Random RGen = new Random();

        public Dastan(int R, int C, int NoOfPieces , string player1_name , string player2_name) // parameters for the constructor
        {
            Players.Add(new Player(player1_name, 1)); // instead of "Player One" the parameter player1_name
            Players.Add(new Player(player2_name, -1)); // instead of "Player the" the parameter player2_name
            CreateMoveOptions();
            NoOfRows = R;
            NoOfColumns = C;
            MoveOptionOfferPosition = 0;
            CreateMoveOptionOffer();
            CreateBoard();
            CreatePieces(NoOfPieces);
            CurrentPlayer = Players[0];
        }


Delphi/Pascal:


Java:


Python:

class Dastan:
    def __init__(self, R, C, NoOfPieces):
        self._Board = []
        self._Players = []
        self._MoveOptionOffer = []
        playerOneName = input("Please enter player 1's name: ")
        self._Players.append(Player(playerOneName, 1))
        playerTwoName = input("Please enter player 2's name: ")
        self._Players.append(Player(playerTwoName, -1))
        self.__CreateMoveOptions()
...


VB.NET:


Show where the piece can moveEdit

Description of problem: At the moment when selecting a move the player is expected to remember the ways in which move can be applied. Modify the program so that, once a piece has been selected a '^' symbol appears in the squares into which that piece can be moved based on the move selected.

C#:

//Dastan class
private void DisplayBoardMoveOptions(Player CurrentPlayer, int Choice, int StartSquareReference)
{
    //A slightly altered DisplayBoard() but checks if each square is a possible square to move to using CurrentPlayer.CheckPlayerMove() and places "^" if it is

    //Adds Column axis labeling
    Console.Write(Environment.NewLine + "   ");
    for (int Column = 1; Column <= NoOfColumns; Column++)
    {
        Console.Write(Column.ToString() + "  ");
    }
    Console.Write(Environment.NewLine + "  ");
    for (int Count = 1; Count <= NoOfColumns; Count++)
    {
        Console.Write("---");
    }
    Console.WriteLine("-");

         
    for (int Row = 1; Row <= NoOfRows; Row++)
    {
        //For each row add the row labelling at the start (number and spacing)
        Console.Write(Row.ToString() + " ");
        for (int Column = 1; Column <= NoOfColumns; Column++)
        {
            //Either places a "^" for a possible place to move to ,a " " for an empty sqaure or the symbol for the piece in the square

            int Index = GetIndexOfSquare(Row * 10 + Column);
            Console.Write("|" + Board[Index].GetSymbol());
            Piece PieceInSquare = Board[Index].GetPieceInSquare();
            if (CheckSquareIsValid(Row * 10 + Column, false) && CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, Row * 10 + Column))
            {
                Console.Write("^");
            }
            else if (PieceInSquare == null)
            {
                Console.Write(" ");
            } 
            else
            {
                Console.Write(PieceInSquare.GetSymbol());
            }
        }
        Console.WriteLine("|");
    }
    Console.Write("  -");

    // Add spacing for the bottom of the board display
    for (int Column = 1; Column <= NoOfColumns; Column++)
    {
        Console.Write("---");
    }
    Console.WriteLine();
    Console.WriteLine();
}

public void PlayGame()
{
    bool GameOver = false;
    while (!GameOver)
    {
        DisplayState();
        bool SquareIsValid = false;
        int Choice;
        do
        {
            Console.Write("Choose move option to use from queue (1 to 3) or 9 to take the offer: ");
            Choice = Convert.ToInt32(Console.ReadLine());
            if (Choice == 9)
            {
                UseMoveOptionOffer();
                DisplayState();
            }
        }
        while (Choice < 1 || Choice > 3);
        int StartSquareReference = 0;
        while (!SquareIsValid)
        {
            StartSquareReference = GetSquareReference("containing the piece to move");
            SquareIsValid = CheckSquareIsValid(StartSquareReference, true);
        }
        int FinishSquareReference = 0;
        SquareIsValid = false;
        //Display possible move options using currentPlayer, the player choice number and the start point of the move
        DisplayBoardMoveOptions(CurrentPlayer,Choice,StartSquareReference);
        while (!SquareIsValid)
        {
            FinishSquareReference = GetSquareReference("to move to");
            SquareIsValid = CheckSquareIsValid(FinishSquareReference, false);
        }
        bool MoveLegal = CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference);
        if (MoveLegal)
        {
            int PointsForPieceCapture = CalculatePieceCapturePoints(FinishSquareReference);
            CurrentPlayer.ChangeScore(-(Choice + (2 * (Choice - 1))));
            CurrentPlayer.UpdateQueueAfterMove(Choice);
            UpdateBoard(StartSquareReference, FinishSquareReference);
            UpdatePlayerScore(PointsForPieceCapture);
            Console.WriteLine("New score: " + CurrentPlayer.GetScore() + Environment.NewLine);
        }
        if (CurrentPlayer.SameAs(Players[0]))
        {
            CurrentPlayer = Players[1];
        }
        else
        {
            CurrentPlayer = Players[0];
        }
        GameOver = CheckIfGameOver();
    }
    DisplayState();
    DisplayFinalResult();
}


Delphi/Pascal:


Java:


Python:

    def __DisplayMove(self, CurrentPlayer, Choice, StartSquareReference):
        print("\n" + "   ", end="")
        for Column in range(1, self._NoOfColumns + 1):
            print(str(Column) + "  ", end="")
        print("\n" + "  ", end="")
        for Count in range(1, self._NoOfColumns + 1):
            print("---", end="")
        print("-")
        for Row in range(1, self._NoOfRows + 1):
            print(str(Row) + " ", end="")
            for Column in range(1, self._NoOfColumns + 1):
                Index = self.__GetIndexOfSquare(Row * 10 + Column)
                print("|" + self._Board[Index].GetSymbol(), end="")
                PieceInSquare = self._Board[Index].GetPieceInSquare()
                if self.__CheckSquareIsValid(Row * 10 + Column, False) and CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, Row * 10 + Column):
                    print("^", end="")
                elif PieceInSquare is None:
                    print(" ", end="")
                else:
                    print(PieceInSquare.GetSymbol(), end="")
            print("|")
        print("  -", end="")
        for Column in range(1, self._NoOfColumns + 1):
            print("---", end="")
        print()
        print()


    def PlayGame(self):
            ...
            SquareIsValid = False
            self.__DisplayMove(self._CurrentPlayer,Choice,StartSquareReference)
            ...
    
    #~Victor

Any improvements would be appreciated.

VB.NET:

  #Added to sub new:

For i = 1 To 2
                Console.WriteLine("Enter the name of player " & i)
                Dim PlayerName As String = Console.ReadLine
                Dim direction As Integer
                If i = 1 Then
                    direction = 1
                Else
                    direction = 2
                End If
                Players.Add(New Player(PlayerName, direction))
Next


Random start queueEdit

Description of problem: Randomize the players move queue at the beginning of the game so that the players do not start with the same queue at the beginning of every game.

C#:

// Dastan Class
        private void CreateMoveOptions()
        {
            Players[0].AddToMoveOptionQueue(CreateMoveOption("ryott", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("chowkidar", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("cuirassier", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("faujdar", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("jazair", 1));
            Players[0].AddToMoveOptionQueue(CreateMoveOption("crossMove", 1));
            Players[0].Shuffle();
            Players[1].AddToMoveOptionQueue(CreateMoveOption("ryott", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("chowkidar", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("jazair", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("faujdar", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("cuirassier", -1));
            Players[1].AddToMoveOptionQueue(CreateMoveOption("crossMove", -1));
            Players[1].Shuffle();
        }

        // Player Class
        public void Shuffle()
        {
            Queue.Shuffle();
        }

        // MoveOptionQueue Class
        public void Shuffle()
        {
            Random Rand = new Random();
            int n;
            MoveOption temp;
            for (int i = Queue.Count-1; i > 1; i--)
            {
                n = Rand.Next(0, Queue.Count);
                temp = Queue[n];
                Queue[n] = Queue[i];
                Queue[i] = temp;
            }
        }


Delphi/Pascal:


Java:


Python:

    def __CreateMoveOptions(self):
        #creates a list of all possible moves
        list = ["ryott","chowkidar","cuirassier","lazzad","jazair"]
        #random.shufflle will randomize the list contents
        random.shuffle(list)
        #the  for loop will iterate through each of the contents of thh list
        for i in list:
            #and will add the moves to the move options
            self._Players[0].AddToMoveOptionQueue(self.__CreateMoveOption(i, 1))
            self._Players[1].AddToMoveOptionQueue(self.__CreateMoveOption(i, -1))
            
        #-zednin


VB.NET:

Private Sub CreateMoveOptions()
            Dim RandMove As New Random
            For i = 0 To 1

                Dim MoveList As New List(Of String)
                MoveList.AddRange({"ryott", "chowkidar", "cuirassier", "faujdar", "jazair"})
                Dim d As Integer
                If i = 0 Then
                    d = 1
                Else
                    d = -1
                End If
                While MoveList.Count > 0
                    Dim CurrentString As String = MoveList(RandMove.Next(0, MoveList.Count - 1))
                    Players(i).AddToMoveOptionQueue(CreateMoveOption(CurrentString, d))
                    MoveList.Remove(CurrentString)
                End While
            Next
 End Sub


Choose where to put Kotla and MirzaEdit

Description of problem: At the beginning of the game, allow players the option to choose where they place their (Kotla and Mirza) together at the back of their side of the board. For example: Player One can place their Kotla and Mirza between (1,1) to (1,6) and Player Two can place their Kotla and Mirza between (6,1) and (6,6).

C#:


Delphi/Pascal:


Java:


Python:


VB.NET:

          Private Sub CreateBoard()
            Dim S As Square
            Board = New List(Of Square)
            Dim PlayerColumns As New List(Of Integer)
            For i = 0 To 1
                Dim t As Integer
                If i = 0 Then
                    t = 1
                Else
                    t = 6
                End If
                Dim Choice As Integer = -1
                While Choice < 0 Or Choice > 6
                    Console.WriteLine(Players(i).GetName & ", please enter column of where you would like like your kotla and mirza to be placed, it will be placed in row " & t)
                    Choice = Console.ReadLine
                End While

                PlayerColumns.Add(Choice)
            Next
            For Row = 1 To NoOfRows
                For Column = 1 To NoOfColumns
                    If Row = 1 And Column = PlayerColumns(0) Then
                        S = New Kotla(Players(0), "K")
                    ElseIf Row = NoOfRows And Column = PlayerColumns(1) Then
                        S = New Kotla(Players(1), "k")
                    Else
                        S = New Square()
                    End If
                    Board.Add(S)
                Next
            Next
            Dim CurrentPiece As Piece
            CurrentPiece = New Piece("mirza", Players(0), 5, "1")
            Board(GetIndexOfSquare(10 + PlayerColumns(0))).SetPiece(CurrentPiece)
            CurrentPiece = New Piece("mirza", Players(1), 5, "2")
            Board(GetIndexOfSquare(NoOfRows * 10 + PlayerColumns(1))).SetPiece(CurrentPiece)
        End Sub


Player 3Edit

Description of problem: Add a third player to the game.

C#:


Delphi/Pascal:


Java:


Python:


VB.NET:


Question 10Edit

Description of problem: Currently, if a player accepts the move option offer (so for example, player 1 takes the jazair offer and replaces the ryott), they then get exactly the same choices again: Choose move option to use from queue (1 to 3) or 9 to take the offer:. This is what the Preliminary Material says will happen "Taking the move option from the offer does not count as a move" ... it is still that player's turn. However, your challenge is to change this, so it DOES count as a turn, and if they choose 9, it goes on to the next player.

C#:


Delphi/Pascal:


Java:


Python:

def PlayGame(self):
        GameOver = False
        while not GameOver:
            self.__DisplayState()
            SquareIsValid = False
            Choice = 0
            while Choice < 1 or Choice > 3:
                Choice = int(input("Choose move option to use from queue (1 to 3) or 9 to take the offer: "))
                if Choice == 9:
                    #---------
                    #put it before to change player before board is displayed again
                    if self._CurrentPlayer.SameAs(self._Players[0]):
                        self._CurrentPlayer = self._Players[1]
                    else:
                        self._CurrentPlayer = self._Players[0]
                    #---------
                    self.__UseMoveOptionOffer()
                    self.__DisplayState()
            while not SquareIsValid:
                StartSquareReference = self.__GetSquareReference("containing the piece to move")
                SquareIsValid = self.__CheckSquareIsValid(StartSquareReference, True)
            SquareIsValid = False
            while not SquareIsValid:
                FinishSquareReference = self.__GetSquareReference("to move to")
                SquareIsValid = self.__CheckSquareIsValid(FinishSquareReference, False)
            MoveLegal = self._CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference)
            if MoveLegal:
                PointsForPieceCapture = self.__CalculatePieceCapturePoints(FinishSquareReference)
                self._CurrentPlayer.ChangeScore(-(Choice + (2 * (Choice - 1))))
                self._CurrentPlayer.UpdateQueueAfterMove(Choice)
                self.__UpdateBoard(StartSquareReference, FinishSquareReference)
                self.__UpdatePlayerScore(PointsForPieceCapture)
                print("New score: " + str(self._CurrentPlayer.GetScore()) + "\n")
            if self._CurrentPlayer.SameAs(self._Players[0]):
                self._CurrentPlayer = self._Players[1]
            else:
                self._CurrentPlayer = self._Players[0]
            GameOver = self.__CheckIfGameOver()
        self.__DisplayState()
        self.__DisplayFinalResult()
Cooper and Rhys


VB.NET:


Question 11Edit

Description of problem: Currently you can crash the game when asked to choose "use from queue (1 to 3) or 9 to take the offer" by entering non-integer input.

Validate user input forcing it to be an integer, for choosing 1, 2, 3 or 9, and, if 9 was chosen, for then choosing the move option to replace. A good way to do this is to write a method __ValidateUserInput(PromptString) in the Dastan class, and call this method in PlayGame, passing it the required prompt strings in the two situations where it needs to be called. The method should return the user's input. For now, I would not validate whether it is an appropriate integer, just that it is in fact an integer. To do this you will need to use try ... except ValueError, and a while loop.

C#:


Delphi/Pascal:


Java:


Python:

- This fixes any non integer input from crashing the game in all the inputs in the game.

- It also makes it so that when you input a wrong number in "Enter the square to move to (row number followed by column number):" to let you put it again until the correct input of the chosen move.

______________________________________________________________________________________________________________________________
   
 def __GetSquareReference(self, Description):
        ###  ADDED  ###
        SelectedSquare = 0
        try:
            SelectedSquare = int(input("Enter the square " + Description + " (row number followed by column number): "))
        except ValueError:
            pass
        ###  END   ###
        return SelectedSquare
______________________________________________________________________________________________________________________________
    
def __UseMoveOptionOffer(self):
        ### ADDED   ###
        val = True
        while val:
            try:
               ReplaceChoice = int(input("Choose the move option from your queue to replace (1 to 5): "))
            except ValueError:
                continue
            if 0 < ReplaceChoice < 6:
                val = False
            else:
                continue
        ###   END   ###
______________________________________________________________________________________________________________________________
    
def PlayGame(self):
        GameOver = False
        while not GameOver:
            self.__DisplayState()
            SquareIsValid = False
            Choice = 0
            while Choice < 1 or Choice > 3:
                ###   ADDED   ###
                try:
                    Choice = int(input("Choose move option to use from queue (1 to 3) or 9 to take the offer: "))
                except ValueError:
                    continue
                ###   END   ###
______________________________________________________________________________________________________________________________
    
def PlayGame(self):
        GameOver = False
        while not GameOver:
        [...]
            while not SquareIsValid:
                FinishSquareReference = self.__GetSquareReference("to move to")
                SquareIsValid = self.__CheckSquareIsValid(FinishSquareReference, False)
                ###   ADDED   ###
                MoveLegal = self._CurrentPlayer.CheckPlayerMove(Choice, StartSquareReference, FinishSquareReference)
                if MoveLegal == False:
                    SquareIsValid = False
                else:
                    SquareIsValid = True
                ###   END   ###
______________________________________________________________________________________________________________________________
- If you notice a mistake do fix it and if any improvements can be made, please do so :)


VB.NET:


Question 12Edit

Description of problem: You should also see that the Kotla class has some extra lines in the method GetPointsForOccupancy. The child class can add extra attributes and methods, and can alter existing methods.

This example which is already in the code, could be used to model another subclass. For example a "portal" which automatically moves any piece which goes onto it to a certain point. Or a "booster" square which increases the player's score. I'm not sure what the exam in the summer will ask you to do, but my money is on some kind of new class, based on the Kotla model.

For now, try a "portal" class, which will be placed on square 42 for player 1 and 35 for player 2. Any of the player's own pieces which go to this square should magically move to the other player's mirza and win the game.

- Hi, I'm an AQA Employee with the A-Level Computer Science Team. I can confirm that we will not be making students make a new class in one of the questions in the 2023 exam series. Hopes this helps. Please contact us at computer.science@aqa.org.uk for further information if needed.

Regards,

Dan

C#:


Delphi/Pascal:


Java:


Python:


VB.NET:

Potential Questions:

Make the board larger (or allow the user to set the board size).

User help / info / tutorial page.

New class to allow for saving and loading the game.

Limit the number of times the offer option can be taken in a turn.

End the game when one person's score reaches 0 or goes negative.

Undo move option.

Display scores at the end.

Instead of one offer generated, generate three random offers for the user to pick from.