Page 2 of 2

Posted: Wed May 07, 2008 10:20 am
by srod
Srod, go buy a new PC
Aye, it is about time I upgraded. :) I like my old laptops though, even though they do creak and groan under the strain of it all!

Now, will you remove this damn game because it is stopping me getting any work done! :wink:

Posted: Thu May 08, 2008 4:41 am
by Rook Zimbabwe
I have roughly scanned the thread since I pundited.

I have an idea, based on that Trond said.

You should redesign your AI in a very simple way.

Defense. All defense! That and check for patterns and check for 3 in a row... and look for its own patterns and 3 in a row...

If it plays perfect defense it will win through attrition.

Maybe 1 version all defense just to see how well that does? What do you think?

:twisted:

How are you handling the circle placement? just drawin the corcles in a new location or using a sprite?

Posted: Thu May 08, 2008 5:38 am
by pdwyer
I'm not so sure.

Often in my tests when my AI loses I get the logs and replay the game to see what I was missing. Often it wasn't a bug on my part but that for 10+ moves in a row all were forced moves (open ended 3 or better) and then ended up in a position that I had to block a double three and so I lost but in order to evade, the change had to happen 10 moves earlier which is further than I can see currently.

So, take your idea, how do you you chose a move in case when there is no 3 to block? You don't need to read far into the future to see more three's than you can block! The board can then fill up and even cause a stalemate. BTW, this game has actually been cracked (but not in the time restrictions of the tournament) the first player actually has (apparently) an absolute path to victory!

My code needs some work still and I should be able to post it this week, some of it "evolved" so to speak from trying endless ideas (not unlike this one) and so there's still some fat in it that's slowing it down. A re-write of some of the more complex funtions would give me some good perf boosts and let me read further ahead. My heuristic has some bugs too that can lead it astray. when I post the code, I'll post the flow too so you can see what it's doing and what the reasoning is.

Posted: Thu May 08, 2008 10:37 am
by pdwyer
Source posted in the game programming section here
http://www.purebasic.fr/english/viewtopic.php?p=242775

Posted: Thu May 08, 2008 3:05 pm
by Rook Zimbabwe
So, take your idea, how do you you chose a move in case when there is no 3 to block?
Well I would be looking at 2 in a row then instead of 3 in a row and block the most recent 2 in a row if possible... :wink:

Posted: Thu May 08, 2008 4:03 pm
by Rook Zimbabwe
OK I played a purely defensive game, switching to offense only when it was safe.

I define safe as: Black only has 2 in row and 3 in row that can make a 5.

Rules:
(all moves depend only on last piece played... then other moves)
1. If 4 white can make 5 WIN
2. If 4 BLACK can make 5... CAP IT
3. If 2 sp 1 has 2 open ends black CAP SPACE
4. If 2 sp 1 has 2 open ends WHITE pick space (this is how I won the pictured game in this post!)
5. if black most recent makes 3 CAP IT (this is what made the game so long!)
6. If you have 3 that can make 5 make it into 4
7. If Black move makes 2 in row that can make 5 CAP IT
8. If you have 2 that can make 5 make it 3

Image
I started at 1,1 because that limited the computers responses!

The problem with the AI (the problem with almost every AI is,) it has NO PLAN. It needs a plan. Not just a plan to respond to what it assumes will always be an attack. 8)

By move 20 or so the computer was taking 3 minutes per turn trying to figure out where I was going to attack. I didn't really attack unless it was safe. This made AI unhappy.

I do have a suggestion... add a #ListIcon_movebox to the side to record the moves. :D

SO a plan would be: What are the sneaky setups of pieces in this game and build them when it is safe!

Posted: Fri May 09, 2008 1:07 am
by pdwyer
hmmmm

Interesting, Try it away from the edge, you should be able to turn it down to medium for the test, see if you can win three in a row.

Question: When faced with multiple open 2's to handle, how do you you choose between them? (ie, you would you put it in code to choose?)

