The Student Room Group

Aqa comp1 2016

Scroll to see replies

Could someone send me a link of the whole python code ?
Original post by uGo1001
Has anyone actually made a solution for this?


Yeah, all you have to do is alter the CheckIfMoveIsValid module.
The code below is for Python 3+ but it should be pretty understandabledef CheckIfMoveIsValid(Board, Move, P1, P2, HumanPlayersTurn):
Row = Move % 10
Column = Move // 10
MoveIsValid = False
if Board[Row][Column] == " ":
if HumanPlayersTurn:
Board[Row][Column] = P1
else:
Board[Row][Column] = P2
Valid1 = CheckIfThereArePiecesToFlip(Board, BoardSize, Row, Column, 1, 0)
Valid2 = CheckIfThereArePiecesToFlip(Board, BoardSize, Row, Column, -1, 0)
Valid3 = CheckIfThereArePiecesToFlip(Board, BoardSize, Row, Column, 0, 1)
Valid4 = CheckIfThereArePiecesToFlip(Board, BoardSize, Row, Column, 0, -1)
if Valid1 == True or Valid2 == True or Valid3 == True or Valid4 == True:
MoveIsValid = True
else:
Board[Row][Column] = " "
return MoveIsValid






I have all solutions if anyone needs a last minute hand, only thing would be helpful is if anyone has the solution for quit/skip a turn (in VB.NET), or anyone thought about diffcult part A/B/C topics? Sound sampling is difficult but was last year I think, the variable types are pretty hard in part C also.
Has anyone done any of the problems in java? Especially fixing the invalid coordinates loop?
Original post by KnightCode
why are confusing this??

if (Board[Row, Column] == ' ' && ( CheckIfThereArePiecesToFlip(Board, BoardSize, Row, Column, 1, 0) == true || CheckIfThereArePiecesToFlip(Board, BoardSize, Row, Column, 0, 1) == true || CheckIfThereArePiecesToFlip(Board, BoardSize, Row, Column, -1, 0) == true || CheckIfThereArePiecesToFlip(Board, BoardSize, Row, Column, 0, -1) == true))

thats all u need


Except that doesn't actually let me make a move. When I tried that there was no place on the board which the game let me place a piece on. For some reason you have to put the piece in it's place before checking if all of the "CheckIfThereArePiecesToFlip" are true or else it doesn't work.
Reply 206
How's everyone feeling for the exam tomorrow

I'm a bit nervous but at the same time I feel confident that I'll be fine
Original post by ollycostello
I have all solutions if anyone needs a last minute hand, only thing would be helpful is if anyone has the solution for quit/skip a turn (in VB.NET), or anyone thought about diffcult part A/B/C topics? Sound sampling is difficult but was last year I think, the variable types are pretty hard in part C also.


Are all your solutions in vb.net. If so could you send them to me
Thanks
Some more problems they may ask:

- Only allowing the player to pick even board dimensions.
- If the human, or computer can not place a piece down at the very end of the game, during the adjacent move implementation, empty spaces are left. If you would calculate the score in percentages, it would not calculate the empty space and minus it from BoardSize, hence an invalid percentage would be given. This could be a second part to the adjacent move question.
Okay, here's a harder question that I think may come up but I don't have any idea how to implement. In the actual Reverse game, the player is forced to skip a turn if no legal moves are possible and cannot skip a turn at any other point. Anyone got any ideas for this? I'm not sure how to check if no valid moves are possible.
When playing using the adjacency check, can you actually finish a game without filling out the board? I can't actually finish the game unless the board is filled with pieces
Oh, and note guys, the CheckIfThereArePiecesToFlip doesn't actually check if a flip is possible, it checks if there are adjacent pieces of the opponent next to the position you've specified.
Original post by DodaWilliams
Okay, here's a harder question that I think may come up but I don't have any idea how to implement. In the actual Reverse game, the player is forced to skip a turn if no legal moves are possible and cannot skip a turn at any other point. Anyone got any ideas for this? I'm not sure how to check if no valid moves are possible.


This has been done, check previous pages in the thread.
Original post by uGo1001
Except that doesn't actually let me make a move. When I tried that there was no place on the board which the game let me place a piece on. For some reason you have to put the piece in it's place before checking if all of the "CheckIfThereArePiecesToFlip" are true or else it doesn't work.


yeah, i tried it ur way and it worked. I think it makes sense, since it needs to know whos turn it is and who it is flipping.
thanks for the help though and GL!
Original post by DodaWilliams
Oh, and note guys, the CheckIfThereArePiecesToFlip doesn't actually check if a flip is possible, it checks if there are adjacent pieces of the opponent next to the position you've specified.


Yes it does, it draws a line between the piece you have placed and the next piece you have.
Anyone know how to implement in Python an automatic skip if there are no more possible turns for the human or computer? Thanks
Can anyone actually finish a game using the adjacency check and have blank pieces left over? If a flip isn't possible, the code just stops instead of ending the game
Original post by TercioOfParma
Yes it does, it draws a line between the piece you have placed and the next piece you have.


Yeah, it was bug in my code, my bad :biggrin:
Original post by StarStruck_98
Anyone know how to implement in Python an automatic skip if there are no more possible turns for the human or computer? Thanks


I have implemented skipping a turn manually by the player. The automatic skip for the computer works for me, but in my opinion, implementing automatic skipping for a player is a bit pointless.

If you were playing the real game, the board would not tell you: "Hey, you get no moves, I'm skipping for you". I made it so that the player can have a go, and get the option to skip if they wish too! :smile:

Quick Reply

Latest

Trending

Trending