473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Game design : Making computer play

In computer based, two player, board games, how to make computer play?
Are there any formal ways to _teach_ computer, to choose best possible
move?

I know this is kind of off-topic here. Please redirect me, if there
are more appropriate newsgroup.

Many thanks.
Jun 27 '08 #1
14 2306
On Mon, 14 Apr 2008 00:13:56 -0700, v4vijayakumar wrote:
In computer based, two player, board games, how to make computer play?
Are there any formal ways to _teach_ computer, to choose best possible
move?
That depends on the type of the game. For a certain class of games one
can use the `minimax method`_ for instance.

... _minimax method: http://en.wikipedia.org/wiki/Minimax

Ciao,
Marc 'BlackJack' Rintsch
Jun 27 '08 #2
v4vijayakumar said:
In computer based, two player, board games, how to make computer play?
Write some code that works out what the computer player should do. If you
want a better answer, ask a better question.
Are there any formal ways to _teach_ computer, to choose best possible
move?
That's a better question. The obvious ways are DFS, BFS, and databases.

For example, take backgammon, and computer goes first. You roll the PRNGs
and get 6, 1. You (the computer) have never played this game before, so
you don't have a database of good moves. Your legal moves are:

24,18 and 24,23
24,18 and 8,7
24,18 and 6,5
13,7 and 24,23
13,7 and 8,7
13,7 and 6,5

Of these, which is the best? DFS (Depth-First Search) and BFS
(Breadth-First Search) can help you answer that question. What you do is
define an evaluation function for the position, based on things like how
many blots, how many on the bar, whether you have a prime, and so on. Then
you *play the game* in simulation, as deeply as you can (which won't be
very deep, actually), evaluating all the time. Once you've found the
position that does you most good (or least harm) no matter what die-rolls
the opponent may get and no matter how skilfully he or she plays, you know
what to get your computer player to do next.

If you're clever, you'll keep the solution tree around, destroying only the
bits of it that won't ever be used again - to save processing time on your
next turn.

If you're really clever, you'll write a lot of this information down in a
file, a sort of opening "book", so that you don't have to calculate
everything from scratch every time. For example, in the above situation,
there is no need to calculate, because it's a no-brainer: 13,7 and 8,7 is
far and away the best move.
I know this is kind of off-topic here. Please redirect me, if there
are more appropriate newsgroup.
comp.programming is probably where you want to be, at least to start off
with.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #3
On Apr 14, 12:13*pm, v4vijayakumar <vijayakumar.subbu...@gmail.com>
wrote:
In computer based, two player, board games, how to make computer play?
Are there any formal ways to _teach_ computer, to choose best possible
move?

I know this is kind of off-topic here. Please redirect me, if there
are more appropriate newsgroup.

Many thanks.
You should pick up some nice Artificial intelligence book and see for
the game playing section. Most of them have it. Teaching the computer
is almost like telling it all the possibilities. The actual teaching
is telling the computer how to decide which possibility is the best.
That is by using heuristics. All possibilities are normally
represented as trees, one move leading to another. Then there is are
pruning techniques, miny-maxy things where we deal with the concept of
minimizing opponents gain and maximizing your own. So you design
heuristics like that. (For example in the game of tic tac toe, there
can be say 5 moves to be made, and the heuristic function is the
number of moves a given player will win in.... and the computer
calculates that its 4 for him and 3 for you for a certain move.... he
will pick the next move with is maybe 3 for him and 4 for you and
execute that move). This is a very simplistic application but this is
how it goes. There are many searching heuristic based algorithms, some
blind search algorithms etc. They are very important in game playing
not just board ones but almost all of them. They are the foundation.
So I would recommend you to open some elementary AI book.
Jun 27 '08 #4
On Apr 14, 12:35 pm, Richard Heathfield <r...@see.sig.invalidwrote:
v4vijayakumar said:
In computer based, two player, board games, how to make computer play?

