Archived

This topic is now archived and is closed to further replies.

problem with a basic go game

This topic is 5402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For those who does not know what go is, please check out http://playgo.to/interactive/ I am working on creating a simple go game for two human players. I am wondering what the easiest way would be to check if the stone you place will kill any of the opponents stones or get any of your own stone killed. Suggestions?

Share this post


Link to post
Share on other sites
Cool link, from what I’ve heard the AI in Go is a lot more complicated than Chess, because there are less constraining rules and more possible moves to make each turn. (Although you could say that about Go in general).

I think a sequence of connected stones (counters) is called a Dragon, a Dragon is considered alive if at least one of the stones that make up the Dragon is adjacent to an empty space.
A simple way you could do it is:

1. Find the connecting stones that make up the Dragon for the newly placed stone.

2. For each stone that makes up the Dragon check if they are next to an empty space.

3. If none of the stones that make up the Dragon are adjacent to an empty space, then the player has committed suicide.

Repeat if the new stone was placed next to an enemy’s stone to check if the player has killed their opponents Dragon.

Lot’s of Luck, although I don’t play it very much these days Go really is a neat game.

Share this post


Link to post
Share on other sites
Sounds like a good idea. But now, how should i keep track of what stones have been checked and not? If the first stone is connected to three other stones and those three stones are connected to tree other stones, and so on, i get alot of different paths to try, especialy on a big board. The amount of combinations of paths to travel to check seems pretty large.

Share this post


Link to post
Share on other sites
Oh, this is fun, Im working on a go-game myself.. (with AI)

Im using delphi though, and my knowledge with C/C++ is very limited. Anyways, the theory should be the same, so I think I can point you in the right direction at least. I use a recursive function to check for killed stones. I call this funcion IsTrapped and it returns a boolean. I also make use of a list where I add stones which have already been checked.

When IsTrapped(x,y) is called, it will check some conditions for the stone at X,Y. (after I've added it to the AlreadyChecked-list).
IsTrapped Conditions:
* If ANY adjacent space is empty then return FALSE.
* else If ALL the stones surrounding is (Enemy Stone) OR (Friendly AND IsTrapped) OR (Friendly AND within AlreadyChecked-list) then return TRUE.

This might be a bit confusing if you haven't used recursiv functions before. It takes some training to think recursive. It's really nice when its done though, and you'll be suprised at the very small ammount code which is used. ^_^

The greatest thing is when the IsTrapped you called first returns True, then the AlreadyChecked-list contains ALL the trapped stones. Which makes it possible to pass on the list to another function which removes all the trapped stones from the board.

I could try posting some of my code if you think this made no sense. It's quite simple really.
Heheh, just you wait 'til you have to calculate the score... that is true hell. :-)

Good luck!

[edited by - gunnm on March 3, 2003 5:20:18 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by endasil
I am working on creating a simple go game for two human players. I am wondering what the easiest way would be to check if the stone you place will kill any of the opponents stones or get any of your own stone killed. Suggestions?



This program (it''s for Unix) uses (at least used, when I read its source code) the following approach. Each stone is an element of 2D array (board) and also has links to next/previous stone in a group. The head of each such list maintains the number of liberties for a group. When stone is added, it simply reduces the liberty count of all opponent groups it touches, and if it touchs groups of stones of the same color, it links those groups in a single list (with the liberty count as a sum of liberties of all groups). The only problem is removing a stone, which requires removing all stones in a group, and then adding remaining stones back to the board.

Share this post


Link to post
Share on other sites
Gunnm, i have sent a request to add you to my icq list. It will probaly be easiest if i can talk to someone who is making a go game too.


Advanced Bug, i am using windows xp so i can''t compile that program and test it.

Even if your explanation gives me a bit more understanding on how the stone checking is done, it is sadly not enough for me to actualy implement it.

But i am very thankful that you are trying to help me.

Share this post


Link to post
Share on other sites
Advanced Bug have a point though. that approach will almost certain be faster than recursive operations. Noticeable faster when capturing large ammount of stones.

Didn't get your icq-request, Endasil, not yet anyways. :-)

[edited by - gunnm on March 3, 2003 9:02:05 AM]

Share this post


Link to post
Share on other sites