Posts

Showing posts from December, 2020

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. These arrays start

Baseball game dev diary: V1.0.2.202012232200 Lineup listboxes put to use and line score

Image
 When selecting a player in the lineup list boxes, that player’s info is shown in the player info box. Switches between the two lineups and base buttons (last player clicks deselects any player selected in the lineup) effectively. Reset game button text changed to ‘rewind game’ to better communicate its purpose (rewind to top of the first, no outs, same lineup).  Fixed bugs when reset game button is clicked, the player info did not clear if showing, and the lineup listboxes did not repopulate after being cleared. Array of buttons created for game log form, for line score. Procedure added to increment it by one, which will be added to extra innings code.  Recreated listboxes for lineups as array of listboxes.  Short demo video showing player info when clicking bases, on deck, in hole and lineups, as well as innings being added to line score (presently a button but will be made automatic when extra innings are required. 

Baseball game dev diary: V1.0.1.202012220933 Addition of on deck / in hole player info

Image
Added buttons for on deck and in hole player info. Runs existing procedure for show player info when clicked. Uses bases array spaces 8 and 9 which were intended for this purpose right from the start. Adjusted code to toggle buttons and on-screen info at various situations such as immediately after simming to last inning or end of game. Removed call to ‘buttons toggle simmed entire’ as it was the same code as ‘buttons toggle game over’ and will probably not differ in the future. Added listboxes showing lineups to make it easier to confirm it is cycling through lineups correctly. Tidied up the end of game and end of inning code so that simmed and manual games used the same code. See below. Well, this was an absolute nightmare of a 'minor' addition. The on deck/in hole stuff was no problem as I had already planned for it with the bases array. The lineup listboxes took literally five minutes. But in amongst all of that I decided to try and refine the end of game code as I realised

Baseball game dev diary game log: 'the one that got away in the bottom of the 9th'

Simulating a few games to test the walk-off code and the following game was generated. The away team was ahead 11-6 going in to the bottom of the 9th: Inning 9, Home Team batting 412 doubles on a 0-1 count.  427 singles on a 0-0 count.  409 doubles on a 1-2 count. 412 scores.  422 strikes out. 1 out. 420 doubles on a 0-0 count. 427 scores. 409 scores.  401 singles on a 1-1 count.  423 singles on a 0-0 count. 420 scores.  417 singles on a 0-2 count.  411 singles on a 1-0 count. 401 scores.  412 strikes out. 2 out. 427 strikes out. 3 out. Inning 10, Away Team batting 312 singles on a 0-0 count.  304 singles on a 0-0 count.  306 strikes out. 1 out. 303 strikes out. 2 out. 323 singles on a 0-2 count.  317 strikes out. 3 out. Inning 10, Home Team batting 409 homers on a 0-1 count.  Final:  Team 0 (away): 11 Team 1 (home): 12 Winner: Team 1 Pure randomness at play right there :)

Baseball game dev diary: V1.0.0.202012171941 Addition of the game log (with video!)

Image
I decided to call this version the first release as it's technically simulating complete games now. This turned out to be a significant update in terms of the amount of work involved to get the game log to a reasonably informative state. Due to the sequence of updates to data and outputting of data, lots of debugging and rearranging of code was required for things to display correct without compromising the integrity of the code (in other words – no band aids allowed!). The whole game can now be traced through the game log, play by play. Functionality will be added later to be able to export as a text file. Each plate appearance is also documented temporarily in the plate appearance log (ie ball 1, ball 2, strike 1, strike 2, strike 3 etc). The result of the plate appearance is output to both the plate appearance log and the game log. The PA log will strictly be for batter stuff only – ie steals, wild pitches etc when they are implemented will go in the game log only.  After clicki

Baseball game dev diary: Short demo video

Image
Recorded in PowerPoint on Windows, edited in iMovie on MacOS, many audio snippets replaced using Voice Memos on iPad. Gotta love technology. Subscribe to my YouTube channel while you're there. If I get over 100 I win a prize, or something like that. While I'm here I'll address the elephant in the room - yes, I'm using Visual Basic. It makes it easy for me, I get valuable feedback from the IDE and the debugging it offers and I get to experiment with using classes and objects in a familiar environment. All of this will end up being converted to some algorithms anyway.

Baseball game dev diary V0.5.3.202012090015 Giving the base buttons meaning

Image
Disabled base buttons at beginning of plate appearance unless occupied. Remove the code to reset bases in StartGame as that procedure called ResetGame procedure, which called ResetBases anyway.  Base buttons now display some player info when clicked, by searching for the playerID within the array of objects.  Added public variable for squadSize instead of hardcoding 28 into several places in code.  All player statuses set to 3 (benched) at start of game. Changed to 1 when put into game. Lineups now populate from squads array of player class objects with random players, not just first nine. Used a while loop to generate a random number up to squadSize and if player status was not 3, repeat random number generation. Ended up spending a lot longer than intended on this one (about 3 hours). Worth the extra time as I now better understand creating instances of classes and am fairly satisfied with the random generation of the lineup (even though that part really only took about 10 minutes).

Baseball game dev diary V0.5.2.202012032305 Prepping for pitchers

Created a player class. No such thing as a record anymore. Chose Class over Structure due to some web page recommendation. Was reminded that when variables within classes are set to private, you can’t change them outside of that class. So created a Property for each variable within the class that uses the Get and Set commands to read and write the values in the instances of a class. The private variable starts with an underscore, the property is the same name without the underscore. This should make coding the main game much easier. Presently, properties are: id, last name, first name, primary position, secondary positions, player type, pitches thrown, energy, stamina and game status. Created 28 instances of players for each team (scaled back from 40 for now). Made the base buttons clickable and each calls a procedure that is designed to show info for the batter/runner, but only when base is occupied. Later on will disable the buttons (including batter) if base is not occupied (or in b