Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Connect Four AI
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
fatboy316




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
jonos




PostPosted: 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.
Tony




PostPosted: 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)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bugzpodder




PostPosted: 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
fatboy316




PostPosted: 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



Connect Four.rar
 Description:

Download
 Filename:  Connect Four.rar
 Filesize:  224.5 KB
 Downloaded:  2588 Time(s)

Amailer




PostPosted: 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
fatboy316




PostPosted: 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"
fatboy316




PostPosted: Thu May 27, 2004 2:41 pm   Post subject: (No subject)

so, can anyone tell me how i can make this better?
Sponsor
Sponsor
Sponsor
sponsor
bugzpodder




PostPosted: 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.
SuperGenius




PostPosted: 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.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: