Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    2
    ReputationRep:
    Anyone doing the "AQA reverse" game program?
    Offline

    3
    ReputationRep:
    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.
    Offline

    0
    ReputationRep:
    (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.
    Offline

    0
    ReputationRep:
    (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.
    Offline

    6
    ReputationRep:
    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?
    • Thread Starter
    Offline

    2
    ReputationRep:
    (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
    Offline

    3
    ReputationRep:
    (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.
    Offline

    2
    ReputationRep:
    I am also doing this as a re-take in Python. Looks much easier than last year. Seems like AQA run out of ideas.
    Offline

    3
    ReputationRep:
    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?
    Offline

    2
    ReputationRep:
    (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.
    Offline

    0
    ReputationRep:
    (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.
    Offline

    0
    ReputationRep:
    How do you add the multiplayer feature to the game guys??
    • Thread Starter
    Offline

    2
    ReputationRep:
    (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
    Offline

    0
    ReputationRep:
    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.
    Code:
    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?';); 
     Readln(Player1); 
     Writeln('Player 2, What is your name?';); 
     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!';) 
     else 
      if Player1Score = Player2Score then 
       Writeln('That was a draw!';) 
      else 
       Writeln('Well done, ', Player2, ', you have won the game!';)
     Writeln;
     end;
    Offline

    2
    ReputationRep:
    Has anyone figured out how to do multiplayer on python? I'm just going to have a go now.
    Offline

    1
    ReputationRep:
    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.
    Offline

    3
    ReputationRep:
    (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??
    • Thread Starter
    Offline

    2
    ReputationRep:
    (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
    Offline

    6
    ReputationRep:
    I've been trying the multiplayer thing on python, it's probably not perfect but:
    Code:
    #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)
    Offline

    2
    ReputationRep:
    (Original post by 899071)
    I've been trying the multiplayer thing on python, it's probably not perfect but:
    Code:
    #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)
    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
 
 
 
Poll
Do you agree with the PM's proposal to cut tuition fees for some courses?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.