jleonard2099 / LHG_CollegeBB

Lance Haffner Courtside College Basketball
GNU Affero General Public License v3.0
5 stars 0 forks source link

Frequent fouls #21

Closed jleonard2099 closed 1 year ago

jleonard2099 commented 1 year ago

This may not be reflected in the released version of the game, but this issue now exists in all current published code.

Fouls are occuring frequently in games, to the point where most scoring is from fouls rather than actual shots. I have slowed down a game enough to confirm this is the case (as opposed to fouls being counted wrong or FG counted as FTs, etc.)

In most games, both teams reach the 10th foul and usually within the first part of the first half.

I have re-evaluated the "FoulCalled" routine (which I separated out from the original code myself - usually the cause of such bugs) and the logic for it appears perfect compared to the original.

The challenge here will be determining how a foul is calculated (what variables are used / etc.)

jleonard2099 commented 1 year ago

This has been corrected and will be working in the next committ (as well as public release.) In following the code, it was clear that the right free throws were being taken when fouled. This came down to suspicion over how often fouls were getting called.

At some point in the code I realized R0! had been used as a variable for random #'s (despite being a float and the random #'s the game needs are integers). Well, it turns out there is one place in the game that needs R0! (as a single). Along with "Dim Shared" scoping of that variable, the random # generator wasn't able to update the value when needed. It was too often taking on the integer value of the R0! calculation (which was often < 10) and therefore under the foul threshold.

After making all random calls use a unique variable, this behavior appears much more accurate. The games played so far have resulted in teams usually totalling 10 or more fouls per game. (not to mention, far more FGM/FGA).