Jump to content
IGNORED

New Baseball game for the TI-99/4a


Opry99er

Recommended Posts

Thanks, Jacques!!

 

Yea, I may end up doing some variable compression once the whole thing is designed and organized... Right now I'm just trying to figure out "how the heck do I handle all these possible scenarios?!?!?!"

 

=)

 

I had a couple breakthroughs last night and I SHOULD be able to finish the "one-team" simulation by tonight. Then I'll need to do the same for the second team (that shouldn't be difficult). Once that is complete, I'll have to create/implement the statistic recording subroutines and then graphics.

 

If I can record statistics to disk, this could get really interesting. It would be possible to record player statistics over a "season" and compile them to get a "team MVP" or something of the like. =)

 

It's a silly little program and probably nobody will play it, but it's a good "re-starter" for me.

Link to comment
Share on other sites

When I was a kid, one of my last projects was an XB game for Baseball. I got as far as having it draw the field and make the players run out on the field (which sucked, and finally discouraged me)...

 

One thing I did do, however, was make the speech say "Baseball" I used some speech hack tool which split and smooshed the phonemes and it wound up sounding like "Bayess Buhl".

 

And, no, I don't have it... I sold off all my TI stuff to afford a PeeCee as a kid. Maybe I got $150? Whatever it was, it's a horror show.

Link to comment
Share on other sites

heh.... I was tempted at the start of this to do graphics at the outset. I had a real pretty field all drawn up and such. I decided not to do graphics til' last... To force me to do the dirty work before the "payoff." Of course I want to do the graphics NOW... But I'm forcing myself to wait...

 

Masochistic if you ask me.... =)

Link to comment
Share on other sites

Next I will be creating a simple "base" display... It won't be graphic, but it WILL show which player is on which base at any given time... In that way, it will be visually apparent that my routines are working properly. If you run the program (the last one I posted) and keep track mentally of where the players are, the scoring works perfectly... Now I just need to add the visual of this for testing purposes.

 


4
3 5
6

 

Or something of the like in the bottom right corner....

Link to comment
Share on other sites

Alrighty... Here's the visualization of the base running. You can see each base runner and where they are at the start of a play... You can then see where they end up at the end of the play. After 10 simulations of 9 inning games, all base running seems to be in order.

 

I still haven't finished the "outs" rolls yet, but I'm getting there. Check out this video and then you can copy and paste the code into Classic99 if you'd like.

 

http://youtu.be/-MVVdn_Nn_g

 

 

 

 


**REM THESE LINES SET UP INITIAL VARIABLES.  EACH BASE HAS A FLAG AND PLAYER NAME ASSOCIATED WITH IT

100 BAP=0 :: INN=1 :: OUT=0 :: BFLG=0 :: BBFLG=0 :: BBBFLG=0 :: HPFLG=0 :: SCO=0
110 RANDOMIZE
120 REM BASEBALL SIM

**REM THESE ARE THE STRING VARIABLES CARRYING THE PLAYERS' NAMES WITH THEM

130 P$="W. JOHNSON"
140 C$="J. BENCH"
150 B$="L. GEHRIG"
160 BB$="R. HORNSBY"
170 BBB$="E. MATHEWS"
180 SS$="H. WAGNER"
190 LF$="T. WILLIAMS"
200 CF$="J. DIMAGGIO"
210 RF$="B. RUTH"

**REM THIS IS THE START OF THE VISUAL SETUP

220 CALL CLEAR
230 DISPLAY AT(8,:"DICE BASEBALL";
240 DISPLAY AT(12,:"PRESS ANY KEY":"        TO SIMULATE";
250 GOSUB 520
260 IF OUT>2 THEN OUT=0 :: INN=INN+1 :: BFLG=0 :: BBFLG=0 :: BBBFLG=0
265 IF INN>9 THEN CALL CLEAR :: PRINT "GAME OVER" :: END
266 DISPLAY AT(21,18):BBFLG; :: DISPLAY AT(22,17):BBBFLG; :: DISPLAY AT(22,19):BFLG; :: DISPLAY AT(23,18):BAP
270 DISPLAY AT(4,4):"OUTS: ";OUT :: DISPLAY AT(4,18):"INNING: ";INN :: DISPLAY AT(6,4):"SCORE: ";SCO
280 DISPLAY AT(20,1):"NOW BATTING:":BAP$;
290 CALL KEY(0,K,S):: IF S=0 THEN 290
300 SFDICE=INT(RND*6)+1
310 WHDICE=INT(RND*6)+1
320 CALL CLEAR :: PRINT SFDICE :: PRINT WHDICE
330 FOR I=1 TO 400 :: NEXT I
340 IF SFDICE<3 THEN GOSUB 360 ELSE GOSUB 440
350 FOR I=1 TO 900 :: NEXT I :: CALL CLEAR :: GOTO 240

**REM THIS IS THE "YOU REACH BASE AND HERE'S HOW" SUB

360 CALL CLEAR
370 ON WHDICE GOSUB 380,390,400,410,420,430 :: RETURN

**REM WALK, RUNNERS ON BASE ADVANCE ONLY IF FORCED

380 PRINT "WALK"
381 IF BBBFLG>0 AND BBFLG>0 AND BFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=BBFLG :: BBFLG=BFLG :: BFLG=BAP;
382 IF BBFLG>0 AND BFLG>0 THEN BBBFLG=BBFLG :: BBFLG=BFLG :: BFLG=BAP
383 IF BFLG>0 THEN BBFLG=BFLG :: BFLG=BAP
384 BFLG=BAP
385 RETURN

**REM SINGLE, ALL RUNNERS ADVANCE ONE BASE

390 PRINT "SINGLE" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
391 IF BBFLG>0 THEN BBBFLG=BBFLG :: BBFLG=0
392 IF BFLG>0 THEN BBFLG=BFLG :: BFLG=0
393 BFLG=BAP
394 RETURN

400 PRINT "SINGLE" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
401 IF BBFLG>0 THEN BBBFLG=BBFLG :: BBFLG=0
402 IF BFLG>0 THEN BBFLG=BFLG :: BFLG=0
403 BFLG=BAP
404 RETURN

**REM DOUBLE, ALL RUNNERS ADVANCE TWO BASES

410 PRINT "DOUBLE" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
411 IF BBFLG>0 THEN HPFLG=BBFLG :: SCO=SCO+1 :: BBFLG=0
412 IF BFLG>0 THEN BBBFLG=BFLG :: BFLG=0 
413 BBFLG=BAP
414 RETURN

**REM TRIPLE, ALL RUNNERS ADVANCE THREE BASES

420 PRINT "TRIPLE" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
421 IF BBFLG>0 THEN HPFLG=BBFLG :: SCO=SCO+1 :: BBFLG=0
422 IF BFLG>0 THEN HPFLG=BFLG :: SCO=SCO+1 :: BFLG=0
423 BBBFLG=BAP
424 RETURN

**REM HOME RUN, ALL RUNNERS (PLUS BATTER AT PLATE) SCORE

430 PRINT "HOME RUN" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
431 IF BBFLG>0 THEN HPFLG=BBFLG :: SCO=SCO+1 :: BBFLG=0
432 IF BFLG>0 THEN HPFLG=BFLG :: SCO=SCO+1 :: BFLG=0
433 HPFLG=BAP :: SCO=SCO+1
434 RETURN

**REM THIS IS THE "YOU'RE OUT, AND HERE'S HOW" SUB

440 CALL CLEAR
450 ON WHDICE GOSUB 460,470,480,490,500,510 :: RETURN
460 PRINT "STRIKEOUT" :: OUT=OUT+1 :: RETURN
470 PRINT "GROUNDOUT, RUNNERS ADVANCE" :: OUT=OUT+1 :: RETURN
480 PRINT "GROUNDOUT, RUNNERS ADVANCE":"IF FORCED" :: OUT=OUT+1 :: RETURN
490 PRINT "GROUNDOUT, DOUBLE PLAY":"IF RUNNER ON 1ST AND":"LESS THAN 2 OUTS...":"ALL OTHERS ADVANCE" :: OUT=OUT+1 :: RETURN
500 PRINT "SHALLOW FLYOUT":"RUNNERS HOLD" :: OUT=OUT+1 :: RETURN
510 PRINT "DEEP FLYOUT, RUNNERS ON":"SECOND OR THIRD ADVANCE" :: OUT=OUT+1 :: RETURN

**REM THIS IS THE "GO THROUGH BATTING ORDER AND DISPLAY BATTER'S NAME" SUB

520 BAP=BAP+1 :: IF BAP>9 THEN BAP=1
530 IF BAP=1 THEN BAP$=B$ ELSE IF BAP=2 THEN BAP$=BB$ ELSE IF BAP=3 THEN BAP$=BBB$ ELSE IF BAP=4 THEN BAP$=SS$
540 IF BAP=5 THEN BAP$=LF$ ELSE IF BAP=6 THEN BAP$=CF$ ELSE IF BAP=7 THEN BAP$=RF$ ELSE IF BAP=8 THEN BAP$=C$
550 IF BAP=9 THEN BAP$=P$
560 RETURN

 

 

Link to comment
Share on other sites

Full routines for one player simulation complete. All "success" rolls and all "outs" rolls are now simulated and working beautifully. Copy and paste into Classic99 and play a little game of baseball... well, the offensive side anyway. =) 2nd player simulation forthcoming... maybe not tonight, but coming.

 

 

 

 


**REM THESE LINES SET UP INITIAL VARIABLES.  EACH BASE HAS A FLAG AND PLAYER NAME ASSOCIATED WITH IT

100 BAP=0 :: INN=1 :: OUT=0 :: BFLG=0 :: BBFLG=0 :: BBBFLG=0 :: HPFLG=0 :: SCO=0
110 RANDOMIZE
120 REM BASEBALL SIM

**REM THESE ARE THE STRING VARIABLES CARRYING THE PLAYERS' NAMES WITH THEM

130 P$="W. JOHNSON"
140 C$="J. BENCH"
150 B$="L. GEHRIG"
160 BB$="R. HORNSBY"
170 BBB$="E. MATHEWS"
180 SS$="H. WAGNER"
190 LF$="T. WILLIAMS"
200 CF$="J. DIMAGGIO"
210 RF$="B. RUTH"

**REM THIS IS THE START OF THE VISUAL SETUP

220 CALL CLEAR
230 DISPLAY AT(8,:"DICE BASEBALL";
240 DISPLAY AT(12,:"PRESS ANY KEY":"        TO SIMULATE";
250 GOSUB 520
260 IF OUT>2 THEN OUT=0 :: INN=INN+1 :: BFLG=0 :: BBFLG=0 :: BBBFLG=0
265 IF INN>9 THEN CALL CLEAR :: PRINT "GAME OVER" :: END
266 DISPLAY AT(21,18):BBFLG; :: DISPLAY AT(22,17):BBBFLG; :: DISPLAY AT(22,19):BFLG; :: DISPLAY AT(23,18):BAP
270 DISPLAY AT(4,4):"OUTS: ";OUT :: DISPLAY AT(4,18):"INNING: ";INN :: DISPLAY AT(6,4):"SCORE: ";SCO
280 DISPLAY AT(20,1):"NOW BATTING:":BAP$;
290 CALL KEY(0,K,S):: IF S=0 THEN 290
300 SFDICE=INT(RND*6)+1
310 WHDICE=INT(RND*6)+1
320 CALL CLEAR :: PRINT SFDICE :: PRINT WHDICE
330 FOR I=1 TO 400 :: NEXT I
340 IF SFDICE<3 THEN GOSUB 360 ELSE GOSUB 440
350 FOR I=1 TO 900 :: NEXT I :: CALL CLEAR :: GOTO 240

**REM THIS IS THE "YOU REACH BASE AND HERE'S HOW" SUB

360 CALL CLEAR
370 ON WHDICE GOSUB 380,390,400,410,420,430 :: RETURN

**REM WALK, RUNNERS ON BASE ADVANCE ONLY IF FORCED

380 PRINT "WALK"
381 IF BBBFLG>0 AND BBFLG>0 AND BFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=BBFLG :: BBFLG=BFLG :: BFLG=BAP;
382 IF BBFLG>0 AND BFLG>0 THEN BBBFLG=BBFLG :: BBFLG=BFLG :: BFLG=BAP
383 IF BFLG>0 THEN BBFLG=BFLG :: BFLG=BAP
384 BFLG=BAP
385 RETURN

**REM SINGLE, ALL RUNNERS ADVANCE ONE BASE

390 PRINT "SINGLE" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
391 IF BBFLG>0 THEN BBBFLG=BBFLG :: BBFLG=0
392 IF BFLG>0 THEN BBFLG=BFLG :: BFLG=0
393 BFLG=BAP
394 RETURN

400 PRINT "SINGLE" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
401 IF BBFLG>0 THEN BBBFLG=BBFLG :: BBFLG=0
402 IF BFLG>0 THEN BBFLG=BFLG :: BFLG=0
403 BFLG=BAP
404 RETURN

**REM DOUBLE, ALL RUNNERS ADVANCE TWO BASES

410 PRINT "DOUBLE" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
411 IF BBFLG>0 THEN HPFLG=BBFLG :: SCO=SCO+1 :: BBFLG=0
412 IF BFLG>0 THEN BBBFLG=BFLG :: BFLG=0 
413 BBFLG=BAP
414 RETURN

**REM TRIPLE, ALL RUNNERS ADVANCE THREE BASES

420 PRINT "TRIPLE" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
421 IF BBFLG>0 THEN HPFLG=BBFLG :: SCO=SCO+1 :: BBFLG=0
422 IF BFLG>0 THEN HPFLG=BFLG :: SCO=SCO+1 :: BFLG=0
423 BBBFLG=BAP
424 RETURN

**REM HOME RUN, ALL RUNNERS (PLUS BATTER AT PLATE) SCORE

430 PRINT "HOME RUN" :: IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
431 IF BBFLG>0 THEN HPFLG=BBFLG :: SCO=SCO+1 :: BBFLG=0
432 IF BFLG>0 THEN HPFLG=BFLG :: SCO=SCO+1 :: BFLG=0
433 HPFLG=BAP :: SCO=SCO+1
434 RETURN

**REM THIS IS THE "YOU'RE OUT, AND HERE'S HOW" SUB

440 CALL CLEAR
450 ON WHDICE GOSUB 460,470,480,490,500,510 :: RETURN

**REM STRIKEOUT, NO RUNNERS ADVANCE
460 PRINT "STRIKEOUT" :: OUT=OUT+1 :: RETURN

**REM GROUNDOUT, ALL RUNNERS ADVANCE A BASE

470 PRINT "GROUNDOUT, RUNNERS ADVANCE" 
471 OUT=OUT+1 :: IF OUT>2 THEN RETURN
472 IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
473 IF BBFLG>0 THEN BBBFLG=BBFLG :: BBFLG=0
474 IF BFLG>0 THEN BBFLG=BFLG :: BFLG=0
475 RETURN

**REM GROUNDOUT, RUNNERS ADVANCE IF FORCED

480 PRINT "GROUNDOUT, RUNNERS ADVANCE":"IF FORCED"
481 OUT=OUT+1 :: IF OUT>2 THEN RETURN
482 IF BBBFLG>0 AND BBFLG>0 AND BFLG>0 THEN HPFLG=BBBFLG ::SCO=SCO+1 :: BBBFLG=BBFLG :: BBFLG=BFLG :: BFLG=0 :: RETURN
483 IF BBFLG>0 AND BFLG>0 THEN BBBFLG=BBFLG :: BBFLG=BFLG :: BFLG=0 :: RETURN
484 IF BFLG>0 THEN BBFLG=BFLG :: BFLG=0
485 RETURN

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

490 PRINT "GROUNDOUT, DOUBLE PLAY":"IF RUNNER ON 1ST AND":"LESS THAN 2 OUTS...":"ALL OTHERS ADVANCE";
491 OUT=OUT+1 :: IF OUT>2 THEN RETURN
492 IF BFLG>0 THEN OUT=OUT+1 :: IF OUT>2 THEN RETURN
493 IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
494 IF BBFLG>0 THEN BBBFLG=BBFLG :: BBFLG=0
495 RETURN

**REM SHALLOW FLYOUT.  NO RUNNERS ADVANCE

500 PRINT "SHALLOW FLYOUT":"RUNNERS HOLD";
501 OUT=OUT+1 :: RETURN

**REM DEEP FLYOUT.  ONLY RUNNERS ON 2ND AND 3RD ADVANCE

510 PRINT "DEEP FLYOUT, RUNNERS ON":"SECOND OR THIRD ADVANCE"
511 OUT=OUT+1 :: IF OUT>2 THEN RETURN
512 IF BBBFLG>0 THEN HPFLG=BBBFLG :: SCO=SCO+1 :: BBBFLG=0
513 IF BBFLG>0 THEN BBBFLG=BBFLG :: BBFLG=0
514 RETURN


**REM THIS IS THE "GO THROUGH BATTING ORDER AND DISPLAY BATTER'S NAME" SUB

520 BAP=BAP+1 :: IF BAP>9 THEN BAP=1
530 IF BAP=1 THEN BAP$=B$ ELSE IF BAP=2 THEN BAP$=BB$ ELSE IF BAP=3 THEN BAP$=BBB$ ELSE IF BAP=4 THEN BAP$=SS$
540 IF BAP=5 THEN BAP$=LF$ ELSE IF BAP=6 THEN BAP$=CF$ ELSE IF BAP=7 THEN BAP$=RF$ ELSE IF BAP=8 THEN BAP$=C$
550 IF BAP=9 THEN BAP$=P$
560 RETURN

 

 

Link to comment
Share on other sites

Here is a 3 inning simulation. All runners are accounted for and base-running is clean and accurate.

 

Notice, I load the bases in the second inning, but Rogers Hornsby blows it by popping out to end the inning... Boooooo!!!

 

http://youtu.be/F6ROb1uTOZY

Edited by Opry99er
Link to comment
Share on other sites

So far I have been able to fully simulate a 1 player game... In trying to make it a 2 player game, I have had to expand code quite a bit and it seems like there's quite a bit of duplicate stuff in there...

 

Can someone point me to an XB game which cleverly implements 2 player mode while re-using the vast majority of the code for both players? I'd like to look at it for some ideas. Thanks

Edited by Opry99er
Link to comment
Share on other sites

This might get you going.

 

100 player1=110
110 player2=340

200 x=player1
210 gosub 400
220 player1=x
230 x=player2
240 gosub 400
250 player2=x

300 print player1, player2
310 end

! large chunk of reusable code
400 x=x+100
410 return

 

100 score(1)=110
110 score(2)=340

200 player=1
210 gosub 400
220 player=2
230 gosub 400

300 print score(1), score(2)
310 end

! large chunk of reusable code
400 score(player)=score(player)+100
410 return

 

100 player1=110
110 player2=340

200 call score(player1)
210 call score(player2)

300 print player1, player2
310 end

! large chunk of reusable code
400 sub score(x)
410 x=x+100
420 subend

 

100 player(1)=110
110 player(2)=340

200 for i=1 to 2::call score(player(i))::next i

300 print player(1), player(2)
310 end

! large chunk of reusable code
400 sub score(x)
410 x=x+100
420 subend

 

Using multidimensional arrays could hold many players each with their own set of variables (numbered).

 

player(1,1) could hold score for player one.

player(2,1) would then also hold score but for player two.

player(1,5) could hold penalty for player one.

player(2,5) would then also have to hold penalty but of course for player two.

player(8,5) would be penalty for player eight.

player(12,11) could be stamina for player twelve.

 

(single-dimensional)

player$(1) name of player one.

player$(5) name of player five.

 

or

 

player$(1,0) could be name of team one.

player$(1,1) could be name of player one in team one.

player$(1,2) could be name of player two in team one.

player$(4,3) name of player three in team four.

 

I guess you could also do something like (naming the numbers in the dimension)

 

score=1

penalty=5

stamina=11

player(1,score)

player(2,score)

player(1,penalty)

player(2,penalty)

player(8,penalty)

player(12,stamina)

 

:)

Edited by sometimes99er
Link to comment
Share on other sites

Getting this second player mode going.... For you baseball fans out there, what do you think about the lineups? =)

 

 

 


***REM HOME TEAM
130 P1$="W. JOHNSON"
135 C1$="J. BENCH"
140 B1$="L. GEHRIG"
145 BB1$="R. HORNSBY"
150 BBB1$="E. MATHEWS"
155 SS1$="H. WAGNER"
160 LF1$="T. WILLIAMS"
165 CF1$="J. DIMAGGIO"
170 RF1$="B. RUTH"

***REM AWAY TEAM

175 P2$="NOLAN RYAN"
180 C2$="Y. BERRA"
185 B2$="T. HELTON"
190 BB2$="R. CAREW"
195 BBB2$="A. RODRIGUEZ"
200 SS2$="C. RIPKEN JR."
205 LF2$="B. WILLIAMS"
210 CF2$="P. ROSE"
215 RF2$="M. CUDDYER"


 

 

Link to comment
Share on other sites

Okay guys, critical moment in this development. I've got it 99.999% completed but I'm having just a bit of trouble on one element.

 

The idea is this... I have several arrays going on and several variables which end up getting plugged into the arrays as identifiers of "which team am I modifying."

 

In this little chunk of code, the following variables are being used.

 

TAP (straight variable...."team at plate"... always either 1 or 2)

BO (this is an array, but it can be either BO(1) or BO(2)

BAP ("Batter At Plate"... straight variable which holds the value corresponding to a particular player's position in the lineup....1-9)

 

 

What I'm trying to do is, at the end of a 3 out inning (or half an inning)-- I want to save the BAP value into either BO(1) or BO(2)... That way the program "remembers" who will be up to bat at the start of the next inning. Also, at the end of the 3 outs--- I need to switch load the value contained in BO(1) or BO(2) (depending on which team is up) into the BAP variable. Here's my code.

 


261 IF OUT>2 THEN BO(TAP)=BAP:: IF TAP=1 THEN TAP=2 ELSE IF TAP=2 THEN TAP=1 :: BAP=BO(TAP)

 

In that code, it can be read literally as:

 

"if there's more than two outs then save the Batter at the Plate value into that team's respective BO variable... Then, switch the Team At Plate. THEN, load the pre-saved BO variable containing the last batter who was at the plate for the NEW team up into the Batter At Plate variable... Continue program"

 

 

Does this look screwy to you guys? For some reason, everything works properly except when it DOES switch teams, the BO variable (containing the value for WHICH player is up to bat for the new team) always loads incorrectly.

 

I'm sure it's something simple, but my eyes are tired and I'm probably not thinking straight. Once this is fixed, I have a complete simulation.

Link to comment
Share on other sites

Just be aware that having multiple IF statements on one line will attract suspicion.

 

Splitting it like this means something completely different.

261 IF OUT>2 THEN BO(TAP)=BAP
262 IF TAP=1 THEN TAP=2 ELSE IF TAP=2 THEN TAP=1
263 BAP=BO(TAP)

 

Depending

IF TAP=1 THEN TAP=2 ELSE IF TAP=2 THEN TAP=1

could probably be rewritten as

IF TAP=1 THEN TAP=2 ELSE TAP=1

 

:)

Edited by sometimes99er
Link to comment
Share on other sites

Yea, however everything in that line is predicated on the "IF OUT>2" question... This would be a good candidate for a subprogram I think... I'm going to sit down and restructure the "end of inning" bits and see if moving everything to a separate section re-organizing it might help. Thanks for the suggestions, sometimes. I will revisit it today with fresh eyes. =)

  • Like 1
Link to comment
Share on other sites

IF TAP>0 THEN TAP=3-TAP

 

Just be aware that having multiple IF statements on one line will attract suspicion.

 

Splitting it like this means something completely different.

261 IF OUT>2 THEN BO(TAP)=BAP
262 IF TAP=1 THEN TAP=2 ELSE IF TAP=2 THEN TAP=1
263 BAP=BO(TAP)

 

Depending

IF TAP=1 THEN TAP=2 ELSE IF TAP=2 THEN TAP=1

could probably be rewritten as

IF TAP=1 THEN TAP=2 ELSE TAP=1

 

:)

Link to comment
Share on other sites

260 IF OUT>2 THEN GOSUB 1260
.
.
.
.

1260 INF=INF+1 :: IF INF>2 THEN INF=1 :: INN=INN+1
1261 BO(TAP)=BAP:: IF TAP=1 THEN TAP=2 ELSE TAP=1 :: BAP=BO(TAP)
1262 OUT=0 :: BFLG=0 :: BBFLG=0 :: BBBFLG=0
1270 RETURN

 

Subroutine in place, same problem exists.

 

Here is what is actually happening.... Now that I've had a chance to look at it, I have a better sense of where the little bugger is fouling up. At the start of the program, I define BO(1) and BO(2) both as "1". That way, once the (B)atting (O)rder switches from team 1 to team 2, the value should reset to "1" so that team 2 starts at the beginning of their lineup.

 

What is happening is that when team 1 gets 3 outs and it flips to team 2, the BO for team 1 just moves right along to team 2... So if Team 1 ends their first inning at #7 in the batting order, Team 2 starts their inning at #8, instead of #1 where it should start.

 

I'm getting closer to locating the offending code, but it's just a hair frustrating... this is not a complicated program.

 

Thanks for the suggestions guys--- I'm trying them, but I think my REAL problem lies elsewhere in the code, and I'm not seeing it for what it is. =)

