Alice Community  

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

Reply
 
Thread Tools Display Modes
Horse Race Game
Old
xybition
Guest
 
Status:
Posts: n/a
Default Horse Race Game - 02-25-2008, 11:22 PM

Hey,
I need to create a horse race game. It is the question number 2, in Chapter 10 Projects, on page 276. It is about creating a horse race game, that horses move randomly and a different horse wins everytime. There are gonna be different colors of circles beginning of the each race lane, so the player can choose a horse. and if the player chooses the right horse is should say you win after the race ends. if the player does not choose the right horse it is going to say try again.

I created it, but my proffessor told me that I needed to use arrays in the race. Also she said that I needed to use randomized timing of race. The horses move randomly and a different horse wins everytime. So I thought time would be randomized but it is not enough. What else should i do? And I could not understand how I can fit the arrays in there. How can i use them in there? For what?

She said "Your coding would not take into
account the color but the position of the button I picked."

How do I fix this?

Thanks.

Last edited by xybition; 03-12-2008 at 11:35 PM.
   
Reply With Quote
Old
xybition
Guest
 
Status:
Posts: n/a
Default 03-11-2008, 07:05 PM

no one has any idea? or any information that help me?
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 03-11-2008, 07:20 PM

Quote:
Originally Posted by xybition View Post
no one has any idea? or any information that help me?
Go to Google and search for the following keywords:

baldwin alice drag race

See if you can glean any information from my drag race game that will help you with your horse race game.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Old
xybition
Guest
 
Status:
Posts: n/a
Default 03-12-2008, 11:36 PM

Quote:
Originally Posted by xybition View Post
Hey,
I need to create a horse race game. It is the question number 2, in Chapter 10 Projects, on page 276. It is about creating a horse race game, that horses move randomly and a different horse wins everytime. There are gonna be different colors of circles beginning of the each race lane, so the player can choose a horse. and if the player chooses the right horse is should say you win after the race ends. if the player does not choose the right horse it is going to say try again.

I created it, but my proffessor told me that I needed to use arrays in the race. Also she said that I needed to use randomized timing of race. The horses move randomly and a different horse wins everytime. So I thought time would be randomized but it is not enough. What else should i do? And I could not understand how I can fit the arrays in there. How can i use them in there? For what?

She said "Your coding would not take into
account the color but the position of the button I picked."

How do I fix this?

Thanks.

I am sorry. It said question #12. I fixed it. Now it says question #2. Please someone help me solve this question. it is really important. How am i supposed to use arrays in this?
   
Reply With Quote
Old
xybition
Guest
 
Status:
Posts: n/a
Default 03-16-2008, 04:05 PM

So I did the game. But still there is a problem with deciding which horse won. I think I did it the right way, and everything seems to be correct, but sometimes even if you do not choose the winning horse it will say you win, or even though if you choose the winning horse it will say try again. I am putting the game here, so maybe someone can tell me why it does that, or at least an idea.
Attached Files
File Type: a2w horse race game.a2w (1.02 MB, 554 views)
   
Reply With Quote
Old
lanceA
Guest
 
Status:
Posts: n/a
Default 03-16-2008, 04:31 PM

I would suggest that you ask the professor/teacher if you could meet with her before/after school or possibly during lunch period to review arrays/lists in Alice. Tell her you are having some difficulties with the assignment. I'm sure the teacher will accomodate you.

Teachers will help if you ask them! I don't believe a teacher would appreciate my writing your assignment for you. The teacher/professor is the best solution to your problem.

Good luck,
lanceA

Last edited by lanceA; 03-16-2008 at 04:33 PM. Reason: to provide further clarification
   
Reply With Quote
Old
xybition
Guest
 
Status:
Posts: n/a
Default 03-17-2008, 03:45 PM

Quote:
Originally Posted by lanceA View Post
I would suggest that you ask the professor/teacher if you could meet with her before/after school or possibly during lunch period to review arrays/lists in Alice. Tell her you are having some difficulties with the assignment. I'm sure the teacher will accomodate you.

Teachers will help if you ask them! I don't believe a teacher would appreciate my writing your assignment for you. The teacher/professor is the best solution to your problem.

Good luck,
lanceA
I asked but she wont help. She just tells me what to do, which is the same thing with the question. She said we dont have use arrays now. So i am not using arrays. I cant figure out whats wrong with coding.. It looks likle there is no mistake, but still it will display the wrong message. You dont have to write it for me, but if you can give me clue like ; use if, or use while. or use this property or this function. i dont know. anyhelp
   
Reply With Quote
Old
lanceA
Guest
 
Status:
Posts: n/a
Default 03-17-2008, 06:11 PM

