Final Product

Background Information

For our project, we modified the user-interface for the Redhawk duels to compete against our classmates.  Redhawk duels is a DE2 hardware programmed game that allows two players to program separate game controllers and battle each other with space ships. The interface for the game is not very user friendly, so each team modifies their interface program, making convenient inputs, outputs, and/or macros.






This is how we originally envisioned our GUI.

This was the GUI we originally envisioned.  We planned on dividing up the screen into several displays.


We found out that it is more easier and visually more appealing if we condense all of these readings into one display.   We use a VGA adapter from University of Toronto to configure the VGA displays. The VGA adapter module manipulates 4x4 pixels, dividing the VGA screen into a 120x140 screen.  Each pixel can be assigned a range of colors designated by the color depth parameter in the VGA adapter.  In our display modules, we manipulate the shapes and readings by using Boolean logic. 

Right before Thanksgiving Break, we successfully displayed a counter, a map, and a radar screen.  Using the x and y coordinates given to us by the ethernet module, we drew the ship’s position relative to the walls on the map.  The map was 320 x 240 meters, but since the VGA is only 160 x 120 pixels, we had to scale the map down by a factor of 10.  

We then wrote a Matlab program to print out Verilog code to generate the radar screen and the relative angles of the cannon/sensor. Our radar screen has yellow marks right below the 0, 90, 180 and 270 degree mark to show where the walls should be.  In the final product, the cannon and the sensor never separated, so we only had to keep track of one angle.  This angle was highlighted green when nothing is detected, and it is highlighted red whenever an enemy ship is detected.

In addition to the map and radar screen, we also implemented several sub-displays to keep track of readings. We had originally planned on displaying readings through numbers and letters, but we found out that by using the VGA adapter from University of Toronto, our resolution is too poor; so we used gauges to keep track of our readings.  Our timer would fill up to 60 pixels whenever a new game would start and decrement a pixel per second, letting us know when the round is coming to a halt.  Our power gauge would calculate the maximum power we can gain from our optimal crystals wiring.  Finally, we created a display to show the optimal crystal wiring.  In this display, our crystals are represented by colors instead of letters, because colors are much easier to display than letters; also it turned out to be easier for us to wire the crystals together after color coding each wire.



This is what our final GUI ended up looking like.


VGA code




      Each ship’s power configuration is determined by the wiring of the crystals.  The longest wiring of the crystals determines the most power the ship can receive, which changes every time the ship gets hit.  In order to change the crystal wiring, the user must not only manually rewire the crystals on a breadboard, but also figure out a working configuration, which turns out to be a traveling salesperson problem, which is NP complete (aka. cannot be solved in polynomial running time).  We calculated that if we were to find the most optimal crystal wiring path, we need to use brute force, which requires 7 factorial possibilities, and this requires 800,000 clock cycles on the DE2 board.  Fortunately, this takes about 1/6 of a second to compute, since the DE2 board uses a 50 MHz clock.  Once we had a program that figured out an optimal path, we needed to figure out a way to quickly wire the crystals.  We eventually came up with a solution that uses telephone plugs for each crystal, and a set of jacks to align them.  Each crystal except the zero crystal was given a plug, with both of its wires going into it.  One wire would go to the previous plug, the other goes to the next plug, with the first and last plugs going into the zero crystal.  The optimal path was displayed as an order, with each crystal assigned a number that is its place in the order.  We translated these into the basic 8 colors of the display, associated each crystal with a plug, and used this system to quickly rewire the crystals of the ship.

Here is a picture of our quick crystal rewiring system.  Yes, that is duct tape.


Here's the wiring scheme for the plugs.  This design led to fast rewiring and minimized human error.


Crystal Wiring Code




            We successfully interfaced the VGA displays and the Crystal wiring algorithms.  We could scan the surrounding area and spot the enemy ship.  We also implemented an auto fire feature that would shoot when a ship was detected by the sensor.  By the competition day, we had a competitive ship.