Link to comment
Share on other sites

I find this line a little unclear: 1261 BO(TAP)=BAP:: IF TAP=1 THEN TAP=2 ELSE TAP=1 :: BAP=BO(TAP)

 

Is BAP supposed to change only when TAP <> 1? (ie: part of the ELSE clause?) I would expect you want it to happen in both cases?

 

Break the IF statements up a little more to make the code simpler, that will help you trace the logic in your mind.

 

Link to comment
Share on other sites

Yea, thanks Tursi. =) I had come to a similar conclusion this morning--- break it all down to single statement lines and then rebuild it. And... lo and behold... breaking it down worked. It was the exact line you quoted which had the offense. NOW.... Here's the question. My initial code was:

 


261 IF OUT>2 THEN BO(TAP)=BAP:: IF TAP=1 THEN TAP=2 ELSE IF TAP=2 THEN TAP=1 :: BAP=BO(TAP)

 

so... in this line, the IF THEN ELSE IF piece always returns a "TRUE" because TAP is either 1 or 2. If that is so, wouldn't XB go to the next piece? (BAP=BO(TAP))? I realize that the first part is only true half of the time, but the ELSE in there allows the code to check the next caveat which would be TRUE if the first is FALSE. Why didn't XB go to the next segment?

Edited by Opry99er
Link to comment
Share on other sites

Thanks, Lee... Yea, I just put that into place and it works great. I'm just curious why XB acted that way... Maybe I missed something in the manual...

 

Regardless, XOR is in the code now and won't be coming out. Much obliged for the help, good sir

Link to comment
Share on other sites

Thanks, Lee... Yea, I just put that into place and it works great. I'm just curious why XB acted that way... Maybe I missed something in the manual...

 

Regardless, XOR is in the code now and won't be coming out. Much obliged for the help, good sir

 

You're quite welcome.

 

Re the IF...THEN...ELSE...IF...THEN construct: XB will never execute the end of that statement { BAP=BO(TAP) } unless TAP=2 because it is considered part of the last THEN clause. You could visualize that line like this:

 

IF OUT>2 THEN

{

BO(TAP)=BAP

IF TAP=1 THEN

{

TAP=2

} ELSE

{

IF TAP=2 THEN

{

TAP=1

BAP=BO(TAP)

}

}

}

 

...lee

Link to comment
Share on other sites

Yea... alright, I was thinking in too linear of terms. Learn something new every time I try to slap some code together. =)

 

Hey, if any of you are very familiar with the game of baseball and how the rules work, baserunning, inning advancement, etc... I need a couple folks to run a few 9 inning simulations for me and watch the base running and batting order to make sure the code works...

 

**NEXT STEP:

 

1) Keeping track of in-game statistics... RBI, Hits, HR, etc.

 

I haven't added graphics yet, nor have I optimized the code... Also haven't "weighted" the dice yet for individual players' statistics... Right now I just have the bare-bones baseball rules in place in order to test the mechanics... Anyone interested?

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