Difference between revisions of "F21: Space Rage"

From Embedded Systems Learning Academy
Jump to: navigation, search
(AI)
(AI)
Line 313: Line 313:
 
For our purposes, the simplest of computer difficulties basically plays without knowledge of the opponent's actions. This results in a very easy to trap opponent.  
 
For our purposes, the simplest of computer difficulties basically plays without knowledge of the opponent's actions. This results in a very easy to trap opponent.  
 
Once we added in more knowledge for the AI, a viscous attack strategy was able to be formulated and the bot then took on the elements of a state machine. The initial part of the attack involved getting to the opposite bottom corner as fast as possible, going right down the middle of the screen making humanly impossible turns. Once the bot reached a close enough location to the other player, it would then decide (almost randomly, the algorithm is a bit complex) to either:
 
Once we added in more knowledge for the AI, a viscous attack strategy was able to be formulated and the bot then took on the elements of a state machine. The initial part of the attack involved getting to the opposite bottom corner as fast as possible, going right down the middle of the screen making humanly impossible turns. Once the bot reached a close enough location to the other player, it would then decide (almost randomly, the algorithm is a bit complex) to either:
Go to the section of the screen the other player was not in and play a survival game, one a human is likely to lose.
+
*Go to the section of the screen the other player was not in and play a survival game, one a human is likely to lose.
Or join the player in the section and attempt to survive.
+
*Or join the player in the section and attempt to survive.
 
The original intention was to force the bot to take the first option every time, but due the suggestion algorithm not responding exactly as intended, the bot can do either option listed previously. This bug actually made the experience more enjoyable and gave some variance to the bot's play style. The main take away from this section should be that not every not fatal bug can actually be a benefit to a gaming experince.
 
The original intention was to force the bot to take the first option every time, but due the suggestion algorithm not responding exactly as intended, the bot can do either option listed previously. This bug actually made the experience more enjoyable and gave some variance to the bot's play style. The main take away from this section should be that not every not fatal bug can actually be a benefit to a gaming experince.
  

Revision as of 23:16, 14 December 2021

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Project Title

Space Rage

Abstract

Space Rage was modeled off of the Tron Light Cycle game, in which two players, attempt to have the opponent run into their trail that is left behind as they move. It is similar to Snake, but the trail left behind is not dependent on any pickups and it is competitive. The players are able to move in the cardinal directions, North, East, South, and West, and are not able to steer directly behind them to prevent instant defeat.

There are two levels of AI a player make compete against: Normal and Hard. The difficult of the AI is dependent on which controller the player is using: Player 1 faces the Normal computer while Player 2 faces the Hard computer. The selection of game type is done from the main screen that shows 1 Player or 2 Player. After the selection, the players are free to choose normal mode or turbo. Turbo mode allows for the pressing of the button on the controller to allow the player to move faster.

The display is a 64 by 64 LED matrix. The player controls their ship by using the joystick and button in the controller. The button located on controller allows the user to select options from the main menu and go turbo mode while in that game mode. There are four speakers for the cabinet: two to play music on either side, one for sound effects related to player one, and one for sound effects related to player two. The volume of the speakers is controlled by a touch sensor that is attached to conductive tape which is attached to the side of the cabinet.

Objectives & Introduction

Show list of your objectives. This section includes the high level details of your project. You can write about the various sensors or peripherals you used to get your project completed.

There were a few key objectives and features we wanted to implement into our game to make it feel more like an arcade game:

  • Single Player and Two Player modes
  • Sound and Music
  • Fast responsive controls
  • High activity and quick rounds


Player Modes

The biggest highlight of the game is the two player aspect of the game, allowing you and a friend to play against each other in the game. Each player can use a one of the controllers attached by a CAT5e cable to the main cabinet. There is also a single player mode that allows a player to play an AI driven computer opponent. The difficulty of the computer depends on which player port the player is connected to. This is a nod to old Atari games that had different settings depending on which controller port the user plugged the controller into.

Sound and Music
Fast responsive controls

//talk about the joystick we used and the button

High activity and quick rounds

We tried to maximize the game space for the game with the limitation of having such a small screen, the 64 x 64 LED matrix. To accommodate this we elected to have small characters, just 2x3 pixels wide, which allowed for a much larger game space. The game does still run at a fast rate, leading to the short quick rounds we intended. We decided on a lives based system for the game, so players have 3 lives before they have truly lost a game. We decided to show this information between rounds, again maximizing the space and giving a slight pause to the action.

Team Members & Responsibilities

Jbeardphoto.jpg

Jonathan tran self pic.jpeg

  • Jonathan Tran Gitlab
    • LED Matrix Interface
  • Devin Alexander
    • Lead construction and design
    • PCB designer
    • Music and sound

Schedule

Week# Start Date End Date Task Status
1
  • 10/12/2021
  • 10/13/2021
  • 10/18/2021
  • 10/13/2021
  • Read previous projects, gather information and discuss among the group members
  • Create GitLab repository for project
  • Completed
  • Completed
2
  • 10/19/2021
  • 10/18/2021
  • 10/20/2021
  • 10/24/2021
  • Order LED Matrix
  • Order Joystick, buttons, mp3 decoder
  • Completed
  • Completed
3
  • 10/24/2021
  • 10/30/2021
  • Read and familiarize with LED Matrix Datasheet
    • Light a few pixels
  • Read and familiarize with Joystick and Buttons
  • Read and familiarize with MP3 decoder
  • Completed
  • Completed
  • Completed
  • Completed
4
  • 10/31/2021
  • 11/06/2021
  • Develop graphics driver for LED matrix
  • Implement initial game objects and decide on logic
  • Decide on and draw Player Models
  • Finalize wiki schedule
  • Completed
  • Completed
  • Completed
  • Completed
