• Categories
  • Popular
  • Dev Tracker
Skins
  • Default (The Show 25)
  • No Skin
  • The Show 23
  • Dark
  • The Show 24
  • The Show 25
Collapse
THESHOW.COM
Game Game Support Support My Account My Account

Community Forum

Programming baseball innings

Scheduled Pinned Locked Moved General Discussion
8 Posts 5 Posters 486 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Red_Ted_is_back_PSNR Offline
    Red_Ted_is_back_PSNR Offline
    Red_Ted_is_back_PSN
    wrote on last edited by
    #1

    I’d appreciate the input of any programmers out there on the following.

    What would be the best way to structure the code for the looping of baseball innings, and why?

    So far, I can come up with the following ideas:

    1. A for loop to repeat the first eight innings, then a while loop for innings 9+ that repeats the content while the game is tied
    2. A while loop for the whole game that repeats while inning is (less than 9) OR (more than 8 AND scores are equal)
    3. A for loop to repeat the first eight, then a single block specifically for the 9th, then a while loop for innings 10+

    I’m thinking #2 simply to avoid repeating code, but it doesn’t take into account the fact that the 9th inning is unique from a winner checking POV so open to better ideas.

    Cheers

    1 Reply Last reply
    0
  • SaveFarris_PSNS Offline
    SaveFarris_PSNS Offline
    SaveFarris_PSN
    wrote on last edited by
    #2

    bool gameEnd = false;
    int inningCnt = 0;

    WHILE (gameEnd == false)
    {
    inningCnt++;
    playRoadTeamBat();
    if (inningCnt >= 9 && homeScr > roadScr)
    {
    gameEnd = true;
    break;
    }
    if (rain == true && inningCnt > 5 && homeScr > roadScr)
    {
    gameEnd = true;
    break;
    }
    playHomeTeamBat();
    if (inningCnt >= 9 && homeScr > roadScr)
    {
    gameEnd = true;
    break;
    }
    }

    Red_Ted_is_back_PSNR 1 Reply Last reply
    0
  • Red_Ted_is_back_PSNR Offline
    Red_Ted_is_back_PSNR Offline
    Red_Ted_is_back_PSN
    replied to Guest on last edited by
    #3

    @SaveFarris said in Programming baseball innings:

    bool gameEnd = false;
    int inningCnt = 0;

    WHILE (gameEnd == false)
    {
    inningCnt++;
    playRoadTeamBat();
    if (inningCnt >= 9 && homeScr > roadScr)
    {
    gameEnd = true;
    break;
    }
    if (rain == true && inningCnt > 5 && homeScr > roadScr)
    {
    gameEnd = true;
    break;
    }
    playHomeTeamBat();
    if (inningCnt >= 9 && homeScr > roadScr)
    {
    gameEnd = true;
    break;
    }
    }

    Thanks for the code - wasn't expecting somebody to go to the trouble but that's awesome you took the time to do that.

    I'd go so far as to put the rainout check after each pitch rather than in between innings. I'd probably change it to a general 'if rainout then gameEnd' that calls a procedure that goes through the rainout rule decision process (the > or <= 5 inningCnt) separately.

    What's making me overthink it is the home 9+ inning and checking for the win during the inning. I reckon I'll try changing the homeScr > roadScr check to a simple winner > 0 (possible values 0, 1, 2 for none, away, home) and have the score check after each pitch also (would do each PA except if a pitch is a balk, wild pitch, passed ball or steal then a plate appearance may not be over) so that it can break to the 'game' while loop if there is a winner.

    In a couple more weeks I'll have some time to put together some procedures for a whole game. Might share some here.

    1 Reply Last reply
    0
  • Freddy_Sez_PSNF Offline
    Freddy_Sez_PSNF Offline
    Freddy_Sez_PSN
    wrote on last edited by
    #4

    Prob would also need a check for roadScr > homeScr somewhere, otherwise the while loop won't exit if the road team is winning.

    1 Reply Last reply
    0
  • J Offline
    J Offline
    je8675309
    wrote on last edited by
    #5

    I never knew I would find a discussion about baseball game development. Pretty cool.

    I don't follow any structure so I by no means follow any best practices. I just keep dabbling at the code till it does what I want it do to. Here's something from a game I'm developing:

    while($inning < 10 || ($inning > 9 && $homeExtraInningAtBat == false)) {

    if($inning >= 9 && $hRuns > $vRuns && $inningHalf == 'bottom'){
    
    	print "End game walk off<br>";	
    
    	$endOfGame = true;
    
    	...
    
    }
    
    if($inning > 8 && $hRuns > $vRuns){
    
    	print "End game<br>";
    
    	$endOfGame = true;
    }
    
    if($inning > 8 && $vRuns > $hRuns){
    
    	print "End game<br>";
    
    	$endOfGame = true;
    
    	$homeExtraInningAtBat = true;
    
    }
    
    $inningHalf = 'top';
    $outs = 0;
    		
    if($endOfGame == false){
    
    	$inning = $inning + 1;
    
    }
    

    }

    Red_Ted_is_back_PSNR 1 Reply Last reply
    0
  • Red_Ted_is_back_PSNR Offline
    Red_Ted_is_back_PSNR Offline
    Red_Ted_is_back_PSN
    replied to Guest on last edited by Red_Ted_is_back_PSN
    #6

    @je8675309 said in Programming baseball innings:

    I never knew I would find a discussion about baseball game development. Pretty cool.

    I don't follow any structure so I by no means follow any best practices. I just keep dabbling at the code till it does what I want it do to. Here's something from a game I'm developing:

    while($inning < 10 || ($inning > 9 && $homeExtraInningAtBat == false)) {

    if($inning >= 9 && $hRuns > $vRuns && $inningHalf == 'bottom'){

      print "End game walk off<br>";	
    
      $endOfGame = true;
    
      ...
    

    }

    if($inning > 8 && $hRuns > $vRuns){

      print "End game<br>";
    
      $endOfGame = true;
    

    }

    if($inning > 8 && $vRuns > $hRuns){

      print "End game<br>";
    
      $endOfGame = true;
    
      $homeExtraInningAtBat = true;
    

    }

    $inningHalf = 'top';
    $outs = 0;

    if($endOfGame == false){

      $inning = $inning + 1;
    

    }

    }

    I like the game log generated as html idea that your code just gave me 🙂

    I’m all for keeping this discussion going; it’s nice reading in amongst all the complaints. You never know, we could come up with something 😉

    1 Reply Last reply
    0
  • Rabid55Wolverine_PSNR Offline
    Rabid55Wolverine_PSNR Offline
    Rabid55Wolverine_PSN
    wrote on last edited by
    #7

    I'm not much into programming at all but what would this be for?

    Red_Ted_is_back_PSNR 1 Reply Last reply
    0
  • Red_Ted_is_back_PSNR Offline
    Red_Ted_is_back_PSNR Offline
    Red_Ted_is_back_PSN
    replied to Guest on last edited by
    #8

    @Rabid55Wolverine said in Programming baseball innings:

    I'm not much into programming at all but what would this be for?

    Just messing around with ideas, keeping the brain active.

    1 Reply Last reply
    0
  • A admin locked this topic on

