PureGM Gets its arse kicked! But it's getting better!

For everything that's not in any way related to PureBasic. General chat etc...
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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:
I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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?
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post 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.
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Source posted in the game programming section here
http://www.purebasic.fr/english/viewtopic.php?p=242775
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post 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 .
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post 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.
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
V2
User
User
Posts: 53
Joined: Wed Oct 15, 2003 4:53 pm

Bug?

Post 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?
V2
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

@Paul... you did implement a check routine? :shock:

Checking: NOPE!

Yay!!! I am a GM Grand Master now... UNDEFEATED!!!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Re: Bug?

Post 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.
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post 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
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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!!!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post 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.
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Post Reply