Jump to content

Photo

"Laser Strike" COMPUTE! Magazine program conversion

COMPUTE!

13 replies to this topic

#1 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Thu Mar 15, 2018 10:04 AM

As with Tiles, Laser Strike is another COMPUTE! Magazine type-in program published after the magazine dropped the TI-99/4A, and is another program for which I received permission to sell and distribute my conversion for the TI-99/4A.

 

Laser Strike appears in COMPUTE! Magazine Issue 79, December 1986, Pp. 44-62.  Article  text here .

 

""Laser Strike" is a strategy game based on several popular board games (Battleship is probably the most famous). However, unlike the board games, the action in Laser Strike occurs in outer space. Two players secretly deploy their spaceships around the galaxy and then try to locate the opponent's ships by firing laser strikes on the two-dimensional galaxy grid. The first player to find and destroy all the opponent's ships is the winner."

 

This post contains my 1988 versions.  The first version has a rather simple A.I., which pokes around the board then follows a very simple search around looking for other parts of a hit ship.  The second version has a very sinister A.I. which immediately knows where the rest of a ship is on the grid once it finds one.  A computer player is created with a blank player name (just press ENTER when prompted for the player's name.)

 

Attached File  LaserStrike.png   2.18KB   5 downloads

 

Over the next few months I will be working on cleaning and modernizing this program as I did with Tiles.  A TidBit source, revamped over the ill-advised GCHAR method I use to build the "grids," including a more clandestine placing of computer player ships, and potentially a two-computer player-vs-player system via serial.

 

The listings below contain CTRL characters which do not translate to text.

 

TI BASIC Listing: LASERSTRIK

Spoiler

 

TI BASIC Listing: LASERSTRK+ (sinister A.I.)

Spoiler

Attached Files



#2 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Thu Mar 15, 2018 6:32 PM

:lol:  I just noticed the last two lines of each program is a simple memory sizer for TI BASIC.  An old trick I picked up from a newsletter which came from some magazine.  If you RUN 288 or RUN 330 the variable AP will increase by 8 until the stack fills up with entries from the following GOSUB.  Then PRINT AP and you will get the number of available bytes: 2248 for the first version, 1440 for the second.

 

Attached File  laser_memory.png   2.23KB   2 downloads



#3 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,098 posts
  • Location:Eagan, MN, USA

Posted Fri Mar 16, 2018 4:53 AM

Cool trick!



#4 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Fri Mar 16, 2018 4:28 PM

For comparison:

 

Attached File  memory.png   2.2KB   1 downloads



#5 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Tue Mar 27, 2018 10:47 PM

Here is a Tidbit snippet showing the ridiculous ways I tend to get complex trying to avoid redundant or repeating sections, IF-THENs, and branches.  This shit is what drives me nuts writing programs and why I could not do this professionally as I obsess and agonize over a short section for hours or days.
 

FOR Y=R+(5-I)*(J=4) TO R-(5-I)*(J=3)         // Check horizontal spacing
IF (Y<1)+(Y>10)+G(P,ABS(Y),C) THEN DeployError      // ABS() fixes negative subscript during OR operation
NEXT Y
FOR X=C+(5-I)*(J=1) TO C-(5-I)*(J=2)         // Check vertical spacing
IF (X<1)+(X>10)+G(P,R,ABS(X)) THEN DeployError      // ABS() fixes negative subscript during OR operation
NEXT X
CALL VCHAR(8+R+(5-I)*(J=4),C-10+14*P,104+8*I,(I-6)*(J>2))
CALL HCHAR(8+R,C+(5-I)*(J=1)-10+14*P,104+8*I,(I-6)*(J<3))

The most painful discovery and wrench in my progress was that FOR-NEXT-STEP does not accept "0" as a STEP.  Makes perfect sense but I was thinking a zero STEP would just cause the loop to be skipped.  There are other sections which are vexing me but I am breaking them up.  I have added a couple of "features" which have made things a little more complex, but I have also removed some things which have made program, like that above, less complex.  One removed feature of my conversion is the ability to lay a ship in any direction from the marker, whereas the original game only let you lay it RIGHT or DOWN, both positive directions.

 

That HCHAR and VCHAR will put out nothing if the repeat value is zero meant I could try to plot in both directions without using an IF-THEN statement and the execution penalty was negligible for this section.  Ultimately a wiser decision was made and this trick, while really cool, is no longer used.



#6 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Tue Mar 27, 2018 11:16 PM

Here is something REALLY weird I ran into tonight testing the "AI" for deploying computer ships in Classic99.  This section of program:

 

DeployComputerShip: 
   RANDOMIZE
   R=INT(RND*10)+1
   C=INT(RND*10)+1
   ON INT(RND*2)+1 GOSUB DeployXCheck,DeployYCheck
   IF G(P,R,C)<>I THEN DeployComputerShip ELSE DeployNextShip

 

without the RANDOMIZE statement produces the EXACT SAME results for both computer players -- that is, both player's ships are laid in exactly the same positions -- every time the program is run.  There is a RANDOMIZE statement earlier in the program in the execution path so I do not expect this behavior.

 

I have no idea if this behaves the same way on metal. What gives?



#7 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Mon Apr 2, 2018 10:11 PM

All parts of game setup and play are completed including the introduction marquee.  All that remains is the AI and I will be done, much to relief of those around me as my time and thoughts are consumed with this project.

 

I have had a revelation while reworking this program: I am tired of TI BASIC.  When I originally wrote these programs all I had was a console and a tape drive.  Thus such configuration was my target audience should these ever be published.  It was also a challenge to do some of the stuff these more advanced BASICs of other computers could do.  Now, however, Extended BASIC makes the limitations of BASIC just plain aggravating, and that is notwithstanding assembly language.

 

I have four more programs which need to be redone, all of them originally written in TI BASIC and one of which took advantage of capabilities offered by MiniMemory in BASIC with an alternate version which also leveraged some assembly routines.

 

I have not yet decided if I will rework them all in TI BASIC or Extended BASIC.  The idea originally was to make them as "type-in friendly" as possible.  I would still like to meet that if only for nostalgia, otherwise right now TI BASIC is not fun to me; it is frustrating and I am getting to the point where I never want to fire up BASIC, again.

 

If you want to see how it looks right now without the AI -- any computer player will fall through to human player -- see below.  I believe it works exactly as desired as a two-player game in its current form.  It can be pasted into Classic99.  EXSD for Player 1, IMJK for Player 2, SPACE for both, joysticks work, too.  Ships will be deployed onto your opponent's grid.  That is, Player 1 deploys onto GRID 2, and vice-versa.  When deploying the "plus" mark indicates to select a direction, right or down.

 

Spoiler


#8 Opry99er ONLINE  

Opry99er

    Quadrunner

  • 9,277 posts
  • Location:Hustisford, WI

Posted Mon Apr 2, 2018 10:22 PM

Awesome stuff there, broseph...  I am very much enjoying observing this process.  :)

 

 

But don't give up on console BASIC so easily... There is untapped potential there, and you've obviously got the knack for it (especially now with TIdBiT in the toolbelt)



#9 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Tue Apr 3, 2018 8:02 AM

I definitely agree that my frustration level would be over 9000 right now were it not for Tidbit.

 

Here are some screen shots from play, me versus myself as the computer player

 

Attached File  LaserStrike-new(a).png   2.39KB   1 downloadsAttached File  LaserStrike-new(b).png   2.41KB   1 downloadsAttached File  LaserStrike-new(c).png   2.69KB   1 downloadsAttached File  LaserStrike-new(d).png   2.73KB   1 downloads



#10 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Wed Apr 4, 2018 8:24 PM

Working up an AI for this, I found some really neat articles on algorithms for playing Battle Ship.  I have been working up a flow chart (ick!) to build my own AI and resisting the urge to just copy the one used in the original game.

 

Once I release the final version I will include some of the articles I found, whether I implement any of them or not it still makes for interesting reading.



#11 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,098 posts
  • Location:Eagan, MN, USA

Posted Thu Apr 5, 2018 11:40 AM

Quick and dirty algorithm:

1- Random shots until hit recorded. Set hit flag.
2- systematic test of the 4 cardinal directions for additional hits unless bounded by edge or previous shots.
3- Follow cardinal direction where hit recorded. If sunk, then clear hit flag and go to 1. If hit go to 3. If no hit then reverse cardinal direction starting with initial hit and go back to 3.

This obviously can be refined further by pre-scanning the grid and creating a list of all possible locations where a particular target could be residing, sorted by ship size. Not terribly helpful until about 50% of the grid has been shot at. It's slow but will make the AI extremely deadly...

#12 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Thu Apr 5, 2018 12:08 PM

Essentially my flow chart goes like this:

 

Check for any ships with hits and parts remaining

Check spacing in all four directions

If only one part has been hit:

Is there a miss adjacent?

Does the ship fit in one direction versus another?

Try the best possible direction, or pick one if more than one.

If multiple parts have been hit:

Is it horizontal or vertical?

Check spacing in both directions

Fire at best possible spot.

 

Otherwise, look at four quadrants

Choose quadrant with most empty space (percentage-wise) less hit ship parts

Choose random spot in selected quadrant

check spacing: is it within space of longest remaining ship?

Fire at best possible or random spot if no best spot, giving space for shortest remaining ship.

 

I want the AI to be a moderately capable opponent.  I am considering using the other player's "score" to determine how analytical the AI becomes.

 

In my original iterations the AI could lose its place on a ship after determining its location by poking around randomly.  The second version automatically knows where the rest of a ship is when it first finds it (cheats in that regard, but the initial find is also random.)



#13 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Thu Apr 5, 2018 7:48 PM

AI aside, hearkening back to the use of complex formulas, the question becomes is performance more greatly impacted by using a formula like C+32+14*P or an array like C+GX(P).

 

For something that small (number added to number times variable) it may not make a difference, but what about C+14*P-10-42*(P<0) where you are expecting values P={-2,-1,1,2}, but you still have to reference the array by taking a variable and adding a number.  Thus, GX(P+3) to return GX({1,2,4,5}).  I would assume the act of "variable plus number times variable minus number minus variable compared to number times number," noting the parenthesis has to be interpreted for precedence order, would take longer than "array lookup of element variable plus number."

 

Just more to obsess.  I have memory available to set up some arrays for the longer formulas so that is not a concern.



#14 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • Topic Starter
  • 4,898 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Thu Apr 5, 2018 9:46 PM

Another thing I learned while working on Tiles is not everything runs the same in emulation and on the metal.  I played this a little tonight on a real console and am very pleased with the results, in particular the sounds.  BASIC is very difficult to get just the right sounds.  Partly because when the 9919 gets a new noise command it restarts the noise generator.







Also tagged with one or more of these keywords: COMPUTE!

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users