Jump to content

  • Log In with Google      Sign In   
  • Create Account


Using timing/clock in Simulation - (Basketball)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 brandon93s   Members   -  Reputation: 101

Like
0Likes
Like

Posted 14 February 2013 - 10:54 AM

I am creating a college basketball simulation that uses statistics to simulate games. Ultimately, going to buy a GUI interface on top of it, and create a management game.

 

Each game is simulated via a state machine, essentially. Could also be done in a while loop just as effectively. Anyways, I am having trouble with the clock mechanism. How and when does the game stop? There is two 20 minute halves in college basketball. The most reasonable method I could come up with is as follows:

 

You initialize a variable to 20 minutes (12,000 deciseconds). Then, each basektball posession is given a randomized length of posession off of a bell curve, centered around the teams average posession length. Each time, this amount is deducted from the initialized time variable until it reaches zero. 

 

What do you guys think? Can anyone think of a more accurate clock representation?



Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 12900

Like
0Likes
Like

Posted 14 February 2013 - 03:59 PM

I am a programmer and so by definition know nothing about the rules of the clock of basketball.

 

But whatever the situation, game time is usually handled with microsecond resolution and any time you need to time something the time is either accumulated or unaccumulated.

 

If you want a timer to count down from 1,200,000,000 microseconds, start it there and each logical update subtract the amount of time that has passed since the last logical update.  You should be using a fixed time-stamp for this, but it will work either way.

 

When subtracting, modify the amount of time you subtract by whatever the rules of basketball dictate.  If under X condition the timer is supposed to count down twice as fast, multiply your subtraction time by 2.  If for Y reason the clock is supposed to stop, multiply your subtraction value by 0.

 

 

L. Spiro


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 EmployeeNumber8   Crossbones+   -  Reputation: 1103

Like
0Likes
Like

Posted 15 February 2013 - 08:38 AM

Then, each basektball posession is given a randomized length of posession off of a bell curve, centered around the teams average posession length. Each time, this amount is deducted from the initialized time variable until it reaches zero.

 

Don't you think it would be more fun to add realism instead of just randomizing possession time? I'm sure you know that turnovers play a big role in Basketball. If you just randomize possession time then you kinda miss out on that. When you take turnovers into account, you could just let the clock run, and the possessions would sort themselves out. No need for randomization. In a real game, possession changes occur when a basket is scored, or on a turnover - to my mind you want to have that same logic in a simulation.



#4 Satharis   Members   -  Reputation: 949

Like
0Likes
Like

Posted 16 February 2013 - 06:33 AM

Kinda goes down to how much "simulation" you want to do, are you just doing statistical simulations of who wins the games and their scores and other data? If so you could technically randomize clock time and all that or just base it off some other factors.

 

Alternatively you could go into deeper simulation like a game of life would or something and have it literally play out randomized AI plays of the game and count the clock down when play is actually.. well going, a bit more complex obviously and would be running in super time but still.

 

This is one of those things that doesn't neccesarily have one right answer you just want to pick the one that sounds reasonable to code and will give a reasonable result.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS