DT

Maze Game

Github Repo

Background & Motivation

This project was completed as a part of a semester-long project for my CSCI 301 Software Development course at William & Mary. The project is split into two parts, one implemented for desktop use and the other for an Android app. Both parts were coded in Java and thorougly documented through Github with periodic tags. Below, the two parts of the project are explained separately with details outlining the different aspects of the game.

Introduction

In order to run the desktop version, you must have the Java Development Kit (JDK) Version 1.8 installed on your device. Below is the command to run the program after compiling it. Notice, there are 4 optional parameters which can be provided in any combination.

  • f: load in a maze from a predefined file

  • g: maze generation algorithm

    Choose from: Prim, Eller, or none (defaults to a randomized DFS algorithm)

  • d: robot driver (for automated play)

    Choose from: Wizard, WallFollower, Manual, or none (defaults to Manual)

  • r: reliability of sensors (unreliable sensors will prevent automated drivers from sensing in the given directions)

    Sensor directions: Forward (f), Left (l), Right (r), Backward (b). Enter 1 for reliable and 0 for unreliable

javagui.MazeByDukeTran[-f file][-g algorithm][-d driver][-r flrb]

Gameplay

The maze gameplay revolves around you controlling a robot in first-person to navigate through a maze. You have the option to modify the gameplay by entering flags when running the program through the command line. Before maze generation, you need to select a difficulty level (ranging from 0-9, then a-f) from the main menu. The user interface of the game is designed to aid you through the provision of a compass and a map (when facing a dead-end). The background colors also fade to gold on the top half of the screen and green on the bottom (the colors of my alma mater, William & Mary) as you get closer to the exit.

maze1 video

javagui.MazeByDukeTran

Maze Generation

As mentioned previously, the maze generation algorithms implemented include Prim, Eller, or a randomized DFS algorithm. For our project, the Prim and DFS algorithms were implemented out of the box. We were tasked with implementing the Eller algorithm. To learn more about these algorithms, here is a good resource. For demonstration purposes, all 3 of the maze runs below were done at skill level 4.

maze2 video

javagui.MazeByDukeTran-g Prim-d Wizard

maze3 video

javagui.MazeByDukeTran-g Eller-d Wizard

Robot Driver

You may have noticed on the previous slide that the commands contained the d flag followed by Wizard. This flag specifies the type of robot that the game will use. The Manual robot allows you to control it and play the game yourself. The Wizard contains and internal representation of the maze and therefore knows the direct path to the exit. The WallFollower is a basic naive (brute-force) robot that follows the left wall until it reaches the exit. You will notice the WallFollower below solves the maze extremely slowly (even when the maze is on difficulty level 0) since it needs to sense in all four directions after each move to make a decision on where to go next.

maze4 video

javagui.MazeByDukeTran-g Eller-d WallFollower

Sensor Reliability

The r flag controls the reliability of the robot's sensors. This setting only affects the WallFollower, since the Wizard knows the path to the exit and therefore does not need to make use of sensors, and the Manual driver is controlled by you (and you don't have access to the sensors nor do you need them since you can see the maze and its walls). In the gameplay below, you'll notice the robot twitching/fidgeting at some points since the sensors in those directions are unreliable (and therefore nonoperational at times), so it'll need to use its other operational sensors to sense in that direction.

maze5 video

javagui.MazeByDukeTran-g Prim-d WallFollower-r 1010

Introduction

In order to run the Android version, you must have the Java Development Kit (JDK) Version 1.8 installed on your device. You can compile the project using Android Studio and emulate the game with an Android SDK of at least version 29.

Many of the command line parameters from the desktop version are adjustable within the game straight from the main menu. For example, the maze generation algorithm can be selected before beginning the game. The feature to load in a predefined file is implemented to load in the maze generated from the previous playthrough of the game.

Gameplay

The maze gameplay is pretty much the exact same as the desktop version. In this version, you also have the ability to jump by pressing the button at the bottom left of the maze screen. Before maze generation, you can set the maze generation algorithm and the difficulty level from the main menu by sliding the crossed swords. You also have the option to modify the gameplay (changing the driver and sensor reliability) before entering the maze. If you need a little help to beat a maze, there are options in the menu at the top left of the maze screen to toggle the map, solution, and maze walls. The background color also fades to a brighter blue on the top half of the screen as you get closer to the exit.

amaze1 android video

Automated Gameplay

Similar to the desktop version, you can choose to play using an automated robot driver. The options are still the same with Wizard and WallFollower. As for sensor reliability, there are 4 choices you can choose from, ranging from most reliable to most unreliable: Demigod, Warrior, Captain, Soldier. The Demigod's sensors will never fail. One of the Warrior's sensors will periodically fail, as will two of the Captain's. All four of the Soldier's sensors are susceptible to failing. You also have the options to start/stop the animation, adjust the animation speed, and view the operational status of the sensors.

amaze2 android video
amaze3 android video

Revisiting a Maze

The Android version re-implements the desktop version's feature to load in a maze in a slightly different way. Instead of storing the maze generation data, it stores the seed used to generate the maze within the Android device's local storage. If you want to revisit a previously generated maze, change the generation settings to match that of a previous maze and then click the Revisit button. This will fetch the previous seed that matches the same settings and use it to re-generate the maze.

amaze4 android video