zcoacoaz Posted October 8, 2006 Share Posted October 8, 2006 (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 October 8, 2006 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] Link to comment Share on other sites More sharing options...
jvanegmond Posted October 8, 2006 Share Posted October 8, 2006 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 github.com/jvanegmond Link to comment Share on other sites More sharing options...
Uten Posted October 8, 2006 Share Posted October 8, 2006 Nice:)I suppose you have googled for reversi "game tree" algorithm? Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
zcoacoaz Posted October 8, 2006 Author Share Posted October 8, 2006 (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 October 8, 2006 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] Link to comment Share on other sites More sharing options...
jvanegmond Posted October 8, 2006 Share Posted October 8, 2006 @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. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Uten Posted October 8, 2006 Share Posted October 8, 2006 Ok, In that case a quick read about game trees at wikipedia is probably a good investment of time Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
/dev/null Posted October 8, 2006 Share Posted October 8, 2006 (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...CheersKurt Edited October 8, 2006 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 * Link to comment Share on other sites More sharing options...
zcoacoaz Posted October 8, 2006 Author Share Posted October 8, 2006 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] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now