O'Reilly Forums: A Day At The Races: Being Fair - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

A Day At The Races: Being Fair Optional random segment on dog performance

#1 User is offline   svHFCs 

  • New Member
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 09-August 14

Posted 02 September 2014 - 04:39 AM

I've posted my frustrations, I should at least post my support. This is totally for the sake of the game more so than for the lesson.

I enhanced the timer_click code for the dog race. You may disagree, but I didn't really feel that the dog race was fair in the fact that though a dog may have a random number of steps to determine its progress, it should also be random on which dog that progress is applied. For example, we have seen many types of races in real life, like horses, where the horses are ahead then behind then ahead again etc. However, we have also seen the horse that comes in from the back during the last lap and wins. This enhancement allows for that possiblity and makes the game less predictable and more fun. However, in the case of the dogs, what if two dogs both need 4 steps to win (say, dog 1 and 2), and the next random number is 4? I don't think dog 1 should win just because it is next in the sequence of the dogs but both should have an equal chance. So I added a randomizer for the dogs chosen for the random steps. The first 3 lines are my enhancement.

            int iDog;
            iDog = MyRandomizer.Next(0, 4);
            greyhound[iDog].Run();


            if (greyhound[iDog].MyPictureBox.Right >= (raceTrackPictureBox.Width - 50))
            {
                timer1.Stop();
                MessageBox.Show("Dog #" + (iDog + 1) + " won the race!", "We have a winner", MessageBoxButtons.OK);
                foreach (Greyhound dog in greyhound)
                {
                    dog.TakeStartingPosition();     
                }
                foreach (Guy guy in guys)
                {
                    guy.Collect(iDog + 1);
                    guy.myRadioButton.Enabled = true;
                    guy.ClearBet();
                    guy.myBet.GetDescription();
                    guy.UpdateLabels();
                }
                betsButton.Enabled = true;
                
             }.

This post has been edited by svHFCs: 02 September 2014 - 04:42 AM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users