Topics

► Games

► Sound & Music

► Watches & Clocks

► GPS

► Power Supplies

► Computers

► Graphics

► Thermometers

► Wearables

► Test Equipment

► Tutorials

► Libraries

► PCB-Based Projects

By processor

AVR ATtiny

► ATtiny10

► ATtiny2313

► ATtiny84

► ATtiny841

► ATtiny85

► ATtiny861

► ATtiny88

AVR ATmega

► ATmega328

► ATmega1284

AVR 0-series and 1-series

► ATmega4809

► ATtiny1604

► ATtiny1614

► ATtiny3216

► ATtiny3227

► ATtiny402

► ATtiny404

► ATtiny414

► ATtiny814

AVR DA/DB-series

► AVR128DA28

► AVR128DA32

► AVR128DA48

► AVR128DB28

ARM

► ATSAMD21

► RP2040

► RA4M1

About me

  • About me
  • Twitter
  • Mastodon

Feeds

RSS feed

Harder Number Maze Game

14th February 2023

This is an update to my Number Maze Game based on suggestions I received from users of the first version. It adds a set of more difficult mazes that are based on different rules, and training levels that introduce you to the new rules.

NumberMazeHard.jpg

The updated Number Maze Game, incorporating additional symbols that define new harder levels.

Introduction

The original version of the Number Maze Game used the symbols 0, 1, 2, and 3.

This upgrade to the program extends the puzzle by introducing new symbols that extend the possibilities, and allow for much harder mazes.

Symbols

Here's a summary of the full set of symbols:

Symbol Name Meaning
LEDs123.gif 1, 2, 3 Jump 1, 2, or 3 squares.
LEDs0.gif 0 You can't move.
LEDsEqual.gif Equals * The same as your previous jump.
LEDsUp.gif Up-arrow * Increase the size of your jump by 1.
LEDsDown.gif Down-arrow * Decrease the size of your jump by 1.
LEDsHome.gif Home Your goal.

The three new symbols marked * make the mazes substantially harder, because your options on each square depend not just on the number on that square, but also the current size of your jumps. In the easier mazes there would be no point in moving to a square you had already visited, because the options would be the same as they were last time. However, in the mazes that use these new symbols it may be necessary to visit a square up to three times to solve the maze.

For example, the longest maze using just the original symbols 0, 1, 2, and 3 is 11 steps, whereas the longest maze with the new symbols is 18 steps.

Moving to the next maze

When you have completed a maze by reaching the Home square, press the right-arrow button to move to the next level.

Alternatively pressing the left-arrow button resets the game back to the first maze.

Undo

As in the earlier game it's possible to get stuck, either by being unable to move, or by being stuck in a loop with no way to exit. In this case keeping any button held down acts as undo, successively stepping you back through your previous positions in the maze.

The circuit

The circuit is unchanged from the original Number Maze Game; see Number Maze Game - Circuit.

The program

The program has been updated with the following new features:

Mazes

There are now 36 mazes, in 12 groups of four mazes in each group. Each group of mazes introduces a new symbol, or changes the selection of symbols available.

For example, here is a section of the mazes[][] array showing the last group of four mazes, including the one shown in the above photograph:

char mazes[TotalMazes][17] = {
....
  // Uses all symbols
  "2v111^v1^2H^221^", // 12 14
  "^1vvvv^^3^H=^v==", // 15 17 
  "2vv=1=v1=^=22==H", // 15 18
  "3vv1^^=vv2=0133H", // 18 18
};

As the new symbols are introduced, there is now often an easier training level at the start of each new group of mazes to demonstrate how the new symbol works, so it should soon become obvious what effect the new symbol has on how you can move.

Symbol values

In addition to the symbol[] and segment[] arrays used previously, a new value[] array is now used to define the behaviour of each symbol in the maze:

char symbol[]     = { '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',  '8',  '9',
                      '=',  '^',  'v',  ' ',  'A',  'E',  'H',  'L',  'n',  'o',
                      'P',  'Y'  };
uint8_t segment[] = { 0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x7b,
                      0x09, 0x62, 0x1c, 0x00, 0x77, 0x4f, 0x37, 0x0e, 0x15, 0x1d,
                      0x67, 0x3b };
uint8_t value[]   = { 0,    1,    2,    3,    4,    5,    6,    7,    8,    9,
                      64+0, 64+1, 64-1, 0,    0,    0,    0,    0,    0,    0,
                      0,    0 };

A number from 0 to 9 specifies an absolute jump length, and an offset from 64 specifies a relative change in jump length.

A new routine Jump() calculates the new size of jump from the square the player is currently on:

int Jump (uint8_t jumpsize, int direction) {
  char cell = mazes[Maze][Player];
  int jump = value[strchr(symbol, cell) - symbol];
  if (jump >= 63) jump = jumpsize + (jump - 64)*direction;
  return jump;
}

The second parameter, direction, is used by the Undo feature.

Resources

Here's the program for the updated game: Harder Number Maze Game Program.

Or get it together with the Eagle files for the PCB here: https://github.com/technoblogy/number-maze-game.


blog comments powered by Disqus