Jump to content
IGNORED

New Baseball game for the TI-99/4a


Opry99er

Recommended Posts

Although... a new EPROM and a Guidry board might do alright... I'm just very particular about acquiring original stuff. =) (I think I have a serious problem... I cannot stop collecting TI hardware and software...) It's not EVERYTHING I CAN GET MY HANDS ON... I'm pretty selective... And I don't like duplicates in my cartridge collection. The ones I've been hunting are Red Baron Flight Simulator and Strike Three!...

 

I'm pretty sure I'll never find a Killer Caterpillar or Arcturus... so I've got to stick to realistic goals. =)

Link to comment
Share on other sites

[/font][/color]

 

Yep... that's where the statistics will play a part when they get implemented... To weight the outcomes of each play by statistical variables goes to the heart of a REAL baseball simulation. =)

 

Glad you're doing some of the testing... Very soon it will be time to start making this thing "real".

 

I found a bigger blunder just now... Pete Rose hit a home run!

 

Ted Williams said if he hit as many singles is Pete, he would have tripped on his skirt. LOL

 

Try version 4 in a minute or two...

 

Looks good, and %80 free space... HMMMM.. Basesball-reference.com Just saying :)

Link to comment
Share on other sites

V.5 Attached to this post!

 

Updates:

 

*The game will not end until a winner is decided. (To prove it, I started in the 9th inning and played until the 12th until we had a winner)

 

*"Walk-offs" now recognized by the sim. (This code was a little trickier than I thought it would be to get put in place, but it's done)

 

 

Getting the walk-off scenario in place was actually tricky because it forced me to move my "check for winner" code outside of the "check for 3 outs" section of code and put it into a sub. I then had to access that sub from two different places... Once from inside the main game loop and once from the "3 outs" sub in order. This was done because one of two conditions had to be satisfied for the game to end.

 

1) The Check for 3 outs section: This was done to insure that if the Away Team (top of the inning) was behind in the 9th inning when they got 3 outs, that the home team (bottom of the inning) wouldn't come back to the plate for another appearance.

 

2) Inside the game loop: This had to be done to be sure that if the home team (bottom of the inning) took the lead in the bottom of the 9th inning or beyond that they wouldn't have to finish their side of the inning (i.e. get 3 outs to end the game). This is the "walk-off" scenario.

 

 

All in all it was a challenging little bit of code to put into place, but well worth it. Hope you enjoy.

 

 

***EDIT***

 

If you want to just test the "end of game scenario," change the value of "INN" in line 100 to "9" instead of "1".

 

That way you can test to see how the games will end. I've only run 2 "end of game" sims since I put this new code in place, so it may be buggy still, but I feel pretty good about it.

BASEBALL5.zip

Edited by Opry99er
Link to comment
Share on other sites

Coupla things...

 

1. If you're developing in a text editor, could you please include the text code in your zips? :)

2. Based on your description of "check for winner" and "check for 3 outs" - to me it seems like the "check for winner" should run at the end of every loop and include the "check for 3 outs" logic...

3. Walk offs are amazing!

 

-H

Link to comment
Share on other sites

I think it's time to start working on the weighted rolls and stats... So I've been thinking of which stats are important for a simulation's batter/hitter matchup...

 

Batting:

 

1) AVG (self explanatory... average hitting percentage of a player against pitching)

2) OBP (on base percentage... this is the percentage of plate appearances which wind up with the hitter on a base) Be it a hit, walk, hit by pitch, etc...

3) SLG (a complex equation, but essentially the higher the slugging percentage is, the better the hitter hits with power)

4) OPS (on base PLUS slugging) This has been used by baseball statisticians for decades to determine the true effectiveness of a hitter at the plate.

 

Pitching:

 

1) ERA (earned run average per 9 innings)

2) K/9 (strikeouts per 9 innings)

3) BB/9 (base-on-balls per 9 innings)

4) WHIP (walks plus hits per innings pitched) This is by far the most important stat for the pitchers in my sim... It determines exactly how many hitters are allowed to get to base over all.

 

 

**Truly, I could do the pitcher/hitter matchup using only OPS for batters and WHIP for pitchers and it would be a good weight... It might make for simpler code.

 

Now, outside of the hitting/pitching matchups, there are other factors to consider...

 

SPD (speed) determines effectiveness of a runner on the base path... Could allow for steals.

FLD (fielding) determines the ability of a defenseman in the outfield or infield to field the ball when it comes to them. This stat will go to determine "errors."

 

 

***So, in review:

If I implement the following stats into the sim, it will make it fairly realistic.

 

WHIP (pitching)

OPS (hitting)

SPD (base runners)

FLD (position players)

 

 

That will at least be a good starting point. =) What you guys think?

 

 

Owen

Edited by Opry99er
Link to comment
Share on other sites

Very cool Owen,

I don't envy your task here. I would suggest using the 162 game average for players.

This takes care of...Brady Anderson's 50 HR season or Rafael Palmeiro's 28 games at first base and winning a gold glove!

 

But, baseball is a game of streaks, who's hot who's not.... Match ups, etc. But I see managers using 3 at bats as a sample size! That cracks me up!

 

I like this project, I just got a rasberryPi and am playing with python (internet connected...). I could see this game/sim using daily stats, who is going to win tonight?

Would be cool to follow a team or 2 for a season and see how your predictions come out! LIVE feeding stats and lineups etc.

 

Gene

Link to comment
Share on other sites

To get going, I was planning on using the baseball-reference.com career average for the players... That way you don't get the steroids-pumped cheating aZZ Barry Bonds with his ridiculous 1.42 OPS for one season. (before I go any further, let me just say I freaking HATE that juiced-up cheating son of a b*** and he will have no place in my sim in any regard) =)

 

It's going to be a tough task, but all your suggestions are awesome and I want to implement them all... Baby steps though.

 

 

 

*First goal is to create a dice-roll which is weighted to the stats of the players.

 

*Second goal will be to record all in-game statistics to disk for retrieval and review.

 

*Third goal is to find a way to retrieve teams from disk so that you don't have to play the same team 162 times. =) Maybe start with a 5 team league for testing and then eventually get it expanded up to 30 teams. I don't think I'll be using the rosters for current or historic teams... I might try to find a way to do a random draft of the pool of historic players...

 

Anyway, it's going to take some time, but with work and time, I believe I can get it going... Hey 1980, you had a chance to DL and review the code in the document from the last post? From what I can gather, I've got PLENTY of room left to implement the statistical data required for the sim and still have plenty of room for graphics. =)

Link to comment
Share on other sites

Okay, testers... Check out this piece of code and tell me why it isn't doing what it's "supposed to". =)

 

**Hint... Look at the other "out" plays. =) This was an oversight on my part and I've got it pegged now.

 

 


**REM GROUNDOUT, DOUBLE PLAY IF RUNNER ON 1ST AND LESS THAN 2 OUTS, ALL OTHERS ADVANCE

490 PRINT "GROUNDOUT"
491 OUT=OUT+1 :: IF OUT>2 THEN RETURN
495 IF BFLG>0 THEN OUT=OUT+1 :: BFLG=0 :: PRINT "DOUBLE PLAY!"; :: IF OUT>2 THEN RETURN
496 IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO(TAP)=SCO(TAP)+1 :: BBBFLG=0
497 IF BBFLG>0 THEN BBBFLG=BBFLG :: BBFLG=0
498 PRINT "RUNNERS ADVANCE"
499 RETURN

 

 

The bug was discovered on my third sim today. I had bases empty 1 out... Hornsby was up to bat and he grounded out (rolling a "DP" groundout if runner on first) The problem was that it went ahead and told me about the runners advancing even though there was nobody on base. In every other "out" play wherein any base running is handled, the particular chunk of code calls a GOSUB 1500. Here's that code:

 


