Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Connect 4- how to check for winner?
Old
p86aaron
Junior Member
 
Status: Offline
Posts: 1
Join Date: May 2012
Angry 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
File Type: a2w FINAL PROJECT.a2w (600.6 KB, 38 views)
   
Reply With Quote
Old
TauTrumpsPi
Senior Member
 
TauTrumpsPi's Avatar
 
Status: Offline
Posts: 399
Join Date: Mar 2011
Location: The diamond layer
Default 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
   
Reply With Quote
Reply

Thread Tools
Display Modes

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 Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.