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

    1
    ReputationRep:
    Python code for only letting a player put a piece down if it takes an opponents piece:
    def CheckIfMoveIsValid(Board, Move, BoardSize, HumanPlayersTurn):
    Row = Move % 10
    Column = Move // 10
    MoveIsValid = False
    if Board[Row][Column] == " ":
    if HumanPlayersTurn == True:
    Board[Row][Column] = "H"
    else:
    Board[Row][Column] = "C"
    if ((CheckIfThereArePiecesToFlip(Bo ard, BoardSize, Row, Column, 1, 0) == True) or (CheckIfThereArePiecesToFlip(Boa rd, BoardSize, Row, Column, -1, 0) == True) or (CheckIfThereArePiecesToFlip(Boa rd, BoardSize, Row, Column, 0, 1) == True) or (CheckIfThereArePiecesToFlip(Boa rd, BoardSize, Row, Column, 0, -1) == True)):
    MoveIsValid = True
    else:
    MoveIsValid = False
    Board[Row][Column] = " "
    return MoveIsValid


    This will also work with diagonals if you add 4 more CheckIfThereArePiecesToFlip's.
    You'll also need to add BoardSize and HumanPlayersTurn when you in PlayGame when you call upon the function
    Offline

    2
    ReputationRep:
    (Original post by crazyy)
    Hi guys, I think I managed to allow only moves where pieces can be flipped. Here it is in VB

    Function CheckIfMoveIsValid(ByVal Board(,) As Char, ByVal Move As Integer, ByValBoardsize As Integer,ByVal HumanPlayersTurn AsBoolean) As Boolean

    Dim Row As Integer
    Dim Column As Integer
    Dim MoveIsValid As Boolean
    Row = MoveMod 10
    Column =Move \ 10
    MoveIsValid = False
    If Board(Row, Column) = " " Then
    If HumanPlayersTurn Then
    Board(Row, Column) = "H"
    Else
    Board(Row, Column) = "C"
    End If
    If (CheckIfThereArePiecesToFlip(Boa rd, 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
    Else
    MoveIsValid = FalseThen
    Board(Row, Column) = " "
    End If
    End If
    Return MoveIsValid End Function

    TheCheckIfMoveIsValid is responsible for validating moves.I extended the function's parameters by adding 'ByVal Boardsize' and 'Byval HumanPlayersTurn'. I also added two if statements inside the IF statement 'Board(Row, Column)= " " then…'. If the user places a coordinate where there is space, their piece will be placed there. Afterwards I made an IF statement where I check if there are pieces to be flipped, I basically copied this from the MakeMove sub routine and made an if statement out of it. If at least one of them are true, then the move is valid, else the move is invalid and the piece will be removed from the board (Board(Row, Column) = "". I hope this works for you guys.
    Could you give us an algorithm for it?
    Offline

    10
    ReputationRep:
    Function CheckIfMoveIsValid(Board, Move,Boardsize, HumanPlayersTurn) As Boolean
    Variable Row As Integer
    Variable Column As Integer
    Variable MoveIsValid As Boolean
    Row=Move Mod 10 (same as % )
    Column = Move \ 10 (same as // )
    MoveIsValid = False
    If Board(The x coordinate you inputted,The y coordinate you inputted) = " " (empty space) then
    If HumanPlayersTurn=True then
    Board(The x coordinate you inputted, The y coordinate you inputted) = "H"
    Else
    Board(The x coordinate you inputted, The y coordinate you inputted) = "C"
    EndIf
    If (CheckIfThereArePiecesToFlip(Boa rd, 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
    Else
    MoveIsValid = False
    Board(The x coordinate you inputted, They coordinate you inputted) = "C" (we remove the piece)End If
    End If
    Returen MoveIsValid
    You can do this for diagonal as well,you need to add the other four CheckIfThereArePiecesToFlip combinations:'1 1', '-1-1', '1 -1' and '-1 1'.
    Offline

    0
    ReputationRep:
    (Original post by aelahi23)
    Prepare for logic gate because the Electronic answer document contains a table which I assume will be for a simple logic gate.

    Hamming code will most likely come up and using hamming code to correct the wrong bit
    Have you got a link to the EAD??
    Offline

    1
    ReputationRep:
    (Original post by frosts16)
    Have you got a link to the EAD??
    It's attached
    Attached Files
  1. File Type: docx 2016 Electronic Answer Document (EAD) (1).docx (77.3 KB, 86 views)
    • Thread Starter
    Offline

    2
    ReputationRep:
    (Original post by frosts16)
    Have you got a link to the EAD??
    here is the EAD
    Attached Files
  2. File Type: docx 2016 Electronic Answer Document (EAD).docx (77.3 KB, 71 views)
    Offline

    0
    ReputationRep:
    Thanks!
    Offline

    10
    ReputationRep:
    (Original post by aelahi23)
    here is the EAD
    Thanks man I never knew we can get EAD before the exam
    • Thread Starter
    Offline

    2
    ReputationRep:
    The EAD indicates that Section D this year should be that hard because there are less marks available for the last 2 questions compared to last years paper.

    Last year the last Question was 16 marks now its 13 marks including the screen cap
    Offline

    3
    ReputationRep:
    (Original post by aelahi23)
    Prepare for logic gate because the Electronic answer document contains a table which I assume will be for a simple logic gate.
    Logic gates are not on the specification for this exam (they are in COMP2 instead) so don't expect a logic gate question.

    In previous papers the table has usually been a transition table for a FSM, or a table for a simple dry-run of an algorithm.
    Offline

    2
    ReputationRep:
    (Original post by aelahi23)
    The EAD indicates that Section D this year should be that hard because there are less marks available for the last 2 questions compared to last years paper.

    Last year the last Question was 16 marks now its 13 marks including the screen cap
    Are you doing the old spec?
    Offline

    0
    ReputationRep:
    (Original post by VietDao)
    sorry for the late reply, you don't actually need that i put that in there so i could do amendment later when player want to change their initial but you can just do this:
    Function ShowValidMove(ByRef board(,) As Char, ByVal boardSize As Integer) Dim x As Integer = 0 For i As Integer = 1 To boardSize For a As Integer = 1 To boardSize If board(i, a) = "X" Then board(i, a) = " " End If If board(i, a) = " " Then board(i, a) = "H" If FlipOpponentPiecesInOneDirection (board, boardSize, i, a, 1, 0, True) Or FlipOpponentPiecesInOneDirection (board, boardSize, i, a, 1, -1, True) Or FlipOpponentPiecesInOneDirection (board, boardSize, i, a, -1, -1, True) Or FlipOpponentPiecesInOneDirection (board, boardSize, i, a, -1, 0, True) Or FlipOpponentPiecesInOneDirection (board, boardSize, i, a, -1, 1, True) Or FlipOpponentPiecesInOneDirection (board, boardSize, i, a, 0, 1, True) Or FlipOpponentPiecesInOneDirection (board, boardSize, i, a, 1, 1, True) Or FlipOpponentPiecesInOneDirection (board, boardSize, i, a, 0, -1, True) Then board(i, a) = "X" x += 1 Else board(i, a) = " " End If End If Next Next Return x End Function

    As for where you would implement it, i have implemented in the PlayGame sub just before second do loop and before "DisplayGameBoard(Board, BoardSize)"
    I was wondering what this actually shows on the game display as when i have tried to implement this nothing happens, i must have made a mistake somewhere within my code. I will PM you it if you wouldnt mind helping me out please. Also "x += 1" what does that mean?
    Offline

    10
    ReputationRep:
    Does anyone know which variables would be suitable for fixed value, most wanted holder, gatherer and follower?
    Offline

    0
    ReputationRep:
    (Original post by crazyy)
    Function CheckIfMoveIsValid(Board, Move,Boardsize, HumanPlayersTurn) As Boolean
    Variable Row As Integer
    Variable Column As Integer
    Variable MoveIsValid As Boolean
    Row=Move Mod 10 (same as % )
    Column = Move \ 10 (same as // )
    MoveIsValid = False
    If Board(The x coordinate you inputted,The y coordinate you inputted) = " " (empty space) then
    If HumanPlayersTurn=True then
    Board(The x coordinate you inputted, The y coordinate you inputted) = "H"
    Else
    Board(The x coordinate you inputted, The y coordinate you inputted) = "C"
    EndIf
    If (CheckIfThereArePiecesToFlip(Boa rd, 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
    Else
    MoveIsValid = False
    Board(The x coordinate you inputted, They coordinate you inputted) = "C" (we remove the piece)End If
    End If
    Returen MoveIsValid
    You can do this for diagonal as well,you need to add the other four CheckIfThereArePiecesToFlip combinations:'1 1', '-1-1', '1 -1' and '-1 1'.
    Omg, this is much more elegant than where I went and much easier to remember as well!! Bless your soul! :3 Good luck everyone!!
    Offline

    0
    ReputationRep:
    (Original post by crazyy)
    Does anyone know which variables would be suitable for fixed value, most wanted holder, gatherer and follower?
    fixed value: can't find one

    most wanted holder: Any variable that stores the user's input so "Coordinates" would be one

    gatherer: "Score"

    follower: can't find one

    and regarding the EAD. Question 3 (13) looks like an answer box for one of those "dry-run this dumb algorithm" type questions. I imagine one of those marks (in the box 14) is for correctly determining the purpose of the algorithm.
    Offline

    0
    ReputationRep:
    I've got a simple loop to make things easier when checking for diagonal flips. Just in case it helps anyone

    for (int x = -1; x < 2; x++)
    {
    ---- for (int y = -1; y < 2; y++)
    ---- {
    --------- FlipOpponentPiecesInOneDirection (Board, BoardSize, Row, Column, x, y);
    ---- }
    }
    Offline

    2
    ReputationRep:
    (Original post by aelahi23)
    The EAD indicates that Section D this year should be that hard because there are less marks available for the last 2 questions compared to last years paper.

    Last year the last Question was 16 marks now its 13 marks including the screen cap
    Should not* be right?
    Offline

    1
    ReputationRep:
    (Original post by DodaWilliams)
    I've got a simple loop to make things easier when checking for diagonal flips. Just in case it helps anyone

    for (int x = -1; x < 2; x++)
    {
    ---- for (int y = -1; y < 2; y++)
    ---- {
    --------- FlipOpponentPiecesInOneDirection (Board, BoardSize, Row, Column, x, y);
    ---- }
    }
    Can you do this as pseudo code please?
    Offline

    10
    ReputationRep:
    (Original post by ThisGuyThough)
    Omg, this is much more elegant than where I went and much easier to remember as well!! Bless your soul! :3 Good luck everyone!!
    Glad you found my solution useful thanks for helping me too gl in the exam
    Offline

    10
    ReputationRep:
    Do you guys think chapter 6 - System Life cycle will come up this year, I've never seen a question about it ever.
 
 
 
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.