In the gaming programming section thread for this topic , I'll post the code for using the tornament software, then you can try making changes and put them up against other version not just mine, remember, I'm one of the weaker (est) competitors! :P .

Posted: Fri May 09, 2008 3:05 am
by Rook Zimbabwe
multiple 2's... I picked the closest to last move of black. I did have to fudge on that at times. After the first 8 - 10 moves it didn't matter as I was into middle game...

Hmmm...

Maybe you could think up a 3 tier attack strategy... first few moves... agressive attack, then my absolute defense for a while... looking for the opportunity to make the sneaky setup... then BLAMMO the endgame! :D

Posted: Fri May 09, 2008 3:27 am
by pdwyer
:lol: sounds pretty exciting

I'm thinking of redoing my strategy engine (which is needed for the heuristic in minimax too) to use a template idea. Have a dictionary of templates to overlay on each piece in each direction (open 3, 4 with a gap, etc etc, there'd be lots) and keep it seperate from the main compiled code. Then as I tested and saw the reasons I lost, I could add another template on how to handle it.

Something in line with how a human plays and looks for shapes they know.

From getting so consistantly smashed from opponants though, I can't help but think that some level of look ahead is needed. The tournament (somehow) recorded the app Onix found path-to-victory in one match 46 moves ahead! :shock: It makes me think that the minimx depth needs to be dynamic and let it run if it's on a quick path to whatever depth time permits (varies greatly on the board and search order).

I think your idea is good though, and that a strategy engine should have these kinds to options too as they can be checked very quickly to see if you are in a situation where it would pay off. Think of an Alpha beta search with the heuristic based on your idea of blocking 2's and 3's "snip it in the bud" approach I guess. it could work very well, but I think it needs the look ahead too.

Bug?

Posted: Fri May 09, 2008 3:32 pm
by V2
Hi,

I think your program has a bug - I place a white stone, then there comes a black one - I click on the black one - the black one turns white, and so on - I always win this way with only clicking 5 times, even in very hard...

I guess this isn't the way it should work, is it?

Posted: Fri May 09, 2008 3:37 pm
by Rook Zimbabwe
@Paul... you did implement a check routine? :shock:

Checking: NOPE!

Yay!!! I am a GM Grand Master now... UNDEFEATED!!!

Re: Bug?

Posted: Sat May 10, 2008 1:39 am
by pdwyer
V2 wrote:Hi,

I think your program has a bug - I place a white stone, then there comes a black one - I click on the black one - the black one turns white, and so on - I always win this way with only clicking 5 times, even in very hard...

I guess this isn't the way it should work, is it?
Derek brought this up already, see above. the fix is in the posted code in the game programming section.

Posted: Tue Dec 30, 2008 3:39 am
by pdwyer
FYI, (Of interest to very few I'm sure but...)

I got an email from the organisers and the Gomoku cup computer tournament is on again in 2009, the date has been set for April 4th (last entries due by April 2nd) if anyone wants to enter the page is linked on the first post in this thread, tornament software is on the site. If you need sample PB code for the comms protocol it's simple console I/O and I can provide samples of commands and responses.

PureGM will hopefully have a version 2 competing and perhaps this time won't come last :oops: There are some very strong contenders.

Still, I won a few games, so I want to win a few more, PB4.30 fixes a thread + random() bug so I will have more computing power at my disposal this time, maybe I can do a deeper search. I need to rethink my game algorithm anyway.

Fun to be had either way :D

Posted: Tue Dec 30, 2008 7:46 am
by Rook Zimbabwe
Right here to pundit on Strategy buddy! You can have everything the US Army gave me... :D Or we can find someth8ing that would actually work! ;)

GO PAUL... GO GM!!!

Posted: Tue Dec 30, 2008 8:01 am
by pdwyer
:lol: Thanks,

I'll try to keep the engine separate from the GUI/Protocol so I can put it in the human playable front end and post it to see if you can beat it. I might add a "Dump game to text" option so you can send me back ways that you beat it for me to look at.