First I am somewhat confused now by your question(s). You say you are doing the A Horse Race Game on page 276 of the Dann, et. al. text book. To the best of my knowledge you never needed arrays to begin with in this project. The horses are already part of the world. Secondly, the project tells you step-by-step the methods and event your need to create. In your code you've created an event for each circle?: why not create a world level method, startGame with 1 parameter (obj), and then create a single event: When mouse is clicked on anything, do world.startGame obj = object under mouse cursor.

Your initital method, startGame(), should then call a method such as, setClicked passing it the object that was clicked on:
world.setClicked = obj

Then, per the project specification create a class-level Boolean variable named isClicked for each of the circles. Initialize each class level variabable to false. When the player clicks on the circle, change the appropriate circles's isClicked to true:

setClicked() might look something like this . . .
if clicked == sphere
sphere.isClicked set value to true
else
if clicked == sphere2
sphere.isClicked set value to true
else
. . . . . . .

Now you know which sphere the user chose for the winner and you don't need an array for that neither do you care about the circles color.

Now write a world level method, horseRace() and do as the instructions say, use a Do together to move all three racehorses forward a short random distance.
world.horseRace()
Do together
raceHorseGame.raceLanes.racehorse1 move forward random number (min -0, max -0.2)
raceHorseGame.raceLances.racehorse2 . . . . .
raceHorseGame.

if world.isGameOver()
/*now determine if game is over as suggested by project's specification. "Write a
function called isGameOver() that asks 'Is a horse within 0.5 meters of the finish
line?' ". .05 meters accounts for the distance to finish line is measured from center
of horsen, not it's nose. If you resized the raceHorseGame object when creating
the world you may have to adjust this distance. This function should return a true
once it has determined that the game is over.
*/
else
world.horseRace() // you are recursively calling the horseRace() method
// until the game is over.

If you are still having problems after trying these tips then let me know. If you do have problems attach your code for the above, do not send your original code. Your original code has no comments in it, plus you have several methods with no code in them and that simple makes it somewhat harder to understand what you are doing.

I hope this helps.
   
Reply With Quote
Old
lanceA
Guest
 
Status:
Posts: n/a
Default 03-17-2008, 06:11 PM

First I am somewhat confused now by your question(s). You say you are doing the A Horse Race Game on page 276 of the Dann, et. al. text book. To the best of my knowledge you never needed arrays to begin with in this project. The horses are already part of the world. Secondly, the project tells you step-by-step the methods and event you need to create. In your code you've created an event for each circle?: why not create a world level method, startGame with 1 parameter (obj), and then create a single event: When mouse is clicked on anything, do world.startGame obj = object under mouse cursor.

Your initital method, startGame(), should then call a method such as, setClicked passing it the object that was clicked on:
world.setClicked = obj

Then, per the project specification, create a class-level Boolean variable named isClicked for each of the circles. Initialize each class level variabable to false. When the player clicks on the circle, change the appropriate circles's isClicked to true:

setClicked() might look something like this . . .
if clicked == sphere
sphere.isClicked set value to true
else
if clicked == sphere2
sphere2.isClicked set value to true
else
. . . . . . .

Now you know which sphere the user chose for the winner and you don't need an array for that; neither do you care about the circles color.

Now write a world level method, horseRace() and do as the instructions say, use a Do together to move all three racehorses forward a short random distance.
world.horseRace()
Do together
raceHorseGame.raceLanes.racehorse1 move forward random number (min -0, max -0.2)
raceHorseGame.raceLanes.racehorse2 . . . . .
raceHorseGame.raceLances.racehorse2. . . .

if world.isGameOver()
/*now determine if game is over as suggested by project's specification. "Write
a function called isGameOver() that asks 'Is a horse within 0.5 meters of the
finish line?' ". .05 meters accounts for the distance to finish line is measured
from center of horse, not it's nose. If you resized the raceHorseGame object
when creating the world you may have to adjust this distance. This function
should return a true once it has determined that the game is over.
*/
else
world.horseRace() // you are recursively calling the horseRace() method
// until the game is over.

If you are still having problems after trying these tips then let me know. If you do have problems attach your code for the above, do not send your original code. Your original code has no comments in it, plus you have several methods with no code in them and that makes it somewhat harder to understand what you are doing.

I hope this helps.

Last edited by lanceA; 03-17-2008 at 09:06 PM.
   
Reply With Quote
Old
xybition
Guest
 
Status:
Posts: n/a
Default 03-18-2008, 03:20 PM

I got it...

thanks a lot my friend. I owe you one! If you need anything done (you know... maybe easy, but takes a long time), let me know. I'll try to be of help. Thanks again.

Last edited by xybition; 03-18-2008 at 03:39 PM.
   
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 ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.