X Instagram Facebook YouTube Twitch Discord TikTok
Major League Baseball Players Association Major League Baseball Sony Interactive Entertainment PlayStation Studios San Diego Studio ESRB ESRB Certificate
Terms of Use Privacy Policy TheShow.com Community Code of Conduct MLB The Show Online Code of Conduct MLB The Show Games

Stubs is a registered trademark or trademark of Sony Interactive Entertainment LLC.

"PlayStation Family Mark", "PlayStation", "PS5 Logo", and "PS4 Logo" are registered trademarks or trademarks of Sony Interactive Entertainment Inc.

Microsoft, the Xbox Sphere mark, Series X|S logo, and Xbox Series X|S are trademarks of the Microsoft group of companies.

Nintendo Switch is a trademark of Nintendo.

Major League and Minor League Baseball trademarks and copyrights are used with permission of Major League Baseball. Visit MLB.com and MiLB.com. The Baseball Hall of Fame and Museum trademarks and copyrights are used with permission of the National Baseball Hall of Fame and Museum, Inc., as applicable. Visit the official website of the Hall of Fame at BaseballHall.org

Officially Licensed Product of MLB Players, Inc. MLBPA trademarks, copyrighted works and other intellectual property rights are owned and/or held by MLBPA and may not be used without the written consent of MLBPA or MLB Players, Inc. Visit MLBPLAYERS.com, the Players Choice on the web.

© 2024 Sony Interactive Entertainment LLC.

  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Popular
  • Dev Tracker
  • Login

  • Login or register to search.