Sign in to follow this  
Followers 0
zcoacoaz

Help creating reversi

8 posts in this topic

#1 ·  Posted (edited)

So yesterday I started work on reversi and I have come to a problem that I really need help with. It seems that most games you get stuck with no moves near the end. I need to find an efficient way to check if any moves are left so that when you run out of moves the game ends.

My current source is attached (sorry for the lack of comments).

Reversi.au3

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites



I haven't read your script, as I can't get my head around it right now. But at some point in your script, you have to send a click or input to the game. At that point say $Change = True. If you put $Change = False at the top of your checking loop. $Change will only be True if a move has been performed. So at the end of your loop you could simply say

If Not $Change Then
    ExitGame()
EndIf

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Nice:)

I suppose you have googled for ?

No I haven't, but it looks like that will help me a ton.

@Manadar:

That wont work since the player might click on a spot that isn't a valid movement choice some other time in the game.

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

@Manadar:

That wont work since the player might click on a spot that isn't a valid movement choice some other time in the game.

Sorry, I misinterpreted your question. I thought you were trying to create a script that would play reversi for you.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I need to find an efficient way to check if any moves are left so that when you run out of moves the game ends.

If you want to check, if there is a valid move for RED, check this for each remaining field

(not set by red or blue):

check in the three directions (horizontal, vertical and diagonal):

* If the direct neighbour is unset skip that direction for the field (this will eliminate a lot of fields very fast - at least at the beginning of the game). You can speed this even up, if you set every element of the matrix to 0 at the start. Then, when a field is set to BLUE you set all "empty" neighbours of that field to the value 1 and if a field is set to RED, you set all "empty" neighbours to the value of 2.

* Until the neighbour equals BLUE, check the next field. If the next field is RED, then a move is possible. If the next field is unset, then discard that direction for the field. If you reach the end of the matrix, discard that direction.

There is probably more to check and I guess there are better algorithms, but at least it's a point to start from...

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Well now the game works perfect (I think, I have done tons of testing) in 2 player mode on a single computer. The solution I came up with was when the game went through and counted how many stones each player has it also checks if there are any moves possible for that tile using a modified version of my Move(x,y,player) function. When I implement the computer I will try and use the game trees thing that Uten suggested but it is very hard to comprehend (for me anyways). Hopefully the game will be all the way complete by the end of this week or at the latest next week.


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0