Author |
Message |
fatboy316
|
Posted: Sat May 15, 2004 5:29 pm Post subject: Connect Four AI |
|
|
i don't no where to start for my connect four ai, i've been reading sites around and there seems to be an algorithm to weigh each move and give it a number, then the highest number will be the action taken. Rite now my program checks for win, if can't win then block, if can't block then connect3, if can't connect3 then block3, else it'lld o a random move. its easily beaten rite now, how can i make it better? i am programming this in turing btw
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
jonos
![](http://jonos.f2g.net/pictures/rankca.gif)
|
Posted: Sat May 15, 2004 5:46 pm Post subject: (No subject) |
|
|
Well, after you check for 3, try going to 2 and checking if it can block two. You will have to find a way to choose a random block 2 though because there will be a lot of them.
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sun May 16, 2004 1:14 pm Post subject: (No subject) |
|
|
weighting each move is a good approach to this kind of a game. There are not many moves (just as many as there are columns) so speed should not be an issue.
To make the AI more sophisticated, you can assign weight to strategical moves and half moves. I mean having like splits and what not where after a move two separate lines of 2~3 would be formed. Half move would be to create a situation where on the next move a strategic move will become available.
You might also consider moves to loose weight if they are easily blocked and would end up useless, or aid the opponent (such as allowing him to place a piece on top of yours to achieve w/e)
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
bugzpodder
![](http://www.vbforums.com/avatar.php?userid=31755&dateline=1038631511)
|
Posted: Wed May 19, 2004 7:58 am Post subject: (No subject) |
|
|
connect 4 have being solved... that means its a first-player win. use a recursive procedure to play every possible move and pick the winning move if you are first. if you are second,... good luck
|
|
|
|
|
![](images/spacer.gif) |
fatboy316
|
Posted: Wed May 26, 2004 10:24 pm Post subject: (No subject) |
|
|
well i've sorta worked on it a bit, and here are the results even tho its still a bit buggy.
the only thing i dislike about the weighing approach is that if the human player makes the same moves in two games, the computer will also play the same moves in two games. How can i add some randomness into the game?
btw left and right arrows are to move and space is to drop
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
Connect Four.rar |
Filesize: |
224.5 KB |
Downloaded: |
2600 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Wed May 26, 2004 10:55 pm Post subject: (No subject) |
|
|
it always starts in the center.. hmm and I can't win WHYYYY AHHHHH
|
|
|
|
|
![](images/spacer.gif) |
fatboy316
|
Posted: Thu May 27, 2004 10:12 am Post subject: (No subject) |
|
|
thats because the center column is weighed the most since it is able to "
connect the most 4 in a rows"
|
|
|
|
|
![](images/spacer.gif) |
fatboy316
|
Posted: Thu May 27, 2004 2:41 pm Post subject: (No subject) |
|
|
so, can anyone tell me how i can make this better?
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
bugzpodder
![](http://www.vbforums.com/avatar.php?userid=31755&dateline=1038631511)
|
Posted: Sat May 29, 2004 11:07 am Post subject: (No subject) |
|
|
i beat it on my first try, going second... it definately needs some improvement.
as i said its a first player win, so you might as well try to make that... keep your current strategy for second player.
|
|
|
|
|
![](images/spacer.gif) |
SuperGenius
|
Posted: Wed Jun 16, 2004 7:23 pm Post subject: (No subject) |
|
|
Nice job with the AI, however it gets predictable, which decreases gameplay value. The only way to win seems to be to not let it beat you for long enough until there are no spaces left.
|
|
|
|
|
![](images/spacer.gif) |
|