Posts

Random Game Log

Just posting this as I haven't been able to work on the project for a few months and trying to reconnect with it. The numbers in parentheses before a play eg (20) or (1) represent the batter's outcome. Inning 1, PEN batting (20) 328 grounds out on a 0-1 count.  Error made; 328 reached 1st safely.  (1) 325 strikes out. 1 out.  (1) 306 strikes out. 2 out.  (1) 301 strikes out. 3 out.  End of inning. Runs: 0, Hits: 0, Errors: 1, Walks: 0, Left on base: 1, Pitches: 13 Inning 1, BRS batting (1) 413 strikes out. 1 out.  (11) 415 singles on a 1-2 count.  (11) 417 singles on a 0-1 count. 415 advances to 2nd.  (1) 409 strikes out. 2 out.  (11) 428 singles on a 2-0 count. 415 advances to 3rd. 417 advances to 2nd.  (1) 407 strikes out. 3 out.  End of inning. Runs: 0, Hits: 3, Errors: 0, Walks: 0, Left on base: 3, Pitches: 20 Inning 2, PEN batting (1) 302 strikes out. 1 out.  (12) 322 doubles on a 0-1 count.  (1) 311 strikes out. 2 out.  (1) 327 strikes out. 3 out.  End of inning. Runs: 0,

V1.2.0.202104122145 Player database!

Image
After a few days of figuring out how to interact with a database, I’m finally confident that I can interact with a database using code-generated SQL. Linked the player creator to an external data source (presently using a 2004 version MS Access file). Player creator generate player button reads a random first name and surname and (state or country) from separate tables. Player creator now has a button to save the randomised player to the database. Player creator also has a button to save randomised players to database in bulk (user-specified number). Temporarily used a pop-up input box just to get it working. Tested out with 100 players – took 10 seconds. Player data is incomplete at present (eg no pitching attributes) but the basic structure is complete and fields can be added/changed as required.

V1.1.7.202104062135 Counting pitches and more player info

Image
Started by counting pitches to output inning pitch counts to the game log. This didn't take long so I moved on to the player creator. A lot of work done on the player creator this time around. Also began the reconstruction of the hit outcome calculations. Renamed StartPitch procedure to StartPlay and separated into two procedures (StartPlay and StartPitch). StartPlay now calls StartPitch if no pre-pitch play has occurred (eg balk, pickoff attempt). Add pitch counts to StartPitch procedure. Array was already there, just needed to add to it. Outputs pitch count for non-batting team to end of inning summary. Tested and is correct. Added complete range of attributes to player creator form and code for hitting, fielding and pitching. Presently pitching attributes do not have any code. Also added to player creator additional player info (names, height/weight, region and state/country). Presently names and state/country are randomly generated using case selection (will event

V1.1.6.202103231020 Fixing simmed game opening batter

Fixed the issue of opening batter ID showing as 0 when simming to top of last or simming full game. This was fixed by moving the nextbatter procedure call from the end of the simming loops to the beginning of the loops. Fixed the issue when simming full game, the home team’s full row of buttons were disabled in the line score. Removed the ‘if not simming’ conditions in the toggleHomeInningButton procedure. This game log should be all correct after the recent fixes (the numbers in parentheses are the in-game play codes, just ignore them): Inning 1, PEN batting (30) 327 flies out on a 1-0 count.  Error made; 327 reached 1st safely.  (1) 315 strikes out. 1 out.  (20) 323 grounds out on a 0-0 count. 327 advances to 2nd. 2 out.  (1) 309 strikes out. 3 out.  End of inning. Runs: 0, Hits: 0, Errors: 1, Walks: 0, Left on base: 1, Pitches: TBA Inning 1, BRS batting (1) 423 strikes out. 1 out.  (1) 410 strikes out. 2 out.  (12) 421 doubles on a 0-0 count.  (1) 422 strikes out. 3 out. 

V1.1.5.202103211320 Fixing game log after dropped third strikes and errors

After analysing a whole simmed game, I identified several issues created by the inclusion of dropped third strikes and errors. It seemed that outs and baserunners were not being handled correctly. So as predicted, the logic didn’t work as intended. Also I realised that dropped third strikes were not actually errors so I had to stop them being recorded as such. Fixed dropped third strikes being recorded as errors and the text output to game log because of such. Moved the advanced to 3rd from 2nd (or 1st) and advanced to 2nd from 1st code that was in single, double, groundouts, flyouts, strikeouts (and would have been in many plays added later) to their own procedures ( CheckAdvanceTo3rd and CheckAdvanceTo2nd ). Will probably do the same with all runner movement to avoid duplication of code. Added text ‘advances to 3rd’ and ‘advances to 2nd’ to game log when such activity happens. This will help with debugging but also improve the user experience. Did this with two new Boole

V1.1.4.202103032300 Basic player creator, line score tidy up and additional play results, including errors

This was a pretty huge four days! Player creator: This idea came to me when I started wondering how I could fulfil my plan of creating 10,000 players at random, at the same time giving them realistic attributes. Added a separate form to generate players which can eventually be saved to database. Presently just generates attributes for contact and power vs L/R based on an entered minimum number of points to allocate, and entered maximum value for bonus points. Bonus points are calculated at random and added to total points to allocate across all attributes. If an attribute is already on 100, that bonus point is wasted. Works pretty well and will be expanded upon. Line score tidy up: This was something that was mostly a quick fix so I thought I may as well get it out of the way now. Now the button for the bottom of the current inning is disabled if playing the top of the inning. Now puts an X in the bottom of the 9th if not played at game end and disables tha

V1.1.3.202102212105 Fielding positions filled

Image
A long time between sessions. I messed up the post-sim forward display trying to make it more efficient and spent hours trying to fix it. The problem was that I couldn’t revert back to the previous version because I had not made a backup after doing the fielder position logic. So it was either lose all of that work or fix it. So I chose to fix it. Which I did, seven weeks later. Unfortunately in between starting and finishing, there was a week-long camping trip, a change of computer (downgrading from 2017 iMac 27" to 2020 M1 MacBook Air) and (most disruptingly) returning to work. The first four weeks minimum after returning to work are basically a write-off timewise. As a consequence the familiarity with the code and the confidence in making a correction decreases as the time away from it increases. Ironically though in this case it only took a few minutes to come up with a solution once I sat down and revised how it worked. I did resort to a much-resented ‘band-aid’. I can justi