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

    2
    ReputationRep:
    Anyone know the forum link for the new syllabus Computer Science Paper1(Monday 6th June 2016)!
    Offline

    2
    ReputationRep:
    (Python) Anybody know how to load the game once it's been saved?
    Offline

    2
    ReputationRep:
    When it comes to saving the board do you think they will want us to only save the pieces that are on the Board and get rid of the 2 arrays that are at the top of the Board and to the left and contain the row and column numbers??
    Offline

    2
    ReputationRep:
    (Original post by faisal148991)
    When it comes to saving the board do you think they will want us to only save the pieces that are on the Board and get rid of the 2 arrays that are at the top of the Board and to the left and contain the row and column numbers??
    This isn't in python is it?
    Offline

    11
    ReputationRep:
    (Original post by Filipo)
    Mine works fine, when I'm in the game and press Q, it returns to the main menu. Then if I continue to press (q)uit game, it just prints the menu again. It doesn't quit the program.. hmm thats a very valid point, I will look into that now.

    EDIT:

    In order to quit the game, an IF statement needs to be implemented inside the IF statement of the option to quit, therefore it will go something like this:

    IF Skip == Q ->
    DisplayMenu()
    Choice = GetMenuChoice(PlayerName)
    IF Choice == "q":
    quit() // I believe the command for that in VB is close()

    EDIT 2:

    If you would like the program to quit inside the window, instead of getting a pop up that prompts you to quit, you just do the following:

    IF Skip == Q ->
    DisplayMenu()
    Choice = GetMenuChoice(PlayerName)
    IF Choice == "q":
    import sys
    sys.exit(0) // not too sure what the VB equivalent is, but just look up exiting a VB program internally using appropriate commands, and you should get the answer!


    Hope that solved the problem.
    The only issue with your Q is that you need to pass Choice as a parameter to PlayGameMethod.

    Since you can't just do
    Choice = GetMenuChoice(PlayerName) since Choice isn't declared in PlayGameMethod, iits a bit extra to having to add another parameter.

    now i need to figure out how to implement this to multiplayer
    Offline

    11
    ReputationRep:
    the Hardest question that i can think of is

    Implementing that the user/computer can only place a piece if it directly next to the piece.
    So far in this game, we can place a piece anywhere but in the real Reversi game, you can only place next to the opponents piece.
    Offline

    1
    ReputationRep:
    (Original post by KnightCode)
    the Hardest question that i can think of is

    Implementing that the user/computer can only place a piece if it directly next to the piece.
    So far in this game, we can place a piece anywhere but in the real Reversi game, you can only place next to the opponents piece.
    Has anyone actually made a solution for this?
    Offline

    11
    ReputationRep:
    (Original post by uGo1001)
    Has anyone actually made a solution for this?
    no :afraid:

    you can play the game here :
    https://www.mathsisfun.com/games/reversi.html

    Its even got harder cause the game won't let you place a piece if you won't flip an opponent (so opponent piece is between two of your pieces, diagonal and horizontally ) and you need to be next to the opponent piece to place a piece.
    Offline

    0
    ReputationRep:
    the more time you think your winning the computer is just way fast ahead the AI is really intelligent at this point does anyone think they would ask us to try make the AI for the computer much more intelligent to know the players coordinates across the board to know where to place its next position on the board??
    Offline

    1
    ReputationRep:
    Someone PLEASE make a working solution to this. in VB
    Offline

    1
    ReputationRep:
    (Original post by dianamajek1)
    the more time you think your winning the computer is just way fast ahead the AI is really intelligent at this point does anyone think they would ask us to try make the AI for the computer much more intelligent to know the players coordinates across the board to know where to place its next position on the board??
    Surely they wont ask this. It would be too hard.
    • Thread Starter
    Offline

    2
    ReputationRep:
    (Original post by uGo1001)
    Has anyone actually made a solution for this?
    I have the soultion I'll upload it when i get home, its not hard as you think
    Offline

    2
    ReputationRep:
    (Original post by brodingoson)
    This isn't in python is it?
    Yeah
    Offline

    18
    ReputationRep:
    (Original post by KnightCode)
    the Hardest question that i can think of is

    Implementing that the user/computer can only place a piece if it directly next to the piece.
    So far in this game, we can place a piece anywhere but in the real Reversi game, you can only place next to the opponents piece.
    This took me about 30 minutes in Java. It is more realising how to check things well. I initially ended up with some hideous looking if statement, and I was able to break it down into this, although I had to modify checkMoveIsValid to take in the other player's character as a parameter.

    boolean checkIfMoveIsValid(char[][] board, int move, char pieceToMove) {
    int row, rowCount;
    int column, columnCount;
    boolean moveIsValid, adjacentCharacter;
    row = move % 10;//The first digit
    column = move / 10;//The second digit moveIsValid = false;//handily, the default is false
    adjacentCharacter = false;//becomes true when a character is detected
    if(column > board[0].length || column < 1 || row > board[0].length || row < 1)//good since square board
    {
    return moveIsValid;
    }
    /* * Checks like this (1-9 represents order, H represents where it wants to be placed
    * 1 2 3 *
    4 H 5 *
    6 7 8 *
    * I originally did this hideous if statement, and then realised I could just use a for loop since it was an array */
    if (board[row][column] == ' '
    {
    for(rowCount = row - 1; rowCount <= row + 1; rowCount++)//checks up to and including
    {
    for(columnCount = column - 1; columnCount <= column + 1; columnCount++)
    {
    try {
    if(board[rowCount][columnCount] == pieceToMove)
    { adjacentCharacter = true; break;
    }
    }
    catch(IndexOutOfBoundsException e)//can end up 1 out of the array
    { break;//we went out of the array
    }
    }
    if(adjacentCharacter == true)//Don't want to waste too much computer time do we?
    {
    break
    ; }
    }
    if(adjacentCharacter == true) {
    moveIsValid = true;
    }
    } return moveIsValid;
    }

    Admittedly, it is not the quickest way. There are more complicated mathematical ways, but it seems to be the quickest and most simple way to write.
    Offline

    1
    ReputationRep:
    (Original post by KnightCode)
    the Hardest question that i can think of is

    Implementing that the user/computer can only place a piece if it directly next to the piece.
    So far in this game, we can place a piece anywhere but in the real Reversi game, you can only place next to the opponents piece.
    i have done this it's quite simple and AQA have already coded the hardest part into the skeleton code. All you have to do is call the function CheckIfThereIsPiecesToFlip 8 times in the CheckIfMoveIsValid (8 times because it's all the pieces next the the player) if it return true at least once, then it's a valid square that player can place their piece.
    Offline

    2
    ReputationRep:
    There's a high chance of Pseudo code coming up, right?
    Offline

    1
    ReputationRep:
    (Original post by brodingoson)
    There's a high chance of Pseudo code coming up, right?
    Well it has been pseudocode for the past 3 years so they might switch it up and do a flowchart! :bunny:
    Offline

    2
    ReputationRep:
    Tried to do the adjacency check for the program and got this:

    #Move can only be valid if an opponents piece can be flipped
    def CheckIfMoveIsValid(Board, Move, BoardSize):
    Row = Move % 10
    Column = Move // 10
    MoveIsValid = False
    if Board[Row][Column] == " ":
    for rowcount in range(-1,2):
    for columncount in range(-1,2):
    if not (rowcount==0 and columncount==0):
    FlipFound = CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, rowcount, column count)
    if FlipFound:
    MoveIsValid = True
    return MoveIsValid


    Not too sure why this doesn't work though - has anyone got a working solution?
    • Thread Starter
    Offline

    2
    ReputationRep:
    Solution to Allow piece placement only when Capturing

    Step 1) there should be a a function called CheckIfMoveIsValid, what you need to do is modify the if statement to this

    If Board[Row, Column] = '"empty space" and
    (CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, 1,0 = true
    or CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, -1, 0) = true
    or CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, 0, 1) = true
    or CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, 0, -1) = true)
    Then MoveIsValid <== True
    what this does is call the function to check if there are pieces to flip and the function will return true or false and if it returns true then the Move entered by the user will be valid

    Step 2) Make HumanPlayerTurn a global variable instead of a local variable in the PlayGame Function

    Step 3)Then paste the following if statement in the function called CheckIfThereArePiecesToFlip right at the start of the function
    If HumanPlayersTurn = true
    Then Board[StartRow, StartColumn] <== 'H'
    Else Board[StartRow, StartColumn] <== 'C'

    when the function to check for flips is called it's normally called after the letter has been assigned to the game board cells so the flip function doesn't see an empty space but sees a letter in the place you entered the coordinates for, since we are now calling it earlier before the letter gets assigned to the board of the player entered co-ordinates the function still reads it as an empty space and will not work that is why in step 3 you have to add and if statement to temporarily assign the selected coordinate to hold a letter instead of an empty space
    Offline

    2
    ReputationRep:
    (Original post by aelahi23)
    Solution to Allow piece placement only when Capturing

    Step 1) there should be a a function called CheckIfMoveIsValid, what you need to do is modify the if statement to this

    If Board[Row, Column] = '"empty space" and
    (CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, 1,0 = true
    or CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, -1, 0) = true
    or CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, 0, 1) = true
    or CheckIfThereArePiecesToFlip(Boar d, BoardSize, Row, Column, 0, -1) = true)
    Then MoveIsValid <== True
    what this does is call the function to check if there are pieces to flip and the function will return true or false and if it returns true then the Move entered by the user will be valid

    Step 2) Make HumanPlayerTurn a global variable instead of a local variable in the PlayGame Function

    Step 3)Then paste the following if statement in the function called CheckIfThereArePiecesToFlip right at the start of the function
    If HumanPlayersTurn = true
    Then Board[StartRow, StartColumn] <== 'H'
    Else Board[StartRow, StartColumn] <== 'C'

    when the function to check for flips is called it's normally called after the letter has been assigned to the game board cells so the flip function doesn't see an empty space but sees a letter in the place you entered the coordinates for, since we are now calling it earlier before the letter gets assigned to the board of the player entered co-ordinates the function still reads it as an empty space and will not work that is why in step 3 you have to add and if statement to temporarily assign the selected coordinate to hold a letter instead of an empty space
    Thanks for this.
    Do you know how to load a game? Personally I believe this will NOT come up as you will either need to be given a file to load in from AQA in the exam computer account or you will have to save a game then load it back in. Validating coordinates, adjacency check and diagonal flipping are likely to come up I feel.
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Has a teacher ever helped you cheat?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

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