Tuesday, 19 January 2016

January 2016 Retrochallenge 8: New 10-Liner Puzzle Game "Dash"



Puzzle-- Finished
Dave Maunder (Bushy555), a member of the Yahoo MC-10 group and an avid user of the VZ200/300 posted that there is an up-coming 10-Liner Basic game programming contest being hosted by the Retrocomputing site Homputerium and posted on Vintage is the New Old. I decided to give it a try, so I dredged up an old project based on a video I saw on YouTube for a text based game written in C++ called "Dash." It is a version of the classic game "Boulder Dash." The use of text graphics inspired me to try to recreate the boulder rolling mechanics on the MC-10. Obviously, Basic is not as fast as C++, but with some tight coding and a limited number of boulders it might be doable. But could it be done in 10-Lines?

I think the answer is yes. The program I have created is 2 parts puzzle game, one part quick reflex arcade game. Well, one part might be pushing it. It's not super fast, but occasionally good timing will be critical to solving the randomly created puzzles, because the boulders do move and are erratic unless blocked in or wedged against each other.

The game mechanic is simple. Boulders fall when there is green space beneath them. They roll randomly from side to side if there is green space on either side of them. They won't crush you if they are next to you or right above you. The only way they can crush you is if they tip off something (have green on either side) and then roll into you. In other words if you are the X and boulders are @s then:

  @
X █

is a very dangerous position to be in. I think of it as the boulder rolling down off something and then on into you. Normally, as a confident miner, you can easily handle boulders, using bracing to keep them above you or temporarily wedging them in place when they are next to you, or blocking them if they are on level ground rolling toward you. But if they roll off something and then immediately head towards you, you're doomed.

Obviously, to solve the puzzle you must also not become blocked in by boulders, so you must be careful where you mine and be wary of how avalanches will occur so as not to hinder your movement to the exit (symbolized by a reverse "I"). It might also be necessary to create avalanches in specific ways to effectively clear the way. That being said, the puzzles are random so sometimes there will be no way to exit, or you might be trapped from the beginning. If that is the case just hold down Ctrl-J (Junk the maze/puzzle) to get a new puzzle.

Also, if you hold down Ctrl-D (Do-over) before exiting the maze, the maze will be redrawn in its initial starting layout, and you can try again. In fact, I found this feature useful when playing the game with my son. The first person tries the maze and gets to a point before exiting but having gathered as many of the treasures ("*" symbols) that are also scattered throughout the maze as possible, and then hits Ctrl-D. The score achieved to that point is reported and the maze is redrawn in its starting condition. Then the other player can try to get a better score. We found it interesting for the person waiting for their try to sit away from the screen so they couldn't see the mistakes being made by the other player, so each player gets a fair try at solving it on their own.  Then the scores can be compared and a new maze created.

The game starts with a level prompt. This simply determines how many immovable ("") wall blocks get scattered around. It also influences the scoring. You get a number of points equal to the level for every treasure ("*") that you collect. I found that 20 is a good starting number. Numbers below that might be useful for young kids, and much above, that starkly increase the number of unsolvable puzzles that are generated.

Here's a video demo:

The source code can be found here:
https://github.com/jggames/trs80mc10/tree/master/quicktype/Puzzle/Dash
It can be run by quicktyping the text file into the VMC-10 Emulator.

Addendum
One of the little annoyances I have with the current code is that it is too tightly packed to add a random number seed feature. If you load from a cold start the game will always proceed through a set sequence of pseudo random mazes. However, my son Charlie and I were able to overcome this by typing in a command like this:
PRINT RND(some number)
to reseed the pseudo random number to something less predictable than the last number called by the RND function. However, in Color Basic if you use a negative number in the RND function, the pseudo random number generator gets set to begin at that specific number, so that you can repeat specific desired sequences. So typing something like:
PRINT RND(-17026) 
will generate a specific puzzle (in this case one with a blocked exit). Try it! Using this method people could in principle "discover" and keep track of unique puzzles that they find particularly challenging. Also, of course, you will have to choose the same Level for the exact puzzle to be regenerated so for puzzle (-17026) use level 20 to see the blocked exit.

No comments:

Post a Comment