Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Problems with If/Else
Old
CaptainLizard
Junior Member
 
Status: Offline
Posts: 11
Join Date: Aug 2012
Default Problems with If/Else - 11-14-2012, 09:46 AM

So I'm doing the race horse exercise (Chapter 8-1 Exercise 1). I have created a very long IF/Else statement to check which horse is ahead of the others. It works for the most part but when more than one horse crosses the line, usually horse number one wins.
Now I've watched the variables on many different runs and I have come to the conclusion that when Alice asks If Distance1 < Distance2 that it is taking the absolute value of these numbers.
For example, one of my runs had horse1 with a distance of -0.04 and horse2 with a distance of -1.24. Logically, horse2 won because it is farther than horse1, but the program keeps picking horse1.
This is not just limited to horse1. The program seems to be breaking the tie as long as the distance is between 0.49 and -0.99.

My question is how do I get around this? Any help is appreciated

Last edited by CaptainLizard; 11-14-2012 at 09:56 AM.
   
Reply With Quote
 

Tags
alice 2.2 horse race


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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.