A-level 计算机/AQA/试卷 1/程序框架/2021
这是针对 AQA A Level 计算机科学规范的。
这里可以提出关于一些问题的可能性以及如何解决它们的建议。
请尊重他人,不要破坏页面,因为这会影响学生备考!
请不要在这个页面上讨论问题。请改用讨论页面。
2021 年试卷 1 将包含 4 道题,共计 13 分。
- 问题在这里
- 问题在这里
- 问题在这里
- 问题在这里
程序框架上的编程问题
- 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