Simulated Annealing - A.I. Algorithm

A little bit of artificial intelligence...

In this video, I break down an optimization algorithm known as simulated annealing. I put together a little visualization of the algorithm using Java Script, and if you download the code from GitHub you can actually try tweaking some of the parameters yourself.

As mentioned in the video, if you have any questions, or if you believe anything I say to be incorrect, please let me know! I'm always looking to learn and improve my skills as a programmer.

Explore the code

Writing a game in C!

Lo-Fi MonkeyBall

Eric Schirtzinger & Carly Krebs

Taking inspiration from the classic video game series "Monkey Ball", we wrote this game for the Tiva Launch Pad (ARM Cortex-M).

> Note: This application was written as part of an open ended final project for ECE353 Introduction to Microprocessor Systems, taught by Eric Hoffman at University of Wisconsin Madison in 2018.

Watch the Demo

Overview

In this game, users roll a ball around the grass, trying to avoid hitting the fire or falling in the lava. Sometimes fire blocks the way, luckily touching the fire puts it out. Once the user reaches the checkered end area, they win! The player with the fastest time gets their initials displayed on the homescreen for all to see.

Highlights

Simulated Inertia

It was very important for us to make sure that the game controls felt real. One of our main focuses was on simulating inertia, to give the ball some weight. I came up with this little "hack" while writing another program, and thought it would work perfectly here.

The main idea is to have user input only update a target speed, rather than the true speed. In this case, it was the raw accelerometer data that set our target speeds. Then each frame, we increment the real speed towards the target speed by some fraction of the difference. This results in the real speed smoothly chasing a more hectic input speed.

Screen Shot 2018-07-19 at 11.13.48 PM.jpg

Below is the structure we used to track the ball's state

Screen Shot 2018-07-19 at 11.14.13 PM.jpg

Easy Level Construction

In order to allow for some variety in game play, we wanted to come up with an easy way to write new levels. Our solution was to simply make a two-dimensional array of integers, each integer associated with a different level component (grass, lava, obstacle, winzone).

Each array index corresponds to a 16x16px square on the screen, when rendering we iterate through the array, and render each level component bitmap. This also is how we do collision detection, take the screen coordinates, divide by 16, and index into the 2d-array to get back the level component.

Screen Shot 2018-07-19 at 11.14.31 PM.jpg

Easy Level Construction

In order to allow for some variety in game play, we wanted to come up with an easy way to write new levels. Our solution was to simply make a two-dimensional array of integers, each integer associated with a different level component (grass, lava, obstacle, winzone).

Each array index corresponds to a 16x16px square on the screen, when rendering we iterate through the array, and render each level component bitmap. This also is how we do collision detection, take the screen coordinates, divide by 16, and index into the 2d-array to get back the level component.

Screen Shot 2018-07-19 at 11.14.53 PM.jpg

Thanks for reading!

If you'd like to dive a little deeper, feel free to check out the source code on GitHub.