x Turn on thread page Beta
 You are Here: Home

# Aqa comp1 2016 watch

1. 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
2. (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?
3. 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'.
4. (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
5. (Original post by frosts16)
It's attached
Attached Files
7. (Original post by frosts16)
Attached Files
9. Thanks!
10. (Original post by aelahi23)
Thanks man I never knew we can get EAD before the exam
11. 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
12. (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.
13. (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?
14. (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?
15. Does anyone know which variables would be suitable for fixed value, most wanted holder, gatherer and follower?
16. (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!!
17. (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.
18. 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);
---- }
}
19. (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?
20. (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?
21. (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
22. Do you guys think chapter 6 - System Life cycle will come up this year, I've never seen a question about it ever.

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: August 19, 2016
Today on TSR

### I've studied the wrong subject

...Should I go back to school?

### Should I complain about my supervisor?

Poll
Useful resources

Can you help? Study Help unanswered threadsStudy Help rules and posting guidelines

## Groups associated with this forum:

View associated groups

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