The Student Room Group

Aqa comp1 2016

Anyone doing the "AQA reverse" game program?
(edited 8 years ago)

Scroll to see replies

Reply 1
I'm not doing it (got 120/120 in COMP1 last year) but I've seen the preliminary material and would be interested in seeing the program if you have a copy? Preferably the Pascal version, but any language would be fine.
Original post by marioman
I'm not doing it (got 120/120 in COMP1 last year) but I've seen the preliminary material and would be interested in seeing the program if you have a copy? Preferably the Pascal version, but any language would be fine.


I have it in python can pm it to you , I originally made the thread with the skeleton code attached but they took down my post because of it.
Reply 3
Original post by thatnerdwholifts
I have it in python can pm it to you , I originally made the thread with the skeleton code attached but they took down my post because of it.


hey dya think i can get a copy of that please? i can't find it anywhere online.
Reply 4
I'm doing AQA reverse. Our predictions for questions are:
1. More menu options (there are always more menu options... maybe the multiplayer thing mentioned below?)
2. Scores section/ High scores (seems unlikely as it has already come up and there is no obvious structure already
in the code to support this.)
3. Extend board size parameters
4. Something to do with enter name section (seems obsolete. Maybe a player1/ player2 and letters to match (so
rather than "H" and "C" "K" and "M" or whatever.)
5. Two player mode
6. Loop for wrong coordinate values (The programme already loops for 0,0. Presumably because it is technically
in the array.)
7. Something to do with the flip def/ mechanic (ie. three ways to flip or fixing a flaw etc.)

Does anyone have any thoughts or ideas?
Reply 5
Original post by 899071
I'm doing AQA reverse. Our predictions for questions are:
1. More menu options (there are always more menu options... maybe the multiplayer thing mentioned below?)
2. Scores section/ High scores (seems unlikely as it has already come up and there is no obvious structure already
in the code to support this.)
3. Extend board size parameters
4. Something to do with enter name section (seems obsolete. Maybe a player1/ player2 and letters to match (so
rather than "H" and "C" "K" and "M" or whatever.)
5. Two player mode
6. Loop for wrong coordinate values (The programme already loops for 0,0. Presumably because it is technically
in the array.)
7. Something to do with the flip def/ mechanic (ie. three ways to flip or fixing a flaw etc.)

Does anyone have any thoughts or ideas?


I would also like to add to the list

8. Save the game and the players turn
9. load the game and continue playing
10. fix the crash when you enter a letter for co-ordinates
11. display the actual score of player, currently it just says "well done".
12. allow diagonal capture (probably the last question which is worth 10 marks)
13. let the player skip a turn
Reply 6
Original post by aelahi23
12. allow diagonal capture (probably the last question which is worth 10 marks)


This is unlikely, as there is no way of testing this reliably in the exam due to the computer choosing its moves at random.

I think they may ask something to do with counting the number of pieces of each type on the board, for example calculating the percentage of 'Human' pieces on the board compared to 'Computer' pieces.
Reply 7
I am also doing this as a re-take in Python. Looks much easier than last year. Seems like AQA run out of ideas.
Hi guys,
I predict that this year there will be a question on validating the input of coordinates. The program crashes if you input 10,10 or a letter.
This is almost guaranteed to come up.
This is an easy fix in visual basic with 2 simple if statements.

Anyone have any ideas of what could come up as one of the other tasks?
Reply 9
Original post by TechnoEngineer
Hi guys,
I predict that this year there will be a question on validating the input of coordinates. The program crashes if you input 10,10 or a letter.
This is almost guaranteed to come up.
This is an easy fix in visual basic with 2 simple if statements.

Anyone have any ideas of what could come up as one of the other tasks?


There is also a very easy fix to the invalid coordinates with python. The posts further up mention a couple of good examples of what could also come up. :smile:
Original post by TechnoEngineer
Hi guys,
I predict that this year there will be a question on validating the input of coordinates. The program crashes if you input 10,10 or a letter.
This is almost guaranteed to come up.
This is an easy fix in visual basic with 2 simple if statements.

Anyone have any ideas of what could come up as one of the other tasks?


PLEASE! can you show me the two if statements, I've been trying to fix this problem for hours.
Reply 11
How do you add the multiplayer feature to the game guys??
Reply 12
Original post by ayouby98
How do you add the multiplayer feature to the game guys??


I'm going to attempt this tonight and have an answer for you later today or tommorow unless someone else answers it before me

My current thinking is your probably going to copy paste all the player one functions amd make it for player 2 and just adjust the comouter to not call on any of computer players subroutines
Just done it in Pascal, Just created a multiplayer procedure which is the PlayGame procedure with a few modifications.
P1 and P2 are global variables. Replace 'H' with P1 and 'C' with P2 in the code and at the start of the PlayGame procedure initialise P1 and P2 as 'H' and 'C' respectivley to make sure the program works.procedure Multiplayer(BoardSize: integer);
var
Board: TBoard;
Player1Turn, MoveIsValid: boolean;
Move, Player1Score, Player2Score: integer;
Player1, Player2: string;
begin
Writeln('Player 1, What is your name?':wink:;
Readln(Player1);
Writeln('Player 2, What is your name?':wink:;
Readln(Player2);
P1 := Player1[1];
P2 := Player2[1];
SetUpGameBoard(Board, BoardSize);
Player1Turn := False;
repeat
Player1Turn := not Player1Turn;
DisplayGameBoard(Board, BoardSize);
MoveIsValid := False;
repeat
if Player1Turn then
Move := GetHumanPlayerMove(Player1)
else
Move := GetHumanPlayerMove(Player2);
MoveIsValid := CheckIfMoveIsValid(Board, Move);
until MoveIsValid;
MakeMove(Board, BoardSize, Move, Player1Turn);
until GameOver(Board, BoardSize);
DisplayGameBoard(Board, BoardSize);
Player1Score := GetPlayerScore(Board, BoardSize, P1);
Player2Score := GetPlayerScore(Board, BoardSize, P2);
if Player1Score > Player2Score then
Writeln('Well done, ', Player1, ', you have won the game!':wink:
else
if Player1Score = Player2Score then
Writeln('That was a draw!':wink:
else
Writeln('Well done, ', Player2, ', you have won the game!':wink:
Writeln;
end;
Reply 14
Has anyone figured out how to do multiplayer on python? I'm just going to have a go now.
Reply 15
The skeleton program allows the player to place their piece anywhere on the board, when in a real game, you can only place a piece if doing so actually TAKES an opponents piece. This is a core part of the game, so I imagine that this is quite likely to come up but I can't find a solution yet.
Original post by TechnoEngineer
Hi guys,
I predict that this year there will be a question on validating the input of coordinates. The program crashes if you input 10,10 or a letter.
This is almost guaranteed to come up.
This is an easy fix in visual basic with 2 simple if statements.

Anyone have any ideas of what could come up as one of the other tasks?


how would you fix it in python??
Reply 17
Original post by Jixum
The skeleton program allows the player to place their piece anywhere on the board, when in a real game, you can only place a piece if doing so actually TAKES an opponents piece. This is a core part of the game, so I imagine that this is quite likely to come up but I can't find a solution yet.


I can't seem to find a solution to this one, will try again later in the week
Reply 18
I've been trying the multiplayer thing on python, it's probably not perfect but:
#Skeleton Program for the AQA COMP1 Summer 2016 examination
#this code should be used in conjunction with the Preliminary Material
#written by the AQA COMP1 Programmer Team
#developed in a Python 3.4 programming environment
import random
def SetUpGameBoard(Board, Boardsize):
for Row in range(1, BoardSize + 1):
for Column in range(1, BoardSize + 1):
if (Row == (BoardSize + 1) // 2 and Column == (BoardSize + 1) // 2 + 1) or (Column == (BoardSize + 1) // 2 and Row == (BoardSize + 1) // 2 + 1):
Board[Row][Column] = "C"
elif (Row == (BoardSize + 1) // 2 + 1 and Column == (BoardSize + 1) // 2 + 1) or (Column == (BoardSize + 1) // 2 and Row == (BoardSize + 1) // 2):
Board[Row][Column] = "H"
else:
Board[Row][Column] = " "
def SetUpMultiGameBoard(Board, Boardsize):
for Row in range(1, BoardSize + 1):
for Column in range(1, BoardSize + 1):
if (Row == (BoardSize + 1) // 2 and Column == (BoardSize + 1) // 2 + 1) or (Column == (BoardSize + 1) // 2 and Row == (BoardSize + 1) // 2 + 1):
Board[Row][Column] = PlayerName1[0]
elif (Row == (BoardSize + 1) // 2 + 1 and Column == (BoardSize + 1) // 2 + 1) or (Column == (BoardSize + 1) // 2 and Row == (BoardSize + 1) // 2):
Board[Row][Column] = PlayerName2[0]
else:
Board[Row][Column] = " "
def ChangeBoardSize():
BoardSize = int(input("Enter a board size (between 4 and 9): "))
while not(BoardSize >= 4 and BoardSize <= 9):
BoardSize = int(input("Enter a board size (between 4 and 9): "))
return BoardSize
def GetHumanPlayerMove(PlayerName):
print(PlayerName, "enter the coodinates of the square where you want to place your piece: ", end="")
Coordinates = int(input())
return Coordinates
def GetComputerPlayerMove(BoardSize):
return random.randint(1, BoardSize) * 10 + random.randint(1, BoardSize)
def GameOver(Board, BoardSize):
for Row in range(1 , BoardSize + 1):
for Column in range(1, BoardSize + 1):
if Board[Row][Column] == " ":
return False
return True
def GetPlayersName():
PlayerName = input("What is your name? ")
return PlayerName
def GetPlayerName1():
PlayerName1 = input("What is your name? ")
return PlayerName1
def GetPlayerName2():
PlayerName2 = input("What is Player 2's name?")
return PlayerName2
def CheckIfMoveIsValid(Board, Move):
Row = Move % 10
Column = Move // 10
MoveIsValid = False
if Board[Row][Column] == " ":
MoveIsValid = True
return MoveIsValid
def GetPlayerScore(Board, BoardSize, Piece1, Piece2):
Score = 0
for Row in range(1, BoardSize + 1):
for Column in range(1, BoardSize + 1):
if Board[Row][Column] == Piece1 or Piece2:
Score = Score + 1
return Score
def CheckIfThereArePiecesToFlip(Board, BoardSize, StartRow, StartColumn, RowDirection, ColumnDirection):
RowCount = StartRow + RowDirection
ColumnCount = StartColumn + ColumnDirection
FlipStillPossible = True
FlipFound = False
OpponentPieceFound = False
while RowCount <= BoardSize and RowCount >= 1 and ColumnCount >= 1 and ColumnCount <= BoardSize and FlipStillPossible and not FlipFound:
if Board[RowCount][ColumnCount] == " ":
FlipStillPossible = False
elif Board[RowCount][ColumnCount] != Board[StartRow][StartColumn]:
OpponentPieceFound = True
elif Board[RowCount][ColumnCount] == Board[StartRow][StartColumn] and not OpponentPieceFound:
FlipStillPossible = False
else:
FlipFound = True
RowCount = RowCount + RowDirection
ColumnCount = ColumnCount + ColumnDirection
return FlipFound
def FlipOpponentPiecesInOneDirection(Board, BoardSize, StartRow, StartColumn, RowDirection, ColumnDirection):
FlipFound = CheckIfThereArePiecesToFlip(Board, BoardSize, StartRow, StartColumn, RowDirection, ColumnDirection)
if FlipFound:
RowCount = StartRow + RowDirection
ColumnCount = StartColumn + ColumnDirection
while Board[RowCount][ColumnCount] != " " and Board[RowCount][ColumnCount] != Board[StartRow][StartColumn]:
if Board[RowCount][ColumnCount] == "H":
Board[RowCount][ColumnCount] = "C"
else:
Board[RowCount][ColumnCount] = "H"
RowCount = RowCount + RowDirection
ColumnCount = ColumnCount + ColumnDirection
def MakeMove(Board, BoardSize, Move, HumanPlayersTurn):
Row = Move % 10
Column = Move // 10
if HumanPlayersTurn:
Board[Row][Column] = "H"
else:
Board[Row][Column] = "C"
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 1, 0)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, -1, 0)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 0, 1)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 0, -1)

def MakeMultiMove(Board, BoardSize, Move, HumanPlayersTurn):
Row = Move % 10
Column = Move // 10
if HumanPlayersTurn:
Board[Row][Column] = PlayerName1[0]
else:
Board[Row][Column] = PlayerName2[0]
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 1, 0)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, -1, 0)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 0, 1)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 0, -1)

def PrintLine(BoardSize):
print(" ", end="")
for Count in range(1, BoardSize * 2):
print("_", end="")
print()
def DisplayGameBoard(Board, BoardSize):
print()
print(" ", end="")
for Column in range(1, BoardSize + 1):
print(" ", end="")
print(Column, end="")
print()
PrintLine(BoardSize)
for Row in range(1, BoardSize + 1):
print(Row, end="")
print(" ", end="")
for Column in range(1, BoardSize + 1):
print("|", end="")
print(Board[Row][Column], end="")
print("|")
PrintLine(BoardSize)
print()
def DisplayMenu():
print("(p)lay game")
print("(e)nter name")
print("(c)hange board size")
print("(q)uit")
print("(m)ultiplayer mode")
print()
def GetMenuChoice(PlayerName):
print(PlayerName, "enter the letter of your chosen option: ", end="")
Choice = input()
return Choice
def CreateBoard():
Board = []
for Count in range(BoardSize + 1):
Board.append([])
for Count2 in range(BoardSize + 1):
Board[Count].append("")
return Board
def PlayGame(PlayerName, BoardSize):
Board = CreateBoard()
SetUpGameBoard(Board, BoardSize)
HumanPlayersTurn = False
while not GameOver(Board, BoardSize):
HumanPlayersTurn = not HumanPlayersTurn
DisplayGameBoard(Board, BoardSize)
MoveIsValid = False
while not MoveIsValid:
if HumanPlayersTurn:
Move = GetHumanPlayerMove(PlayerName)
else:
Move = GetComputerPlayerMove(BoardSize)
MoveIsValid = CheckIfMoveIsValid(Board, Move)
if not HumanPlayersTurn:
print("Press the Enter key and the computer will make its move")
input()
MakeMove(Board, BoardSize, Move, HumanPlayersTurn)
DisplayGameBoard(Board, BoardSize)
HumanPlayerScore = GetPlayerScore(Board, BoardSize, "H")
ComputerPlayerScore = GetPlayerScore(Board, BoardSize, "C")
if HumanPlayerScore > ComputerPlayerScore:
print("Well done", PlayerName, ", you have won the game!")
elif HumanPlayerScore == ComputerPlayerScore:
print("That was a draw!")
else:
print("The computer has won the game!")
print()
def PlayMultiGame(PlayerName1, PlayerName2, Boardsize):
Board = CreateBoard()
SetUpMultiGameBoard(Board, BoardSize)
HumanPlayersTurn = False
while not GameOver(Board, BoardSize):
HumanPlayersTurn = not HumanPlayersTurn
DisplayGameBoard(Board, BoardSize)
MoveIsValid = False
while not MoveIsValid:
if HumanPlayersTurn:
Move = GetHumanPlayerMove(PlayerName1)
else:
Move = GetHumanPlayerMove(PlayerName2)
HumanPlayersTurn = False
MoveIsValid = CheckIfMoveIsValid(Board, Move)
#if not HumanPlayersTurn:
#print("Press the Enter key for player 2's turn")
#input()
MakeMultiMove(Board, BoardSize, Move, HumanPlayersTurn)
DisplayGameBoard(Board, BoardSize)
HumanPlayer1Score = GetPlayerScore(Board, BoardSize, PlayerName1[0], "X")
HumanPlayer2Score = GetPlayerScore(Board, BoardSize, PlayerName2[0], "O")
if HumanPlayer1Score > HumanPlayer2Score:
print("Well done", PlayerName1, ", you have won the game!")
elif HumanPlayer1Score == HumanPlayer2Score:
print("That was a draw!")
else:
print("Well done", PlayerName2, ",you have won the game!")
print()


random.seed()
BoardSize = 6
PlayerName = ""
PlayerName1 = ""
Choice = ""
while Choice != "q":
DisplayMenu()
Choice = GetMenuChoice(PlayerName)
if Choice == "p":
PlayGame(PlayerName, BoardSize)
elif Choice == "e":
YU = (input("Is there a player2 Y/N? "))
while YU != "N" and YU != "Y":
YU = (input("Invalid, enter Y/N"))
if YU == "N":
PlayerName = GetPlayersName()
elif YU == "Y":
PlayerName1 = GetPlayerName1()
PlayerName2 = GetPlayerName2()
elif Choice == "c":
BoardSize = ChangeBoardSize()
elif Choice == "m":
if PlayerName1 == "":
PlayerName1 = "X"
PlayerName2 = "O"
PlayMultiGame(PlayerName1, PlayerName2, BoardSize)
else:
PlayMultiGame(PlayerName1, PlayerName2, BoardSize)

Original post by 899071
I've been trying the multiplayer thing on python, it's probably not perfect but:#Skeleton Program for the AQA COMP1 Summer 2016 examination
#this code should be used in conjunction with the Preliminary Material
#written by the AQA COMP1 Programmer Team
#developed in a Python 3.4 programming environment
import random
def SetUpGameBoard(Board, Boardsize):
for Row in range(1, BoardSize + 1):
for Column in range(1, BoardSize + 1):
if (Row == (BoardSize + 1) // 2 and Column == (BoardSize + 1) // 2 + 1) or (Column == (BoardSize + 1) // 2 and Row == (BoardSize + 1) // 2 + 1):
Board[Row][Column] = "C"
elif (Row == (BoardSize + 1) // 2 + 1 and Column == (BoardSize + 1) // 2 + 1) or (Column == (BoardSize + 1) // 2 and Row == (BoardSize + 1) // 2):
Board[Row][Column] = "H"
else:
Board[Row][Column] = " "
def SetUpMultiGameBoard(Board, Boardsize):
for Row in range(1, BoardSize + 1):
for Column in range(1, BoardSize + 1):
if (Row == (BoardSize + 1) // 2 and Column == (BoardSize + 1) // 2 + 1) or (Column == (BoardSize + 1) // 2 and Row == (BoardSize + 1) // 2 + 1):
Board[Row][Column] = PlayerName1[0]
elif (Row == (BoardSize + 1) // 2 + 1 and Column == (BoardSize + 1) // 2 + 1) or (Column == (BoardSize + 1) // 2 and Row == (BoardSize + 1) // 2):
Board[Row][Column] = PlayerName2[0]
else:
Board[Row][Column] = " "
def ChangeBoardSize():
BoardSize = int(input("Enter a board size (between 4 and 9): ":wink:)
while not(BoardSize >= 4 and BoardSize <= 9):
BoardSize = int(input("Enter a board size (between 4 and 9): ":wink:)
return BoardSize
def GetHumanPlayerMove(PlayerName):
print(PlayerName, "enter the coodinates of the square where you want to place your piece: ", end="":wink:
Coordinates = int(input())
return Coordinates
def GetComputerPlayerMove(BoardSize):
return random.randint(1, BoardSize) * 10 + random.randint(1, BoardSize)
def GameOver(Board, BoardSize):
for Row in range(1 , BoardSize + 1):
for Column in range(1, BoardSize + 1):
if Board[Row][Column] == " ":
return False
return True
def GetPlayersName():
PlayerName = input("What is your name? ":wink:
return PlayerName
def GetPlayerName1():
PlayerName1 = input("What is your name? ":wink:
return PlayerName1
def GetPlayerName2():
PlayerName2 = input("What is Player 2's name?":wink:
return PlayerName2
def CheckIfMoveIsValid(Board, Move):
Row = Move % 10
Column = Move // 10
MoveIsValid = False
if Board[Row][Column] == " ":
MoveIsValid = True
return MoveIsValid
def GetPlayerScore(Board, BoardSize, Piece1, Piece2):
Score = 0
for Row in range(1, BoardSize + 1):
for Column in range(1, BoardSize + 1):
if Board[Row][Column] == Piece1 or Piece2:
Score = Score + 1
return Score
def CheckIfThereArePiecesToFlip(Board, BoardSize, StartRow, StartColumn, RowDirection, ColumnDirection):
RowCount = StartRow + RowDirection
ColumnCount = StartColumn + ColumnDirection
FlipStillPossible = True
FlipFound = False
OpponentPieceFound = False
while RowCount <= BoardSize and RowCount >= 1 and ColumnCount >= 1 and ColumnCount <= BoardSize and FlipStillPossible and not FlipFound:
if Board[RowCount][ColumnCount] == " ":
FlipStillPossible = False
elif Board[RowCount][ColumnCount] != Board[StartRow][StartColumn]:
OpponentPieceFound = True
elif Board[RowCount][ColumnCount] == Board[StartRow][StartColumn] and not OpponentPieceFound:
FlipStillPossible = False
else:
FlipFound = True
RowCount = RowCount + RowDirection
ColumnCount = ColumnCount + ColumnDirection
return FlipFound
def FlipOpponentPiecesInOneDirection(Board, BoardSize, StartRow, StartColumn, RowDirection, ColumnDirection):
FlipFound = CheckIfThereArePiecesToFlip(Board, BoardSize, StartRow, StartColumn, RowDirection, ColumnDirection)
if FlipFound:
RowCount = StartRow + RowDirection
ColumnCount = StartColumn + ColumnDirection
while Board[RowCount][ColumnCount] != " " and Board[RowCount][ColumnCount] != Board[StartRow][StartColumn]:
if Board[RowCount][ColumnCount] == "H":
Board[RowCount][ColumnCount] = "C"
else:
Board[RowCount][ColumnCount] = "H"
RowCount = RowCount + RowDirection
ColumnCount = ColumnCount + ColumnDirection
def MakeMove(Board, BoardSize, Move, HumanPlayersTurn):
Row = Move % 10
Column = Move // 10
if HumanPlayersTurn:
Board[Row][Column] = "H"
else:
Board[Row][Column] = "C"
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 1, 0)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, -1, 0)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 0, 1)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 0, -1)

def MakeMultiMove(Board, BoardSize, Move, HumanPlayersTurn):
Row = Move % 10
Column = Move // 10
if HumanPlayersTurn:
Board[Row][Column] = PlayerName1[0]
else:
Board[Row][Column] = PlayerName2[0]
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 1, 0)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, -1, 0)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 0, 1)
FlipOpponentPiecesInOneDirection(Board, BoardSize, Row, Column, 0, -1)

def PrintLine(BoardSize):
print(" ", end="":wink:
for Count in range(1, BoardSize * 2):
print("_", end="":wink:
print()
def DisplayGameBoard(Board, BoardSize):
print()
print(" ", end="":wink:
for Column in range(1, BoardSize + 1):
print(" ", end="":wink:
print(Column, end="":wink:
print()
PrintLine(BoardSize)
for Row in range(1, BoardSize + 1):
print(Row, end="":wink:
print(" ", end="":wink:
for Column in range(1, BoardSize + 1):
print("|", end="":wink:
print(Board[Row][Column], end="":wink:
print("|":wink:
PrintLine(BoardSize)
print()
def DisplayMenu():
print("(p)lay game":wink:
print("(e)nter name":wink:
print("(c)hange board size":wink:
print("(q)uit":wink:
print("(m)ultiplayer mode":wink:
print()
def GetMenuChoice(PlayerName):
print(PlayerName, "enter the letter of your chosen option: ", end="":wink:
Choice = input()
return Choice
def CreateBoard():
Board = []
for Count in range(BoardSize + 1):
Board.append([])
for Count2 in range(BoardSize + 1):
Board[Count].append("":wink:
return Board
def PlayGame(PlayerName, BoardSize):
Board = CreateBoard()
SetUpGameBoard(Board, BoardSize)
HumanPlayersTurn = False
while not GameOver(Board, BoardSize):
HumanPlayersTurn = not HumanPlayersTurn
DisplayGameBoard(Board, BoardSize)
MoveIsValid = False
while not MoveIsValid:
if HumanPlayersTurn:
Move = GetHumanPlayerMove(PlayerName)
else:
Move = GetComputerPlayerMove(BoardSize)
MoveIsValid = CheckIfMoveIsValid(Board, Move)
if not HumanPlayersTurn:
print("Press the Enter key and the computer will make its move":wink:
input()
MakeMove(Board, BoardSize, Move, HumanPlayersTurn)
DisplayGameBoard(Board, BoardSize)
HumanPlayerScore = GetPlayerScore(Board, BoardSize, "H":wink:
ComputerPlayerScore = GetPlayerScore(Board, BoardSize, "C":wink:
if HumanPlayerScore > ComputerPlayerScore:
print("Well done", PlayerName, ", you have won the game!":wink:
elif HumanPlayerScore == ComputerPlayerScore:
print("That was a draw!":wink:
else:
print("The computer has won the game!":wink:
print()
def PlayMultiGame(PlayerName1, PlayerName2, Boardsize):
Board = CreateBoard()
SetUpMultiGameBoard(Board, BoardSize)
HumanPlayersTurn = False
while not GameOver(Board, BoardSize):
HumanPlayersTurn = not HumanPlayersTurn
DisplayGameBoard(Board, BoardSize)
MoveIsValid = False
while not MoveIsValid:
if HumanPlayersTurn:
Move = GetHumanPlayerMove(PlayerName1)
else:
Move = GetHumanPlayerMove(PlayerName2)
HumanPlayersTurn = False
MoveIsValid = CheckIfMoveIsValid(Board, Move)
#if not HumanPlayersTurn:
#print("Press the Enter key for player 2's turn":wink:
#input()
MakeMultiMove(Board, BoardSize, Move, HumanPlayersTurn)
DisplayGameBoard(Board, BoardSize)
HumanPlayer1Score = GetPlayerScore(Board, BoardSize, PlayerName1[0], "X":wink:
HumanPlayer2Score = GetPlayerScore(Board, BoardSize, PlayerName2[0], "O":wink:
if HumanPlayer1Score > HumanPlayer2Score:
print("Well done", PlayerName1, ", you have won the game!":wink:
elif HumanPlayer1Score == HumanPlayer2Score:
print("That was a draw!":wink:
else:
print("Well done", PlayerName2, ",you have won the game!":wink:
print()


random.seed()
BoardSize = 6
PlayerName = ""
PlayerName1 = ""
Choice = ""
while Choice != "q":
DisplayMenu()
Choice = GetMenuChoice(PlayerName)
if Choice == "p":
PlayGame(PlayerName, BoardSize)
elif Choice == "e":
YU = (input("Is there a player2 Y/N? ":wink:)
while YU != "N" and YU != "Y":
YU = (input("Invalid, enter Y/N":wink:)
if YU == "N":
PlayerName = GetPlayersName()
elif YU == "Y":
PlayerName1 = GetPlayerName1()
PlayerName2 = GetPlayerName2()
elif Choice == "c":
BoardSize = ChangeBoardSize()
elif Choice == "m":
if PlayerName1 == "":
PlayerName1 = "X"
PlayerName2 = "O"
PlayMultiGame(PlayerName1, PlayerName2, BoardSize)
else:
PlayMultiGame(PlayerName1, PlayerName2, BoardSize)



I'm do the exam in python 2.7 so not much difference but isn't AQA asking way too much if they're want a 2 player mode in python, takes way too long for just the allocated 50 mins on this section. i'm fine with section C, im worried about Section A & B haha

Quick Reply

Latest

Trending

Trending