Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Connect Four AI
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

jonos

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

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.
bugzpodder

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

Connect Four.rar
Description:
Filename:  Connect Four.rar
Filesize:  224.5 KB

Amailer

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

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

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

bugzpodder

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.
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.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 10 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: