跳轉到內容

A-level 計算機/AQA/試卷 1/程式框架/2021

來自華夏公益教科書,開放的書籍,開放的世界

這是針對 AQA A Level 計算機科學規範的。

這裡可以提出關於一些問題的可能性以及如何解決它們的建議。

請尊重他人,不要破壞頁面,因為這會影響學生備考!
請不要在這個頁面上討論問題。請改用討論頁面

Class Diagram
類圖

C 部分預測

[編輯 | 編輯原始碼]

2021 年試卷 1 將包含 4 道題,共計 13 分。

  • 問題在這裡
  • 問題在這裡
  • 問題在這裡
  • 問題在這裡

D 部分預測

[編輯 | 編輯原始碼]

程式框架上的程式設計問題

  • 2020 年試卷 1 包含 4 道題:一道 6 分題,一道 8 分題,一道 11 分題和一道 12 分題 - 這些分數包含螢幕截圖,因此編碼的可能分數將低 1-2 分。
  • 2019 年試卷 1 包含 4 道題:一道 5 分題,一道 8 分題,一道 9 分題和一道 13 分題 - 這些分數包含螢幕截圖,因此編碼的分數將低 1-2 分。
  • 2018 年試卷 1 包含一道 2 分題,一道 5 分題,兩道 9 分題和一道 12 分題 - 這些分數包含螢幕截圖。
  • 2017 年試卷 1 包含一道 5 分題,三道 6 分題和一道 12 分題。

目前的問題是本頁面貢獻者推測的。

顯示方塊編號

[編輯 | 編輯原始碼]

建立一個名為 “DrawGridWithTileNumbers” 的子程式,它將在網格上顯示方塊編號,幫助玩家識別每個方塊

例如,對於預設遊戲

  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


在 HexGrid 類中建立一個新方法,以便您輕鬆地呼叫大小

    Public Function GetGridSize()
        Return Size
    End Function

在 Playgame 中新增以下行(在迴圈之前)

       
 GridSize = Grid.GetGridSize
 DrawGridWithTileNumbers(GridSize)

新增新的子程式

    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


幫助命令

[編輯 | 編輯原始碼]

此問題指的是子程式 PlayGame。

目前,玩家可以輸入 move、saw、dig、upgrade 或 spawn 作為命令。遊戲將進行修改,以便玩家可以輸入幫助命令,這將顯示他們可以輸入的命令列表。幫助命令不應阻礙玩家的命令。換句話說,玩家應該能夠輸入“help”,它不應該被計入玩家輸入的三個命令之一。

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


以任何偶數寬度開始網格

[編輯 | 編輯原始碼]

建立一個新函式來代替預設遊戲或載入遊戲。這應該允許使用者輸入任何偶數並建立對應大小的網格。網格中的每個位置都應該有 25% 的機率是森林,25% 的機率是泥炭沼澤,50% 的機率是平原。男爵應該仍然像預設遊戲中那樣在地圖的角落開始,並在相鄰的方塊中有一個農奴。

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


新增另一個稱為傳送的命令,允許任何棋子以三燃料的代價移動到任何位置

[編輯 | 編輯原始碼]

在這裡描述問題

C#

Delphi/Pascal


Java


Python


VB.NET


新增另一種型別的方塊,稱為礦石(或其他型別的資源)

[編輯 | 編輯原始碼]

目前有 3 種地形型別:田野、泥炭沼澤和森林。新的方塊型別將使用 $ 符號表示,每 10 個方塊將有 1 個礦石。1 個礦石價值 2 個燃料。

C#

Delphi/Pascal


Java


Python


VB.NET


儲存選項。

[編輯 | 編輯原始碼]

我最好的猜測是儲存遊戲的一種方法;目前您可以載入 game1.txt,但您無法儲存正在玩的遊戲。文字檔案提供了我們使用的格式,所以我認為這是很有可能的。

C#

Delphi/Pascal


Java


Python


VB.NET



遊戲結束錯誤

[編輯 | 編輯原始碼]

在這個版本中,玩家可以將自己的男爵困住以結束遊戲。雖然這在某種程度上是有道理的,但他們可能會要求您使其至少有一個困住男爵的棋子必須屬於另一個玩家。


C#

Delphi/Pascal


Java


Python


VB.NET


目前,如果您的男爵被困住(如果遊戲結束),您可以確切地看到發生了什麼。可以在地圖上放置一個地雷,並對雙方玩家隱藏,以便如果您的對手踩到該方塊,他們將失去該棋子。

C#

Delphi/Pascal


Java


Python


VB.NET


新的棋子型別

[編輯 | 編輯原始碼]

我們有 4 種棋子型別:男爵、農奴、LESS(伐木工)和 PBDS(泥炭挖掘者)。如果存在新的地形或資源,他們可能會要求您建立一個新的棋子型別。


C#

Delphi/Pascal


Java


Python


VB.NET


新問題

[編輯 | 編輯原始碼]

問題描述

C#

Delphi/Pascal


Java


Python


VB.NET


新問題

[編輯 | 編輯原始碼]

問題描述

C#

Delphi/Pascal


Java


Python


VB.NET


新問題

[編輯 | 編輯原始碼]

問題描述

C#

Delphi/Pascal


Java


Python


VB.NET


新問題

[編輯 | 編輯原始碼]

問題描述

C#

Delphi/Pascal


Java


Python


VB.NET


新問題

[編輯 | 編輯原始碼]

問題描述

C#

Delphi/Pascal


Java


Python


VB.NET


新問題

[編輯 | 編輯原始碼]

問題描述

C#

Delphi/Pascal


Java


Python


VB.NET

華夏公益教科書