**REM THIS IS THE "CHECK IF THERE ARE ANY BASE RUNNERS" SUB

1500 IF BFLG>0 THEN RFLG=1 :: RETURN
1510 IF BBFLG>0 THEN RFLG=1 :: RETURN
1520 IF BBBFLG>0 THEN RFLG=1 :: RETURN
1530 RFLG=0 :: RETURN

 

This piece of code (in English) says "If there's anyone on any base, then "RFLG" is set to 1, otherwise set it to zero." So... since I didn't call for it in the above caveat (double play if runner on first and less than two outs... all other runners advance) then it prints it all anyway, regardless if there are any runners on or not.

 

Line 498 NOW says:

 

498 GOSUB 1500 :: IF RFLG>0 THEN PRINT "RUNNERS ADVANCE"

 

This is the kind of bug I've been finding... just oversights in small segments during the initial coding.

 

If you guys find any more of these, please let me know! =)

Edited by Opry99er
Link to comment
Share on other sites

Another bug squashed... In the "end of game" segment, the following line of code exists:

 

1705 IF SCO(1)>SCO(2) THEN CALL CLEAR :: PRINT "GAME OVER":"HOME: ";SCO(1),"AWAY: ";SCO(2) :: END

 

I don't know what I was smoking. I guess the game doesn't end until the home team wins... =) I ran a sim just now and came across this. In one of the highest scoring sims I've ever had on here, the Away team was squashing the home team pretty bad... bottom of the 9th, the home team couldn't come back from the 7 run deficit and the game was over... Or was it?

 

basbug_zpse813a554.jpg

 

As you can see, the game went into extras with a 7 run disparity. Looked at the code, and found this stupid piece of code. Just dumb. =) Anyway, it's fixed now.

 

1705 IF SCO(1)>SCO(2) THEN CALL CLEAR :: PRINT "GAME OVER":"HOME: ";SCO(1),"AWAY: ";SCO(2) :: END
1706 IF SCO(1)<SCO(2) THEN CALL CLEAR :: PRINT "GAME OVER":"HOME: ";SCO(1),"AWAY: ";SCO(2) :: END
1710 RETURN

 

 

My next post will have the new program and the new code attached.

Link to comment
Share on other sites

Okay, three updates in this package:

 

1) Screen color changes for each set of circumstances... flashes RED for an "out" play, flashes WHITE for a "reach base" play--- flashes blue for a "side change"

2) Double play bug fixed

3) End of game bug fixed

 

I added the screen changes in there to break up the monotony and give you a real clear sense of "what just happened"

 

bas3_zps53766ecf.jpg

 

bashit_zpsf952cafe.jpg

 

bas2_zpsb04326a4.jpg

 

 

Enjoy!

baseballcodeV6.zip

BASEBALLV6.zip

Link to comment
Share on other sites

...

**REM THIS IS THE "CHECK IF THERE ARE ANY BASE RUNNERS" SUB

1500 IF BFLG>0 THEN RFLG=1 :: RETURN
1510 IF BBFLG>0 THEN RFLG=1 :: RETURN
1520 IF BBBFLG>0 THEN RFLG=1 :: RETURN
1530 RFLG=0 :: RETURN

...

 

Why not

 

1500 RFLG=BFLG>0 OR BBFLG>0 OR BBBFLG>0::RETURN

 

...lee

Link to comment
Share on other sites

Lee,

As always, your optimization ideas are most welcome. I haven't started the optimization process yet, but this one's going directly into the "to-do" list.

 

The syntax is a bit different than I'm used to though... In your example, this will set RFLG to "1" if anyone is on base? See, the base flags don't contain just a "1" or a "0"... The base flags contain the lineup number of the player on base (so any number from 1-9).

 

BFLG can contain the number "9" (which would mean the pitcher is on first base), etc...

 

Will your code example still work with that construct?

 