Write some code that works out what the computer player should do. If you
want a better answer, ask a better question.
I am just implementing a game played in my village (Tamilnadu /
India), called "aadupuli" (goats and tigers). There are only 23
positions and 18 characters (15 goats and 3 tigers). Some of you might
be aware of this.

I can post initial version of the game (implemented using html/
javascript) in couple of hours here.

Welcome any help in making computer to play one of these player.
Jun 27 '08 #5
[comp.programming added, and followups set to that group]

v4vijayakumar said:
On Apr 14, 12:35 pm, Richard Heathfield <r...@see.sig.invalidwrote:
>v4vijayakumar said:
In computer based, two player, board games, how to make computer play?

Write some code that works out what the computer player should do. If
you want a better answer, ask a better question.

I am just implementing a game played in my village (Tamilnadu /
India), called "aadupuli" (goats and tigers). There are only 23
positions and 18 characters (15 goats and 3 tigers). Some of you might
be aware of this.

I can post initial version of the game (implemented using html/
javascript) in couple of hours here.

Welcome any help in making computer to play one of these player.
comp.programming would be a better group.

I've found a picture of the board, but I can't find the rules anywhere,
without which the task is impossible. Can you tell us what they are?

If you reply, I suggest you do so in comp.programming.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #6
v4vijayakumar wrote:
) On Apr 14, 12:35 pm, Richard Heathfield <r...@see.sig.invalidwrote:
)v4vijayakumar said:
) In computer based, two player, board games, how to make computer play?
)>
)Write some code that works out what the computer player should do. If you
)want a better answer, ask a better question.
)
) I am just implementing a game played in my village (Tamilnadu /
) India), called "aadupuli" (goats and tigers). There are only 23
) positions and 18 characters (15 goats and 3 tigers). Some of you might
) be aware of this.

Odd, I thought there were 25 positions, 20 goats and 4 tigers.
*googles* Oh wait, that is Bagh Chal. Roughly the same rules,
different board layout and number of tigers.

) I can post initial version of the game (implemented using html/
) javascript) in couple of hours here.
)
) Welcome any help in making computer to play one of these player.

If the board is that small then an exhaustive search might work,
but then the computer would be unbeatable.

Minmax would be best I guess.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Jun 27 '08 #7
On Apr 14, 1:00 pm, v4vijayakumar <vijayakumar.subbu...@gmail.com>
wrote:
....
I can post initial version of the game (implemented using html/
javascript) in couple of hours here.
The game is here,

http://v4vijayakumar.googlepages.com...nd-tigers.html
Jun 27 '08 #8
On 14 Apr, 09:13, v4vijayakumar <vijayakumar.subbu...@gmail.com>
wrote:
In computer based, two player, board games, how to make computer play?
Are there any formal ways to _teach_ computer, to choose best possible
move?

I know this is kind of off-topic here. Please redirect me, if there
are more appropriate newsgroup.

Many thanks.
can you post a link to the game so I can see the rules and how the
board looks.
/hopefully going to india soon
Jun 27 '08 #9
sk*******@yahoo.se said:
On 14 Apr, 09:13, v4vijayakumar <vijayakumar.subbu...@gmail.com>
wrote:
>In computer based, two player, board games, how to make computer play?
Are there any formal ways to _teach_ computer, to choose best possible
move?

I know this is kind of off-topic here. Please redirect me, if there
are more appropriate newsgroup.

can you post a link to the game so I can see the rules and how the
board looks.
Here's the board (which bears only a slight resemblance to one I'd seen on
the Web):

+---------------+
| HORN $ |
+---+---+---+---+---+---+
|L W| | $ | $ | |R W|
+E-I+--CHEST+---+---+I-I+
|F N| | | | |G N|
+T-G+---+---+---+---+H-G+
| | | | | |T |
+---+---+---+---+---+---+
| LEGS| | |
+---+---+---+---+

There are three tigers and fifteen goats.
The tigers' goal is to eat all the goats and remain mobile.
It seems that the initial tiger positions are: one on the horn, and one
each on CHEST-2 and CHEST-3 (see $ marks, above).
The goats' goal is to block the tigers from moving.
The goats are placed one by one.
Tigers appear only to be able to move orthogonally (up/down/left/right) -
although they can use the horn to whizz across the chest (e.g. CHEST-1 to
HORN, HORN to CHEST-4, in two moves).
The rest of the rules are beyond me, I'm afraid. It's not clear how tigers
eat goats or how goats block tigers.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #10
Richard wrote:
) Here's the board (which bears only a slight resemblance to one I'd seen on
) the Web):
)
) +---------------+
) | HORN $ |
) +---+---+---+---+---+---+
) |L W| | $ | $ | |R W|
) +E-I+--CHEST+---+---+I-I+
) |F N| | | | |G N|
) +T-G+---+---+---+---+H-G+
) | | | | | |T |
) +---+---+---+---+---+---+
) | LEGS| | |
) +---+---+---+---+
)
) There are three tigers and fifteen goats.
) The tigers' goal is to eat all the goats and remain mobile.
) It seems that the initial tiger positions are: one on the horn, and one
) each on CHEST-2 and CHEST-3 (see $ marks, above).
) The goats' goal is to block the tigers from moving.
) The goats are placed one by one.
) Tigers appear only to be able to move orthogonally (up/down/left/right) -
) although they can use the horn to whizz across the chest (e.g. CHEST-1 to
) HORN, HORN to CHEST-4, in two moves).
) The rest of the rules are beyond me, I'm afraid. It's not clear how tigers
) eat goats or how goats block tigers.

If it's similar to the 'other' goats and tigers game, a tiger eats a goat
by jumping over it, for which the square behind it needs to be empty,
obviously.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Jun 27 '08 #11
On Mon, 14 Apr 2008 12:13:20 +0000 (UTC), Willem <wi****@stack.nl>
wrote:
>Richard wrote:
) Here's the board (which bears only a slight resemblance to one I'd seen on
) the Web):
)
) +---------------+
) | HORN $ |
) +---+---+---+---+---+---+
) |L W| | $ | $ | |R W|
) +E-I+--CHEST+---+---+I-I+
) |F N| | | | |G N|
) +T-G+---+---+---+---+H-G+
) | | | | | |T |
) +---+---+---+---+---+---+
) | LEGS| | |
) +---+---+---+---+
)
) There are three tigers and fifteen goats.
) The tigers' goal is to eat all the goats and remain mobile.
) It seems that the initial tiger positions are: one on the horn, and one
) each on CHEST-2 and CHEST-3 (see $ marks, above).
) The goats' goal is to block the tigers from moving.
) The goats are placed one by one.
) Tigers appear only to be able to move orthogonally (up/down/left/right) -
) although they can use the horn to whizz across the chest (e.g. CHEST-1 to
) HORN, HORN to CHEST-4, in two moves).
) The rest of the rules are beyond me, I'm afraid. It's not clear how tigers
) eat goats or how goats block tigers.

If it's similar to the 'other' goats and tigers game, a tiger eats a goat
by jumping over it, for which the square behind it needs to be empty,
obviously.

v4 gave us a link to a page that not only lists the rules, but lets
you try them out:

http://v4vijayakumar.googlepages.com...nd-tigers.html

Seems like a fun quickie game to play with some coins on a piece of
paper. I like the asymmetrical goals and the quick setup.
Jun 27 '08 #12
On Mon, 14 Apr 2008 00:13:56 -0700 (PDT), v4vijayakumar
<vi******************@gmail.comwrote:
>In computer based, two player, board games, how to make computer play?
Are there any formal ways to _teach_ computer, to choose best possible
move?

I know this is kind of off-topic here. Please redirect me, if there
are more appropriate newsgroup.

Many thanks.
Sargon: A Computer Chess Program (Paperback)
by Dan Spracklen (Author), Kathe Spracklen (Author)
Search Amazon with that title. Its available for under $20.

The Spracklen's book provides a concrete structure and model for a
computer program which attempts to look ahead, evaluating alternative
moves. Unlike AI texts which obfuscate through abstraction, theirs is
quite clear even if you don't know Z80 assembly language. By reading
their book (studying it might be a better phrase) I came to understand
the complexity and immensity of the task.

Good luck.

John
Jun 27 '08 #13

"Marc 'BlackJack' Rintsch" <bj****@gmx.netwrote in message
news:66*************@mid.uni-berlin.de...
On Mon, 14 Apr 2008 00:13:56 -0700, v4vijayakumar wrote:
>In computer based, two player, board games, how to make computer play?
Are there any formal ways to _teach_ computer, to choose best possible
move?

That depends on the type of the game. For a certain class of games one
can use the `minimax method`_ for instance.

.. _minimax method: http://en.wikipedia.org/wiki/Minimax
While checking the Wikipedia, also check out the A* (a-star) graph search
algorithms:

http://en.wikipedia.org/wiki/A%2A

There is a table on the top-right of this page that includes other graph
search algorithms.

My AI games are usually built around general purpose mini-max code, possibly
inplementing A* (I reuse the same code for various games). For each new
two-player game, I usually only have to write new "position evaluator" code,
which generates a quantitative value that gives the relative position of one
player over the other for a particular board. Some games can benefit from a
database of opening moves that have been shown to be be superior (this
speeds up the computer's response).

Carl G.
Jun 27 '08 #14
v4vijayakumar wrote:
On Apr 14, 1:00 pm, v4vijayakumar <vijayakumar.subbu...@gmail.com>
wrote:
....
>I can post initial version of the game (implemented using html/
javascript) in couple of hours here.

The game is here,

http://v4vijayakumar.googlepages.com...nd-tigers.html
The list of valid moves is incomprehensible to humans without
actually drawing all the possible moves. Without an exhaustive
check for validity, I think the following is an accurate summary:

* Treat the board as a 5x6 grid with the corners removed and
the top 4 cells merged.

* Any piece can move one space up, down, left, or right.

* A tiger can eat a goat by jumping over it, thereby moving
two spaces up, down, left, or right.
Jun 27 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: BlackHawke | last post by:
My name is Nick Soutter, I own a small game development company (www.aepoxgames.net) making our first game (www.andromedaonline.net) in java. I am writing because we are having a very...
3
by: Sam | last post by:
Hey all, I want to create a computerised version of this game, though I'm not really sure how to go about it. For those who don't know how the game works, here's my attempt at a brief...
138
by: theodp | last post by:
--> From http://www.techdirt.com/articles/20040406/1349225.shtml Microsoft Patents Saving The Name Of A Game Contributed by Mike on Tuesday, April 6th, 2004 @ 01:49PM from the...
11
by: enki | last post by:
I am writing a game and I am having trouble with moving the character on the map. Here is what I have right now. It involves win32 programming but that not my problem. I would like some...
6
by: ume$h | last post by:
Four Win Description To program the play named "four win", the background board should consist of a lattice with 7 columns, into which in each case 6 stones fit. The playing field stands...
1
by: =?Utf-8?B?c2hhcmVu?= | last post by:
im having a problem with my computer im trying to play sims2 seasons and every time i try to start the game it gives me an error msg 0x0000005 ive been unable to play this game for 6 months and its...
1
by: Gomi | last post by:
Hi guys I'm new to C++ Programming and I am having trouble in making my Guessing game code replay. I am suppose to give the user that is playing my game the opportunity to play again with options of...
1
by: Leiram | last post by:
I am trying to write a game where there is 13 stones and you play against the computer to make sure that you don't take the last stone. You or the computer (depending on the turn) is allowed to take...
2
by: LilMeechc20 | last post by:
Hello, I have a group assignment that I have to do. We have to write a Tic Tac Toe game. One person in my group has managed to write the code for a multiplayer (human -vs- human) game and I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.