Posts

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 co...

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...

Baseball game dev diary: V1.1.2.202101012249 0x-1+1 =1 and 1x-1+1=0

Image
Added a team class, primarily to make it so that I could make the buttons on the diamond show up as team colours. ie When team 0 is batting, the base buttons have team 0 colours and the fielding buttons have team 1 colours, and vice versa when the teams switch. Batting buttons (bases etc) worked first go. Fielding buttons took a little longer as there was no existing logic to manage them. 0*-1+1 is 1 and 1*-1+1 is 0. Basically a guaranteed way to produce a 0 when a value is a 1 and get a 1 when a value is a 0. Used here to reverse the batting team value to avoid Ifs when working out the fielding team.

Baseball game dev diary: V1.1.1.202101011620 Adding a diamond

Image
Having overcome the frustration of the last lot of changes, I shifted my focus to improving the interface somewhat. Game log and line score now visible by default. Fixed base buttons getting messed up when simming forward. Was progressing to next batter before checking which base buttons needed disabling, so batter, on deck and in hole were always enabled after simming forward. Line score buttons now clear when rewinding game. Replaced function to generate a rounded up inning number (called 29 times) with an integer variable and add to it when incrementing inning only if int(inning) is not equal to inning number (ie only when progressing to top of an inning). Probably more efficient. Made the start game, sim forward, rewind and sim game menu items not buttons, and the show game log and show line score menu items, not checkboxes. Will remove buttons once I’m satisfied menu items are working correctly. Game log and line score toggles work as required. Moved the call to ButtonsTogg...

Baseball game dev diary: V1.1.0.202012302330 Innings buttons on the fly

Image
All innings buttons (regular and extra) are now generated as the game progresses. So innings 2-9 for example do not show until these innings are started. These arrays of objects are quite complicated to set up (especially when replacing existing variables or arrays with new ones) but they make for much more efficient code.  Generating of innings buttons was done incorrectly resulting in innings of 2 or more over the starting game length not being removed correctly. Code seemed to be creating a whole new set of innings buttons with each inning that was added, instead of just the one inning worth.  Hits and runs now update in the line score (as too will errors when they are included). Per-inning runs also update in the line score buttons.  Per innings totals for hits, runs, errors, walks, runners left on (LOBs) stored in two-dimensional arrays (0,1 is team 0 inning 1 etc) with 0,0 and 1,0 being the totals, making use of what would have been an empty array space anyway. Thes...