Alice Community Connect 4- how to check for winner?

 Connect 4- how to check for winner?
p86aaron
Junior Member

Status: Offline
Posts: 1
Join Date: May 2012
Connect 4- how to check for winner? - 05-24-2012, 11:53 AM

Hello, i am new to alice and currently working on my final project in this 5 week course. My project is a game of 2 player connect four. I have gotten the board set up, and the pieces change colour when each person clicks. However, i am completely stuck when finding a way to detect that there has been a winner

Any help is appreciated
Attached Files
 FINAL PROJECT.a2w (600.6 KB, 40 views)

 TauTrumpsPi Senior Member     Status: Offline Posts: 399 Join Date: Mar 2011 Location: The diamond layer 05-24-2012, 03:34 PM Unfortunately, that is going to be very hard, probably harder than what you've done so far. The easiest way I can think of to do it is use 2 lists, one boolean for isRed/isBlack, and another representing the number of the area the piece occupies. Then, you need to have lots of if statements saying if 4 numbers next to each other horizontally are red/black, win, then do the same with vertically, and then diagonally, though that will be very hard. You're going to need some kind of algorithm to do it unless you want brute force programming, like if(#.IsBlack && #+1.IsBlack etc etc) for horizontal, then vertical and diagonal will be even harder My train of though kind of went crazy there, so if you need clarification, feel free to ask. Unfortunately, there is no easy way to do what you're asking. -------------------------------------------------------------------------------------------------------------------------- I have plenty of common sense. I just choose to ignore it. -Calvin and Hobbes Wondering about my Avatar? http://en.wikipedia.org/wiki/Tardigrade Wondering about my username? http://www.youtube.com/watch?v=jG7vhMMXagQ

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge