Close
0%
0%

10-Liner BASIC Softball

Write a Softball simulation in 10 lines of BASIC code

Similar projects worth following
68 views
0 followers
I decided to try to make a 10-Liner BASIC game for the next BASIC 10Liner Games Contest on Homputerium. It is loosely based on the many computer baseball simulation games I've seen over the years, but more specifically, a game video I saw recently for the old 8-bit Japanese home computer the Sharp MZ-700. Details: https://jimgerrie.blogspot.com/2024/08/softball-for-basic-10-liner-programming.html

I decided to try to make another 10-Liner BASIC game for the next BASIC 10Liner Games Contest on Homputerium. It is loosely based on many computer simulation baseball games I've seen over the years, but more specifically, a game video I saw recently for the old 8-bit Japanese home computer the Sharp MZ-700:

I've been thinking for some time that it would be simple to animate a pitcher batter interaction and the plotting of the movement of runners around the 4 bases of a simple diamond.  I wasn't so sure it could all happen on the same screen though, until I say the MZ game.  That old 8-bit machine isn't all that more functional than an MC-10 in its screen resolution. I also really liked the simple dynamic of different zones in the outfield representing different possibilities for number of bases. The original had 1-4, with two zones for out mapped out along the back fence using numbers. I thought I could save some space by using the pixels of them semigraphics-4 mode of the MC-10, which gives me 1-64 units horizontally.  This is a lot better than the 1-40 units of the text "graphics" being used on the MZ game, and more than twice what I would have if I used the 1-32 horizontal text spaces of the regular MC-10 text screen. I just requires using solid colours instead of numbers.

In the end fitting in a diamond and a side bar for the pitcher and batter interaction on the right meant I could only fit in 1,2 and 4 zones for number of bases and two zones for outs. The MZ game also had four positions in the inner outfield for outs. I used Red for the zones causing an out, and a then the colors corresponding to the values 1,2,4 (offset slightly) to save my program doing some conversion between sensing the color the ball is travelling through and the number of bases achieved.

The MZ game doesn't actually recreate a baseball/softball game. There is something else going on about points for hits.  I can't really tell.  My son knows Japanese so maybe I'll try to locate the article for the type-in magazines with the game and see what he can make of it.  But I thought I could recreate the rules of a simple softball match, which I remember from school, including grad school recreational teams I played on. The balls just track within the diamond.  There are no out of bounds.  This would be too complex for a 10-Liner.

The game basically is a reaction game where you try to time your key press to activate the bat at the same time that the ball is crossing directly to the right of the player.  If you make a hit, a random trajectory from a slightly random starting point at the bottom apex of the diamond heads up screen. If the pixel track hits anything besides green, a number of bases are won, or the ball is out if it hits red.  Once I had the graphics for diamond and pitcher and batter printed, and the animation for the pitch and the swing done, then there is just some simple calculations of runs and misses until 3 outs has happened. Then a shift is made to the other team and it is all done again. Repeat until 9 innings are completed, then END with a report of the two scores.

To achieve this in 10 lines requires all the techniques I've developed over the years.  The most important are using ON -(logical test) GOTO line num, line, line num as a kind of 8-bit replacement CASE SELECT IF/ELSE commands.  The other "biggy" is using Boolean logical operators directly in calculation to help omit using IF/THEN statements for conditional calculations.  Then its just the simple techniques-- single letter variables, reusing variables/scratch variables, removing spaces, etc.

The code can be found on my Github here:

https://github.com/jggames/trs80mc10/tree/master/quicktype/Strategy%20%26%20Simulation/Softball

But I'll include the current version here:

0 J=3.5:K=1:B$="*":C$=" ":C=40+RND(10):?"ßßßßßß¿¿¿ÏÏÏ¿¿¿ßßßßßß","ßß߯¯¯¿¿¿ÏÏÏ¿¿¿¯¯¯ßßß","ŸŸŸ¯¯¯¯¯¯ŸŸŸ",
...
Read more »

  • 1 × TRS-80 Micro Color Computer (MC-10) An 8-Bit home computer from the early 1980s. Low cost entry level computer similar to the Sinclair ZX-80. Orphaned after only a year of production
  • 1 × James (the Animal) Tamer's Virtual MC-10 emulator (VMC10) A common emulator for the system.
  • 1 × Microsoft Micro Color BASIC Apparently one of the versions worked on by Bill Gates himself.

  • 1
    How to play the current version yourself

    This is a modern homebrew game for the TRS-80 Micro Color Computer ("MC-10") using Micro Color BASIC. It is a softball simulation written in 10 lines of BASIC code.  The latest version can be played online using "emularity" at the Internet Archive: https://archive.org/details/softball_202407

    HOW TO PLAY
    Launch the emulation and wait until you see the green screen with just an "S" in the upper left corner, press Scroll Lock and then press F2. This will load the tape. After the tape finishes loading press Scroll Lock again and then type RUN and hit Enter.


    SOME USEFUL KEYS
    ]  Break
    Left Shift A Backspace
    AWSD or AWSZ or IJKL typically for Arrow keys
    Right Shift ; +
    = -
    Right Shift 2 "

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates