View Single Post
Old 07-27-2014, 05:17 AM   #18
Groundhog
Coordinator
 
Join Date: Dec 2003
Location: Sydney, Australia
Initial Sim Concept

The sim itself would be a loop that continues to run until the game is over. That's the easy part. There are a collection of variables that are checked each time the loop is run - team with possession, type of possession, game situation, etc. - that then fire functions based on those conditions. These functions would be things like inbound plays, halfcourt sets, free throws etc. They would write commentary to a file, keep stats, etc.

The first issue I see with doing it that way would be the amount of info I need to pass between the main program and the individual functions. Each time a play is run, for example, I'd need to pass just about every variable containing player and team information through to each function every time it fires, and then once the function is finished a lot of data will need to be sent back too - stats being the prime example. Using global variables would cut back on some of this, although I'm trying to avoid using too global variables if I can. The advantage to this method would be that the main program would be more compact.

The other method would be reserving functions just for the calculations - for example, to use the jump ball experiment above, the loop would run and check the variable that calls for the opening tip. An 'If' statement then fires and runs the actual play, including the jumpball function. The function would simply return a couple of values to indicate who was in the jump and who won, and the main program then uses the values to build the commentary and adjusts any stats as required (none, in this case), as well as set the variables that will trigger the next event - a possession for the winning team.

The advantage would be less information being passed between the main program and the numerous functions. The main disadvantage is that the program is going to get very long, very fast!

Maybe I'm way off and there's a better way to do it that I don't know yet, but right now I'm leaning towards option #2.
__________________
Politics, n. Strife of interests masquerading as a contest of principles.
--Ambrose Bierce

Last edited by Groundhog : 07-27-2014 at 05:28 AM.
Groundhog is offline   Reply With Quote