basic-computer-games icon indicating copy to clipboard operation
basic-computer-games copied to clipboard

12 BombsAway java version always asks for gunner hit rate

Open havoclad opened this issue 4 years ago • 11 comments

To reproduce

  1. java BombsAwayGame
  2. What side - 1
  3. Target - 1
  4. Missions - 1
  5. What does the enemy have - 2

The response is "What's the percent rate of enemy gunners (10 to 50)?" This should only happen for choices 1 and 3, compare to the basic, javascript or perl versions.

Screen Shot 2022-01-07 at 9 47 01 PM

havoclad avatar Jan 08 '22 03:01 havoclad

aha did we contact the person who submitted the pull request?

coding-horror avatar Jan 08 '22 04:01 coding-horror

git log --follow suggests that @journich might be the author of BombsAway.java

havoclad avatar Jan 08 '22 04:01 havoclad

Thanks for reporting this @havoclad - I have uploaded a fix for this and for some missing functionality from the original game. Please test and let me know if you have any other problems. @coding-horror FYI.

journich avatar Jan 08 '22 07:01 journich

This bug is fixed, thanks! Thanks for supporting code your wrote almost a year ago @journich

However, I think there is another inconsistency in the damage calculation. I noticed I wasn't getting shot down nearly often enough when selecting choice 3 (both) and looked at the code.

Lines 289 case GUNS: is commented that it's identical code to case BOTH. This is incorrect. Case BOTH should apply chanceToBeHit as well as percentageHitRateOfCunners while case GUNS should only apply the latter.

These are analogous to T and S in the original basic code.

Line 350 runs the percent hit rate code unless choice 2 is made while line 360 applies the extra 35 if the choice is greater than one.

havoclad avatar Jan 08 '22 17:01 havoclad

Thanks @havoclad - I totally missed that and the fix is in place now. Please take a look. In my testing I certainly get shot down a lot more when selecting BOTH, although it is still possible to succeed.

What BASIC interpreter are you using to test? I am using Chipmunk BASIC on a Mac with Apple Silicon and the very first time I play a game from scratch I always get a direct hit, but when I select Y to play again it seems to function normally.

journich avatar Jan 08 '22 20:01 journich

I'm using Vintage Basic

havoclad avatar Jan 08 '22 22:01 havoclad

That's another open question, what's the "official" way to verify the original BASIC code behavor? 🤔

Would be nice if we had a web-based VM for this

coding-horror avatar Jan 08 '22 23:01 coding-horror

This book also has a bug in this program which bombsaway.bas in this repo does not. I wonder when it was addressed?

It wasn't fixed in the way I did back in '79 or so. I remember because it was the first time I found a bug in something published, lol.

https://annarchive.com/files/Basic_Computer_Games_Microcomputer_Edition.pdf has the version I remember.

207 IF F$="N" THEN S=0 : GOTO 358

There is no 358 :) It seems obvious to me that GOTO 357 was meant, after all. To get to line 207 the user just claimed that he or she was not on their first kamikaze mission. Setting S to 0 right before the GOTO clinches it, it should go to 357 with the great line, "YOU LIE, BUT YOU'LL PAY..."

havoclad avatar Jan 09 '22 01:01 havoclad

Thanks @havoclad I'll give Vintage Basic a go and see how it turns out.

I can't answer that question about the bug being fixed. It would be good to know for sure which original version of the code we are using to create our ports of the game.

Maybe the bugfixes got fixed in a reprint of the book?

journich avatar Jan 09 '22 03:01 journich

That's another open question, what's the "official" way to verify the original BASIC code behavor? 🤔

Would be nice if we had a web-based VM for this

@coding-horror I had a little hunt for a web-based VM but the ones I played around with had problems with multiple statements on the one line and the use of TAB to add spaces to output.

i.e.

PRINT "TRY AGAIN..." : GOTO 10

and

PRINT TAB(26);"ACEY DUCEY CARD GAME"

journich avatar Jan 09 '22 04:01 journich

Closing this one as I believe the bug is fixed. Let me know @havoclad if you have any other issues.

Thanks for your help in finding the bugs and testing.

journich avatar Jan 12 '22 01:01 journich