5
  • 11/07/2021
  • 11/13/2021
  • Order PCB components and complete the design for printing
  • Order additional accessories if required and finalize hardware specifications (touch sensor)
  • Figure out logic required for second player
  • Finalize controller design
  • Completed
  • Completed
  • Completed
  • Completed
6
  • 11/14/2021
  • 11/20/2021
  • PCB and component assembly
  • Integration of PCB and microcontroller
  • Game logic finalization
  • Testing and debugging of game logic
  • Figure out AI settings and algorithms
  • Construct both controllers
  • Circuit board testing, ensuring proper trace runs and connectivity
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
7
  • 11/21/2021
  • 11/27/2021
  • Integrate game logic code with LED matrix
  • Get soundtrack and game sounds set
  • MP3 decoder driver construction
  • Develop and add method for animations
  • Completed
  • Completed
  • Completed
  • Completed
8
  • 11/28/2021
  • 12/04/2021
  • Finalizing the video game
  • Construct enclosure for LED matrix and microcontroller
  • Finalize and test menu select screen
  • Update the wiki page
  • Integrate game sounds with game logic
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
9
  • 12/05/2021
  • 12/11/2021
  • Address bugs during testing of integrated system
  • Completed
10
  • 12/12/2021
  • 12/12/2021
  • 12/12/2021
  • 12/12/2021
  • 12/14/2021
  • 12/14/2021
  • 12/14/2021
  • 12/14/2021
  • Final Demo
  • Update Gitlab repo with final code
  • Update test video
  • Update the wiki page
  • Completed
  • Completed
  • Completed
  • Completed


Parts List & Cost

Give a simple list of the cost of your project broken down by components. Do not write long stories here.

Design & Implementation

The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.

Hardware Design

Discuss your hardware design here. Show detailed schematics, and the interface here.

-PCB-

Hardware Interface

In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.

-LED Matrix-
-Sj2 Main to Sj2 Music-
-Music and Sound-

Software Design

Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.

-Core Game Design-

The game logic runs on a tick system, updating the players location after a certain amount of ticks has passed. A few key attributes are required for the logic of the game to work:

  • Each player has a speed (either 2 ticks for slow or 1 tick for fast)
    • This speed denotes how many game ticks must occur before the player is moved.
    • This tick count is stored in each players' game object.
  • Drawn Direction and New Direction
    • Drawn direction represents the way the player was facing, used to keep track of what pixels need to be cleared when movement occurs.
    • New direction represents the input from the player to change directions after their tick count has reached zero. As a rule, the input will be ignored if the player attempts to go backwards directly onto their drawn trail.
-Game Controller State Machine-
Game State Machine

The Game Controller is the state machine that makes the game operate as a whole, with menus, sounds, and input. Each state is simplified in the diagram to its core functionality.

-AI logic-

The logic for the AI we constructed is rather simplistic. There are three main functions utilized as shown:


AI core functions

The normal computer uses simple survival and educated turning to survive. To make the bot slightly less predictable, the bot has a 3% chance to turn either left or right, based off the educated turning model. This will still likely result in human being able to easily defeat the bot. The major intention on with this difficulty is to allow the player to practice the game without fear of the other player being too aggressive.

The hard computer uses a state machine to commence it's attack. It starts by cutting directly down from the top left corner to the bottom right corner, making near impossible turns to cut the board perfectly in half. Once the opponent is either 25 pixels above (or greater) or 25 pixels to the left (or greater) of the player, the computer will either head directly east or directly south, respectively, to cut down the size of the arena. The original intention was to then have the bot simply go to the larger area and survive, since it can play nearly perfectly. This still does happen occasionally, but in certain circumstances the bot will turn into the area where the other player is. This results in rather intense competition. The adjustments were going to be made to ensure just the perfect play would take place, but after testing with the current state, it was found to be more fun to have the bot take either path, as it was much more unpredictable.

Implementation

This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.

Testing & Technical Challenges

Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.

Include sub-sections that list out a problem and solution, such as:

Main Suggestions

Make sure you write modular code. Keep functions short and simple to start. The most used function in our project was the function to write to the 64x64 array that represented our display: led_display__draw_pixel. With this simple interface between the LED matrix and the rest of the code allowed for other functions to be written to take care of drawing images of different sizes easily.

Keeping code simple and using a naming convention that called for a description of what the function was doing allowed for rapid development with little to no debugging required.

AI

Figuring out the logic for a computer opponent in a game such as ours is a difficult task. To figure out how to optimize a bot, you must figure out various strategies the computer should employ and allow the bot to have as much or more knowledge of the game state as a human would have while playing. For our purposes, the simplest of computer difficulties basically plays without knowledge of the opponent's actions. This results in a very easy to trap opponent. Once we added in more knowledge for the AI, a viscous attack strategy was able to be formulated and the bot then took on the elements of a state machine. The initial part of the attack involved getting to the opposite bottom corner as fast as possible, going right down the middle of the screen making humanly impossible turns. Once the bot reached a close enough location to the other player, it would then decide (almost randomly, the algorithm is a bit complex) to either:

  • Go to the section of the screen the other player was not in and play a survival game, one a human is likely to lose.
  • Or join the player in the section and attempt to survive.

The original intention was to force the bot to take the first option every time, but due the suggestion algorithm not responding exactly as intended, the bot can do either option listed previously. This bug actually made the experience more enjoyable and gave some variance to the bot's play style. The main take away from this section should be that not every not fatal bug can actually be a benefit to a gaming experince.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

Project Video

Upload a video of your project and post the link here.

Project Source Code

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

List any references used in project.

Appendix

You can list the references you used.