 |
 |
Connect 4 Board Evaluation Function
|
 |
|
 |
|
Mac Elite
Join Date: Jun 2000
Location: NY
Status:
Offline
|
|
Im programing an artificial player for connect 4, and need a good board evaluation function to start off with. For those that dont know what this is, its a function which takes in the current board, and the position of the next move and then returns and integer for that move. The higher the integer the better the position is. Thanks!
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status:
Offline
|
|
So, are you looking for someone to code this function for you or are you looking for ideas?
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Nov 2001
Location: Seattle
Status:
Offline
|
|
One possible function would be to go through every possible way of getting four in a row in the game, and giving a score based on how close each player is to completing that particular 4-in-a-row. For example, if the current player is 'x' and the opponent is 'o', you could do something like:
4 x's = 1000 points
3 x's, 1 blank = 100 points
2 x's, 2 blank = 10 points
1 x, 3 blanks = 1 point
all blank, or if there is at least one x and one o = 0 points
1 o, 3 blanks = -1 point
2 o's, 2 blanks = -10 points
3 o's, 1 blank = -100 points
4 o's = -1000 points
Then add up the score for each of the possible ways of getting 4-in-a-row to get the total score for the board.
This is somewhat primitive, but it should work. Of course you'll have to play around with the point values to get this to work well; I just picked numbers off the top of my head. I haven't played connect-4 for a long time, so I don't know any strategy. If you have any general heuristic strategies when you play, it might be worth incorporating them into the board evaluation function. Perhaps it's easier to get 4-in-a-row horizontally or diagonally than it is vertically, or better to play in the center rather than the sides. Rules like this can be implemented in the above scoring function by weighing the scores of various 4-in-a-row sets appropriately.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jun 2000
Location: NY
Status:
Offline
|
|
thanks much juggle, as to the other two posters no i was not looking for someone to hand me the code but a very helpful post like juggles, something you two are obviously not cabable of. If anyone else has other ideas it would be greatly appreciated.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Status:
Offline
|
|
I did a assignment just like that for ~ 2 month ago, we used the eval function described by Juggle5. You can always let to AI player play eachother with diffrent weights in the eval function and see if one of them is winning more then tho otherone.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status:
Offline
|
|
Originally posted by Jsnuff1:
thanks much juggle, as to the other two posters no i was not looking for someone to hand me the code but a very helpful post like juggles, something you two are obviously not cabable of. If anyone else has other ideas it would be greatly appreciated.
Jsnuff1,
I asked what you are looking for, code or ideas. It was a simple question. I am capable of many things, but a mind reader I am not. Calling me incapable certainly doesn't encourage me to help you out though, that's for sure.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|