I suppose I could just adjust the code in the main program to check for RFLG>0 as opposed to checking individually for "1" or "0".

 

This is all more optimization stuff I'll be getting into very soon. =) Thanks again

Edited by Opry99er
Link to comment
Share on other sites

Lee,

As always, your optimization ideas are most welcome. I haven't started the optimization process yet, but this one's going directly into the "to-do" list.

 

The syntax is a bit different than I'm used to though... In your example, this will set RFLG to "1" if anyone is on base? See, the base flags don't contain just a "1" or a "0"... The base flags contain the lineup number of the player on base (so any number from 1-9).

 

BFLG can contain the number "9" (which would mean the pitcher is on first base), etc...

 

Will your code example still work with that construct?

 

 

Yes.

 

I suppose I could just adjust the code in the main program to check for RFLG>0 as opposed to checking individually for "1" or "0".

 

No. You should use just RFLG as in "IF RFLG THEN ...". The THEN clause will not execute iff RFLG=0.

 

This is all more optimization stuff I'll be getting into very soon. =) Thanks again

 

A relational expression such as "BFLAG>0" will always result in a value of TRUE (-1) or FALSE (0), which can be used by the logical operators, AND, OR, XOR and NOT, as well as by the IF statement. For that matter, you can use any numerical value as a parameter for a logical operator or as an expression for IF---you just need to remember that the logical operators perform bitwise operations. The IF statement needs an expression that it can evaluate as TRUE (non-zero) or FALSE (0). Though any value except 0 is considered TRUE by IF, all relational expressions that are true evaluate to -1. If, in fact, you want RFLG=1, you would need to negate the result of my suggested line 1500 by subtracting the result from 0:

 

1500 RFLG=0-(BFLG>0 OR BBFLG>0 OR BBBFLG>0)::RETURN

 

If RFLG is only considered in IF statements such as "IF RFLG=1 THEN ..." or "IF RFLG>0 THEN ...", you could change it to "IF RFLG THEN ...", which is probably faster because XB does not have to evaluate the expression.

 

Head hurt yet? :P

 

...lee

Link to comment
Share on other sites

No... At one point I knew most of this stuff... Just getting back into the swing. =)

 

Although I've been reading yours and Willsy's Forth posts... THAT.... hurts my head. =)

 

I'll re-read through your post later today and take some notes. It's nice to have masters on here to learn from. I appreciate your time and your wisdom, sir.

Link to comment
Share on other sites

No... At one point I knew most of this stuff... Just getting back into the swing. =)

 

Although I've been reading yours and Willsy's Forth posts... THAT.... hurts my head. =)

 

I'll re-read through your post later today and take some notes. It's nice to have masters on here to learn from. I appreciate your time and your wisdom, sir.

 

Master? I'm not so sure...but, what I know or think I know you are certainly welcome to and, as you no doubt have noticed, I'm not shy. As to time, I usually have plenty of that with 3 1/2 years into retirement and I'm certainly enjoying myself! ;-)

 

...lee

Link to comment
Share on other sites

Belated congratulations. =) One day, I will hopefully have the opportunity to retire and focus on family and hobbies (namely the TI right now). =)

 

BTW, I've been playing around in TurboForth today... the standard "getting into it" stuff...

 

**forgive the formatting

 


>: STAR
> 42 EMIT
>;
>
>: STARS
> 0 DO STAR LOOP
>;
>
>: SQUARE
> DUP 0 DO
> DUP STARS CR
> LOOP DROP
>;

 

 

I've always loved the construct in Forth... But the concept is so hard to filter through my head. I mean in principle, it sounds so simple... And it IS!!! But, man... tracking and manipulating the stack just proves to be very challenging for me. All the Forth stuff I've done/tried in the past ended up being very BASIC-like and didn't seem "Forthy" enough. When I get moved into my new house, I'm going to get out all my Forth docs and start playing again... Maybe THIS TIME it will all sink in. =)

Edited by Opry99er
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...