Skip to content

Instantly share code, notes, and snippets.

@MisterBrash
Last active November 20, 2023 15:36
Show Gist options
  • Save MisterBrash/019663cc563718171b20595056b186ea to your computer and use it in GitHub Desktop.
Save MisterBrash/019663cc563718171b20595056b186ea to your computer and use it in GitHub Desktop.
Various challenges to practice Python coding using the Unicorn-HAT-HD (or the simulator)

Unicorn HAT Challenges

Create a new file for each level (level1.py, level2.py, etc). Clicking on the animation will enlarge it.

Level 1 - Randomly light up a single pixel a random colour forever.

Level 2 - Randomly light up a single pixel white forever (but no other lights are on)

Level 3 - Hide a single pixel and the computer tries to find it randomly, leaving BLUE for a miss. When it finds it, highlight it RED and stop.

Level 4 - MOVE a single dot around the screen - up/down/left/right by a single postition. No wrap-around and no going off the screen. Reversing is fine.

Level 5 - Similar to Level 4, move a dot around the screen, reversing is fine. Leave a trail wherever the dot goes.

Level 6 - Hide a random dot (ship) and then randomly fire at it. Every miss leaves a trail but each miss increases the brightness, creating a heat-map. When the hidden ship is found, light it bright red.

Level 7 - A mixture of Level 3 and 5. Hide a ship. Instead of randomly firing, walk around the map, leaving a trail, until you find the ship.

Level 8 - Similar to Level 7 but instead of leaving a simple trail, we will create a heat-map of where we walked. Similar to level 6 where the brightness increased on every hit, the brightness of a "walked" location will increase every time it is hit.

Level 9 - Adjust Level 8 so that the number of "steps" are counted and printed when finished. Also, The moving dot cannot "reverse". It cannot go backwards, it can only move forward, right, or left. No doubling-back.

Level 10 - The ultimate challenge! No hidden ship. Instead, two different-coloured dots walk around the screen like Level 9, leaving a different coloured heat maps. If the dots collide, a simple red animation (explosion) happens and the number of steps is printed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment