View Single Post
Old 08-24-2014, 08:16 PM   #36
Groundhog
Coordinator
 
Join Date: Dec 2003
Location: Sydney, Australia
Spent a good 6 hours coding this past weekend, working mainly on the passing logic. A few weeks ago I wrote an elif block that handled the hedge sequence if the PG comes off the screen with space. Basically it determined if the defender of the SG or PF's defenders leave their man, based on the defensive strategy (and whether they follow that strategy), and the PG then decides if he will pass to the open SG or PF if they do - based on the PGs ratings and the PF or SGs skill scoring from the position they are in. The actual pass action was in this elif block too - it could sail out of bounds, be picked off, or make it to the player.

This was great and it all worked as planned, but it was very specific to the one play. Instead, I wanted to build the logic of these two actions into more generic pass and hedge code blocks that could be called whenever they are required for any play.

For this I created an elif block and a function. The function is fed a number of variables about the current possession and uses these to determine if the player receiving the pass is open. It looks at the defensive strategy of the team so if the team is playing man-to-man defense for example, it will check if the ball handler is open and based on the location of that player and the defender, if the defender hedges in to pick up the ballhandler. If the team is playing zone, it uses the pass receiver's position on the court vs the type of zone being played to determine if the player is open. In a zone each defender is assigned different areas of the court to defend, and some slices - the mid-range baselines in the 1-3-1 for example - have a better chance of causing a player to be open than others. The defender's defensive awareness rating gives him a chance to recover to the player.
Anytime a pass action is required, I created an elif block that is called from within the play being run. The play moves the loop to the pass state, actions the pass, and based on the result (turnover, completed pass, etc) will then either return the loop to the play, or action a shot, etc.

If the pass is made to an open player around the basket, there is also a chance of the pass being an alley-oop play. The advantage of this is that it allows for alley-oops to happen outside of the scripted play being run - if a player passes to a guy near the basket who is open, there is a chance that this would be an alley-oop. The sim takes into account the ratings of the passer and the guy near the basket to determine if it's a good decision to throw the alley-oop, as well as the success of the pass and finish.

I also created a settings.ini file which stores some default values that can be tweaked to adjust frequency of things like fouls, open shot attempt %s, blocks, turnovers, alley-oop attempts, etc. Gameplay sliders I guess you could call them! They aren't raw % of events occurring because player ratings factor in as modifiers, but should hopefully allow me to tweak things easier down the track.

Next on my to-do list is an elif block to handle a ballhandler's isolation decision. It will factor in whether the player is open, the defense being faced, and based on the players ratings determine whether they attack the basket, shoot a jumpshot, or pass the ball - basically, it's an isolation play that could be called once a play breaks down, or in a play designed to get a skilled scorer the ball in a particular location. Once that's done, I want to go back and adjust a few calculations against different zone defenses, code a post play elif block, begin work on shot clock/game clocks, and then add stat recording. After that's done, much of the core "basketball" stuff will be coded and creating additional plays for the most part should be fairly straight forward.
__________________
Politics, n. Strife of interests masquerading as a contest of principles.
--Ambrose Bierce
Groundhog is offline   Reply With Quote