View Single Post
Old 10-09-2014, 07:28 PM   #40
Groundhog
Coordinator
 
Join Date: Dec 2003
Location: Sydney, Australia
The last couple of weeks have been another big rewrite, this time purely around loop control. The basic structure of my sim was a whole bunch of "elif" blocks for each action - jump ball, pass, shot, etc. - with each block pointing the loop to the next, so a foul would lead to an inbound, etc. Apart from being messy, it's also harder to troubleshoot and to reuse elif blocks for similar actions.

I closed my text editor down and started mapping out a more structured loop control in excel, and came up something much cleaner. I have a sub-loop to the main game loop which I title the "logic_block". This is just an elif block but it controls the flow of the main game loop. Based on the game situation, which is a sub-loop to the 'logic_block', and this elif block points the loop to the correct action - action_shot_attempt, action_turnover, etc - and tells that action where to go next. What I really like about this layout is that each action is standalone - it just calculates what it needs to, and leaves everything else up to the logic_block. This makes it really easy to re-use these actions in different situations.

It probably doesn't sound exciting, but I'm very happy with how it's turned out.

In more basketball-ey coding, related to my post above, I have finished up the logic around non-structured offense. Every step of a play, the sim will check the offensive and defensive players positions on the court, determine if a guy is open (intentionally or not), his ability to score from where he is, and his location in comparison to the ballhandler to determine pass difficulty. All of these factors make up a "pass value" score from 1 to 4, with 1 being "Shaq open from 3" to 4 being "Shaq open in front of the basket" - ie. a must-pass. A player's offensive awareness determines how many player's pass values are checked, and the higher the value the more chance that the player will break from the scripted offense to make the pass to that player - again, offensive awareness helps aid the right decision here.

I have also put some work into mapping out distances between court positions to help with defensive recovery - if a guy is open with the ball at a particular location, this will be used to determine if the defender is able to recover from his position in time, or if the offensive player will get a chance at an open shot/drive etc. It will also allow for logic around defenders hedging off their man to pick up the ballhandler. Still lots to be done here, but I have a plan on how to implement it.

This is a text sim, but I am putting a lot of effort into tracking player positions on the court and the distance/relation between the areas on the court, because, while it's taken some work, it makes it easier to have "natural" events occur - open shots, backdoor cuts, etc.
__________________
Politics, n. Strife of interests masquerading as a contest of principles.
--Ambrose Bierce
Groundhog is offline   Reply With Quote