Jump to content

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

From Wikibooks, open books for an open world

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.

Class Diagram
Class Diagram

Section C Predictions

[edit | edit source]

The 2021 paper 1 will contain 4 questions worth 13 marks.

  • Question here
  • Question here
  • Question here
  • Question here

Section D Predictions

[edit | edit source]

Programming Questions on Skeleton Program

  • 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.

Display the tile numbers

[edit | edit source]

Create a subroutine 'DrawGridWithTileNumbers' which will display the tile numbers on a grid to help the players identify each tile

eg for the default game:

  0     1     2     3
     4     5     6     7
  8     9    10    11
    12    13    14    15
 16    17    18    19
    20    21    22    23
 24    25    26    27
    28    29    30    31

C#:

public string DrawGridWithTileNumbers()
{
    var sb = new System.Text.StringBuilder();
    var id = 0;
    var lineNo = 0;

    int width = size / 2;
    int maxId = size * width;

    while (id < maxId)
    {
        // If on an odd-numbered line, add an indent
        if (lineNo % 2 != 0)
            sb.Append("   ");

        // Create line of ID's
        for (int i = 0; i < width; i++)
        {
            sb.Append(id + "      ");
            id++;
        }

        sb.AppendLine();
        lineNo++;
    }

    return sb.ToString();
}

Delphi/Pascal:


Java:


Python:

  # In HexGrid Class
  def DrawGridWithTileNumbers(self):
    count = 0 # Used to count the tiles
    Line = "" # Used to store the output
    for x in range(0, 8):   # Runs through each tile line       
      for y in range(0, 4): # Runs through each column
        if x % 2 == 0: # Checks if odd/even line
          if y == 0: # Adds only 3 spaces to beginning if even line
            Line = Line + "   " + str(count)
          else:
            Line = Line + "     " + str(count)            
        else: 
          Line = Line + str(count) +  "     "
        count = count + 1
      Line = Line + os.linesep
    return Line

   # In PlayGame Subroutine
   while not (GameOver and Player1Turn):
      print(Grid.GetGridAsString(Player1Turn))
      print(Grid.DrawGridWithTileNumbers())


VB.NET:


Create a new method in the class HexGrid to allow you to easily recall the size:

    Public Function GetGridSize()
        Return Size
    End Function

Add the following lines to Playgame (just before loop):

       
 GridSize = Grid.GetGridSize
 DrawGridWithTileNumbers(GridSize)

Add the new subroutine:

    Sub DrawGridWithTileNumbers(GrideSize As Integer)

        Dim Tile As Integer = 0
        Console.WriteLine()

        For i = 1 To GrideSize
            If i Mod 2 = 0 Then
                Console.Write("   ")
            End If

            For j = 1 To GrideSize / 2


                If Tile < 10 Then
                    Console.Write("   " & Tile & "  ")
                Else
                    Console.Write("  " & Tile & "  ")
                End If

                Tile = Tile + 1
            Next

            Console.WriteLine()
        Next
        Console.WriteLine()

    End Sub


Help Command

[edit | edit source]

This question refers to the subroutine PlayGame.

Currently, the player can enter move, saw, dig, upgrade, or spawn as a command. The game is to be amended so that the player can enter a help command, which will show the list of commands they can enter. The help command should not impede the players commands. In other words, the player should be able to enter “help” and it should not be counted as one of the three commands the player enters.

C#:

public static void PlayGame(Player player1, Player player2, HexGrid grid)
{
    bool gameOver = false;
    bool player1Turn = true;
    bool validCommand;
    List<string> commands = new List<string>();
    Console.WriteLine("Player One current state - " + player1.GetStateString());
    Console.WriteLine("Player Two current state - " + player2.GetStateString());
    do
    {
        Console.WriteLine(grid.GetGridAsString(player1Turn));
        if (player1Turn)
            Console.WriteLine(player1.GetName() + " state your three commands, pressing enter after each one.");
        else
            Console.WriteLine(player2.GetName() + " state your three commands, pressing enter after each one.");

        int maxCommands = 3;
        for (int count = 1; count <= maxCommands; count++)
        {
            Console.Write("Enter command: ");
            var command = Console.ReadLine().ToLower();

            if (command == "help")
            {
                DisplayHelpMenu();
                maxCommands++;
                continue;
            }

            commands.Add(command);
        }
        foreach (var c in commands)
        {
            List<string> items = new List<string>(c.Split(' '));
            validCommand = CheckCommandIsValid(items);
            if (!validCommand)
                Console.WriteLine("Invalid command");
            else
            {
                int fuelChange = 0;
                int lumberChange = 0;
                int supplyChange = 0;
                string summaryOfResult;
                if (player1Turn)
                {
                    summaryOfResult = grid.ExecuteCommand(items, ref fuelChange, ref lumberChange, ref supplyChange,
                        player1.GetFuel(), player1.GetLumber(), player1.GetPiecesInSupply());
                    player1.UpdateLumber(lumberChange);
                    player1.UpdateFuel(fuelChange);
                    if (supplyChange == 1)
                        player1.RemoveTileFromSupply();
                }
                else
                {
                    summaryOfResult = grid.ExecuteCommand(items, ref fuelChange, ref lumberChange, ref supplyChange,
                        player2.GetFuel(), player2.GetLumber(), player2.GetPiecesInSupply());
                    player2.UpdateLumber(lumberChange);
                    player2.UpdateFuel(fuelChange);
                    if (supplyChange == 1)
                    {
                        player2.RemoveTileFromSupply();
                    }
                }
                Console.WriteLine(summaryOfResult);
            }
        }

        commands.Clear();
        player1Turn = !player1Turn;
        int player1VPsGained = 0;
        int player2VPsGained = 0;
        if (gameOver)
        {
            grid.DestroyPiecesAndCountVPs(ref player1VPsGained, ref player2VPsGained);
        }
        else
            gameOver = grid.DestroyPiecesAndCountVPs(ref player1VPsGained, ref player2VPsGained);
        player1.AddToVPs(player1VPsGained);
        player2.AddToVPs(player2VPsGained);
        Console.WriteLine("Player One current state - " + player1.GetStateString());
        Console.WriteLine("Player Two current state - " + player2.GetStateString());
        Console.Write("Press Enter to continue...");
        Console.ReadLine();
    }
    while (!gameOver || !player1Turn);
    Console.WriteLine(grid.GetGridAsString(player1Turn));
    DisplayEndMessages(player1, player2);
}

static void DisplayHelpMenu()
{
    Console.WriteLine("\n---HELP MENU---\n");

    Console.WriteLine("...\n");
}

Delphi/Pascal:


Java:


Python:

    commandCount = 1
    while commandCount < 4:
      command = input("Enter command: ").lower()
      if command == "help":
        pass
      else:
        Commands.append(command)
        commandCount = commandCount + 1


VB.NET:

        Dim commandCount As Integer
        Dim command As String
        Dim commandList As New List(Of String)
        commandCount = 0
        While commandCount < 3
            Console.WriteLine("Enter command: ")
            command = Console.ReadLine().ToLower()
            If command = "help" Then
                Console.WriteLine("The commands you can use are: move, dig, saw, spawn, upgrade")
            Else
                commandList.Add(command)
                commandCount += 1
            End If
        End While


Start with a grid of any even width

[edit | edit source]

Create a new function to be called instead of default game or load game. This should allow the user to enter any even number and create a grid of that size. Each location in the grid should have a 25% chance of being a forest, 25% chance of being a peat bog and 50% chance of being a plain. The Barons should still start in the corners of the map as in the default game with a serf in an adjacent tile.

C#:

Delphi/Pascal:


Java:


Python:

def AnyGridSize():
  GridSize = int(input("Enter the grid size you would like to use (Must be an even number): "))
  T = []
  for i in range(GridSize * (GridSize//2)):
    TempNum = random.randint(1,4)
    if TempNum == 1:
        T.append("#")
    elif TempNum == 2:
        T. append("~")
    else:
        T.append(" ")
  Grid = HexGrid(GridSize)
  Player1 = Player("Player One", 0, 10, 10, 5)
  Player2 = Player("Player Two", 1, 10, 10, 5)
  print(T)
  print(Grid._Tiles)
  Grid.SetUpGridTerrain(T)
  Grid.AddPiece(True, "Baron", 0)
  Grid.AddPiece(True, "Serf", 0 + GridSize)
  Grid.AddPiece(False, "Baron", len(T)-1)
  Grid.AddPiece(False, "Serf", len(T) - 1 - GridSize)
  return Player1, Player2, Grid

def DisplayMainMenu():
  print("1. Default game")
  print("2. Load game")
  print("3. Any size game")
  print("Q. Quit")
  print()
  print("Enter your choice: ", end="")

def Main():
  FileLoaded = True
  Player1 = None
  Player2 = None
  Grid = None
  Choice = ""
  while Choice != "Q":
    DisplayMainMenu()
    Choice = input()
    if Choice == "1":
      Player1, Player2, Grid = SetUpDefaultGame()
      PlayGame(Player1, Player2, Grid)
    elif Choice == "2":
      FileLoaded, Player1, Player2, Grid = LoadGame()
      if FileLoaded:
        PlayGame(Player1, Player2, Grid)
    elif Choice == "3":
      Player1, Player2, Grid = AnyGridSize()
      PlayGame(Player1, Player2, Grid)


VB.NET:


Add another command called teleport that allows any piece to move to any location, at a cost of three fuel

[edit | edit source]

Describe the question here

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


Add another type of tile called ore (or other type of resource)

[edit | edit source]

Currently there are 3 terrain types: field, peat bog, and forest. The new type of tile will have the $ symbol and there will be 1 ore for every 10 tiles. 1 ore is worth 2 fuel.

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


Save Option.

[edit | edit source]

My best guess is a way of saving the game; currently you can load game1.txt, but you can't save a game that you are playing. The text file gives us the format to use, so I think this is quite likely.

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:



Game Over Bug

[edit | edit source]

With this version, a player can trap their own baron to end the game. While this kind of makes sense, it is possible that they could ask you to make it so that at least one of the pieces that are trapping a baron must belong to the other player.


C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


Land Mine

[edit | edit source]

Currently, if your baron gets trapped (if the game is over), you can see exactly what is going on. A land mine could be placed on a tile, and hidden from both players, so that if your opponent steps on that tile, they lose that piece.

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


New Piece Type

[edit | edit source]

We have 4 piece types: baron, serf, LESS (Lumberjack), and PBDS (Peat digger). It is possible (especially if there are new terrains or resources), that they might ask you to create a new piece type.


C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


New question

[edit | edit source]

Question description

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


New question

[edit | edit source]

Question description

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


New question

[edit | edit source]

Question description

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


New question

[edit | edit source]

Question description

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


New question

[edit | edit source]

Question description

C#:

Delphi/Pascal:


Java:


Python:


VB.NET:


New question

[edit | edit source]

Question description

C#:

Delphi/Pascal:


Java:


Python:


VB.NET: