Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  AI for mancala game  (Read 6134 times)
0 Members and 1 Guest are viewing this topic.
Offline mahfuz

Junior Newbie





« Posted 2009-06-24 23:42:24 »

I am working with a mancala(kalah) game. I made the board and now want to move to the game logic.
Can anyone suggest how I should start with?

Another Question: I want to draw a hole full with ball. The number of balls can increase dynamically. How can I draw them(set Coordinate of ball), so that it seems realistic.

Thanks in advance
Mahfuz
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #1 - Posted 2009-06-25 00:51:23 »

Take a look at minmax decision trees.

It's very easy to implement and works great in solved games (Mancala, Tic Tac Toe, and Connect 4 are all examples of solved games). Because you have enough computational resources to predict every possible game outcome from any given point, you can therefore determine at any given point what the best move is.

Here is an example of a minmax tree for Tic Tac Toe.

The game starts, no pieces are placed. The current... hmm I was going to explain this in text then just decided to Google image search if someone has made one already. 'Lo and behold.



That tree obviously doesn't illustrate every possibility because it has a lot of "..." but you should get the idea. Notice at the end they mention a "utility." This is what you will be using to determine the proper move. As you traverse the tree and find every single possibility, you will eventually reach a bunch of leaf nodes (nodes that have no children) that all represent the end of the game (the board will be full or someone will have won). If the leaf node found is a win for the computer, then it has a value of +1. If it's a loss, then it has a value of -1. A draw has a value of 0. Once you've figured out all these values for every single leaf, you'll have your full tree created. Remember that the root node (the top) is the current game state. All of its direct children are each of your choices (see how in the image there is one for every space you can move into). You want to traverse down each of these choices to all the leaf nodes it contains, adding up the total utility as you traverse. Then the branch that has the highest utility becomes the correct choice.

Click to Play

The above better illustrates that. There are only 3 choices left in the game, so there are 3 children of the root node. Every time a leaf node is reached, its utility is calculated. The total utility for the left choice is (1 + -1 = 0), the total utility for the middle choice is (-1 + 0 = -1), and the total utility for the right choice is (1 + 0 = 1). So, you would choose the right choice, which will result in the computer either winning or having a draw.

Now you just need to take that same concept to Mancala. At the start of the game, the computer will have 6 pots full of marbles and therefore 6 choices. Then you just need to branch from there, same as in Tic Tac Toe.

As for your other question, you'll probably want to use a bit of randomness plus an angle measurement from the center, then use cosine and sine to get the X and Y.

See my work:
OTC Software
Offline mahfuz

Junior Newbie





« Reply #2 - Posted 2009-07-24 04:33:37 »

I need to find some properties which can make good evaluation functions. So, how can make good evaluation functions?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jono
« Reply #3 - Posted 2009-07-25 21:26:15 »

You could try starting with just the number of secure points. That could be the number of stones already  in your home bin (I don't know the proper Mancala terms), plus one for each bin on your side with enough stones to reach your home bin.

The position evaluation doesn't need to be perfect, it just has to help rule out really bad options.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (39 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (36 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!