Beating Super Hexagon With OpenCV And DLL Injection

Every few months a game comes along which is so addictive, players can’t seem to put it down – no matter how frustrating it may get. Last year one of those games was Super Hexagon. After fighting his way through several levels, [Val] decided that designing a bot to beat the game would be more efficient than doing it himself. Having played a few rounds of Super Hexagon ourselves, we can’t fault him on that front!

At its core, Super Hexagon is a simple game. Walls move from the screen edges toward a ship located near the center of the screen. The player uses the arrow keys to “orbit” the ship around a central shape. Avoid getting crushed by the walls, and you’re golden. However, the entire game board is constantly spinning, expanding, contracting, flashing, and generally doing things to disorient the player while ever more complex wall patterns move in to kill you. In short, Super Hexagaon makes Touhou bullet hell games look like a cakewalk.

The first step in beating the game is to capture the screen. [Val] tried Fraps and VLC, but lags of 2 seconds or more were not going to work. Then [Val] turned to DLL Injection. Super Hexagon calls the OpenGL function glutSwapBuffers() to implement double buffering. Every frame of the game is rendered in the background. Once rendering is complete glutSwapBuffers() is called to swap the buffers, and the process starts over again. [Val] changed the game code such that his own frame capture function would be called instead of glutSwapBuffers(). Once he was done capturing the game’s video buffer, [Val] then called the real glutSwapBuffers() function. It worked perfectly.

Now that he had an image, [Val] used OpenCV to process it. Although game is graphically very noisy, there are only a few colors used at any one time. It didn’t take much work to come up with an algorithm which would create a binary image of the walls and the ship itself.

step5[Val] cast rays from the center of each wall through the center of the screen. The ray which was longest before intersecting another wall would be the best escape route. This simple solution worked, but only for about 40 seconds. At that point, Super Hexagon would start throwing more complex patterns, and the AI would fail. The final solution was to create an accessibility condition which also took into account how much space was available between the various approaching walls. This new version of the AI was able to beat the game.

So was this a more efficient method than grinding through Super Hexagon manually? Since [Val] now knows all about DLL injection and OpenCV, we sure think it was!

Click past the break to see the [Val’s] bot in action!

Continue reading “Beating Super Hexagon With OpenCV And DLL Injection”

Hacklet 36 – Oscilloscope Projects

Oscilloscopes are one of the most often used tools of the engineer, hacker, or maker. Voltmeters can do a lot, but when you really need to get a good look at a signal, a good scope is invaluable. This week’s hacklet is triggered by the rising slope of some of the best Oscilloscope projects on Hackaday.io!

rigol500We start with [DainBramage’s] recent project Stretching the Limits of a Rigol DS-1102E Scope. The new Rigol ds1054z may be getting all the press lately, but the older DS-1102E (100 MHz) model is still a very capable scope. [DainBramage] broke out his vintage Singer CSM-1 service monitor to generate frequencies all the way up to 500 MHz. The Rigol did admirably well, detecting a sine wave all the way up to 500 MHz. This is in part due to the scope’s 1 gigasample-per-second sampling rate. Once things got beyond the specified limit of 100 MHz though, the signal began to attenuate.  Not bad for pushing a low-end scope way beyond its limits!

 

cornel-scopeNext up is [Bruce Land] with his PIC32 oscilloscope. Microcontroller scope projects are nothing new, but one that runs at nearly 1 MHz sampling rate while generating NTSC composite video is nothing to sneeze at. [Bruce] pulled this off by using Direct Memory Access (DMA) to move the data from the ADC to memory, and to get the video data from memory to the I/O pins used to generate video. The video itself is created by a resistor tree DAC. All you need to make black and white video is three resistors and two I/O pins. [Bruce] says the entire scope cost about $4.00 us in parts!

scope-hand[Jacob Christ] mixed art and science with his chipKIT Oscilloscope Plotter. [Jacob] used a Microchip PIC32 based Fubarino to draw patterns on his scope. To do this the scope must be set to X-Y mode. [Jacob] paired his Fubarino with a MCP4902 Digital to Analog Converter (DAC). Using a dedicated DAC is a great way to do this. [Jacob’s] images are a testament to that, as they’re some of the cleanest “scope art” drawings we’ve seen. Much like [Bruce Land], [Jacob] used his project as the basis for a college class. In fact, the image to the left was created by one of his students!

Want more scope goodness? Check out our new Oscilloscope Projects List!

Hackaday.io Update!

Hackaday.io is getting new features every day. Our dev team has just rolled out a new gallery view. Just click on a project’s featured image, or the “View Gallery” button, and you will be taken to a gallery view of every image used in the project – including log images. YouTube videos will render in the gallery as well. It’s a great way to view a timeline of progress for some of the projects on hackaday.io. For a great example of this, check out OpenMV’s gallery.

In other Hackaday.io news, check out the Caption CERN Contest! Every week we put up a new image from CERN’s archives. The Hackaday.io user who comes up with the funniest caption wins a T-Shirt from The Hackaday Store!

Looks like we’ve hit the end of the trace for this Hacklet. Same hack time, same hack channel, bringing you the best of Hackaday.io!

EddiePlus, The Edison Based Balancing Robot

[Renee] dropped a tip to let us know about EddiePlus, her balancing robot creation. As its name might imply, EddiePlus is controlled by an Intel Edison processor. More specifically, [Renee] is using several of Sparkfun’s Edison Blocks to create Eddie’s brain. EddiePlus’ body is 3D printed, while his movement comes from two Pololu DC motors with wheels and encoders. The full build instructions are available as a PDF from [Renee’s] Google drive.

Eddie is able to balance and drive around on two wheels, much like a Segway. Sensor data for balance comes from Sparkfun’s LSM9DS0 based Inertial Measurement Unit (IMU) block. In this new “plus” version of Eddie, [Renee] has added encoders to the robot’s wheels. This makes it easier for him to adapt to changing loads – such as pumping iron (or banana plugs as the case may be). The encoders also help with varying terrain, as [Renee] demonstrates by tilting a board as Eddie drives on it. Eddie’s code is written in C, and available on Github.  Controlling Eddie is as easy as sending simple commands via UDP.

As you might imagine, the Intel Edison still has plenty of cycles left over after computing Eddie’s balance. [Renee] uses some of these with a webcam based teleoperation mode.

Click past the break to see Eddie in action!

Continue reading “EddiePlus, The Edison Based Balancing Robot”

Wearable WiFi Finder Uses The ESP8266

It seems like a day doesn’t go by without an ESP8266 project here on Hackaday. There’s a good reason for that, the chip and associated modules have brought low-cost WiFi connectivity to the masses. Today we have [Stevica Kuharski], who has built an open WiFi access point detector using the ESP8266. To do this he’s using the Lua compatible NodeMcu firwmare. [Stevica] wrote his own Lua scripts to run on the ESP8266’s internal 32 bit microcontroller. The freewifi script scans and searches for open WiFi networks. If a network is detected, the user is informed via a blinking LED.

To make the project wearable, [Stevica] powered the project with a pair of CR2450 coin cell batteries. The ESP8266 is not known for being a particularly low power device, so we’re curious to see what sort of battery life  [Stevica] gets with his project. The project source is already available on GitHub, and [Stevica] is hoping to kick off an Indiegogo campaign in the next few weeks. Click past the break to see the WiFi detector in action.

Continue reading “Wearable WiFi Finder Uses The ESP8266”

Spin Up An Old Hard Drive With A Solenoid Motor

Just about all of us have a few old hard drives in our junk box. There are a myriad of projects out there to put them to work in new and interesting ways. One of those ways is to turn your hard drive into a solenoid motor of sorts. (YouTube link) This isn’t a new hack, videos of it have been kicking around the internet for years. [black1985vette] gives a pretty good explanation of how he’s done it. He used a piece of brass as a connecting rod between the drive head and a pin mounted off-center to the platter hub. One of the platter mounting screws provides the perfect place to set the pin. A bent safety-pin rubs the center of the hub, which is partially insulated with tape. When the pin contacts the hub, the drive head is energized, pushing the whole assembly around. The mass of the platters acts as a flywheel, carrying the motor the rest of the way around.

[Pulverrostmannen] performed a similar mod, though he used a micro switch to time the drive head. Rather than a brass connecting rod, [Pulverrostmannen] used a spare head. With a simple transistor circuit acting as a speed control, his hard drive motor revved up to around 1560 RPM, which is pretty respectable for a bunch of junk parts.

So next time you’re stuck in on cold rainy weekend, pull out some of those old drives and get hacking! Click past the break to several of these projects in action.

Continue reading “Spin Up An Old Hard Drive With A Solenoid Motor”

Mapping WiFi Signals In 3 Dimensions

[Charles] is on a quest to complete ever more jaw-dropping hacks with the popular low-cost ESP8266 WiFi modules. This week’s project is plotting WiFi received signal strength in 3D space. While the ESP8266 is capable of providing a Received Signal Strength Indication (RSSI), [Charles] didn’t directly use it. He wrote a simple C program on his laptop to ping the ESP8266 at around 500Hz. The laptop would then translate the RSSI from the ping replies to a color value, which it would then send to the ESP8266. Since the ESP8266 was running [Charles’] custom firmware (as seen in his WiFi cup project), it could directly display the color on a WS2812 RGB LED.

The colors seemed random at first, but [Charles] noticed that there was a pattern. He just needed a way to visualize the LED over time. A single frame long exposure would work, but so would video. [Charles] went the video route, creating SuperLongExposure, an FFMPEG-based tool which extracts every video frame and composites them into a single frame. What he saw was pretty cool – there were definite stripes of good and bad signal.

wifiPOVThumbArmed with this information, [Charles] went for broke and mounted his ESP8266 on a large gantry style mill. He took several long exposure videos of a 360x360x180mm area. The videos were extracted into layers. The whole data set could then be visualized with Voxeltastic, [Charles’] own HTML5/WEBGL based render engine. The results were nothing short of amazing. The signal strength increases and decreases in nodes and anti-nodes which correspond to the 12.4 cm wavelength of a WiFi signal. The final render looks incredibly organic, which isn’t completely surprising. We’ve seen the same kind of image from commercial antenna simulation characterization systems.

Once again [Charles] has blown us away, we can’t wait to see what he does next!

Continue reading “Mapping WiFi Signals In 3 Dimensions”

Hacklet 34 – Satellite Projects

Space. The final frontier. Every tinkerer, hacker, and maker has dreamed of flying out of Earth’s atmosphere and into the heavens. Last year one hard-working team got a chance to fly a member to space by winning the Hackaday prize. For the rest of us, we can still experience some of that excitement by contacting satellites in orbit, or even sending a bit of our own hardware into space. This week’s Hacklet focuses on the best satellite projects on Hackaday.io!

basicSatWe start with [movax] and Your satellite devkit and launch. Chipsat is a tiny satellite which runs BASIC code. Yes, BASIC in space! Chipsats will be stacked into a launcher and sent off into space in groups. The idea is to eventually have them launched from the International Space Station. Power is provided by a small solar cell which charges up a pair of super capacitors. When the capacitors are charged, the satellite will run for a few seconds. Connectivity with the ground is via a 433 MHz link. Chipsat doesn’t just float in space, three coils give it the ability to control its attitude and rotation. Chipsat will sense the space around it with a magnetometer and a light sensor.

 

satnogsv2

No satellite-themed Hacklet would be complete without [Pierros Papadeas] and his team’s work on SatNOGS – Global Network of Ground Stations. SatNOGS aims to create a global network of connected satellite ground stations. Think of it as a grass-roots version of NASA’s deep space network for satellites in earth orbit. This is more than just a great idea, as SatNOGS won the 2014 Hackaday Prize. You can check out our coverage of the project back in November, 2014. Since then, the SatNOGS team has been busy! They’ve just deployed the first SatNOGS V2 system above their hackerspace in Athens, Greece.

trsiNext up is TRSI PocketQub Satellite, another project by [movax]. TRSI is a satellite that sends data via images which can be viewed with a simple RTL-SDR stick using Hellschreiber mode. Hell mode means that images can be directly viewed in the waterfall display of whichever SDR application is running the receiver. Numbers or entire images snapped with TRSI’s cell phone style camera module can be encoded and displayed. Power is of course provided by solar cells, and the communications link will be on the coordinated 433 MHz band. The original TRSI hardware has actually morphed into a deployment machine for ChipSat, [morvax’s] other satellite project. He’s put the main TRSI program on hold until after the ChipSat campaign is complete.

pocketquRounding out our satellite special is [OzQube] with his project QubeCast Max. QubeCast is the first Australian version of the PocketQube PQ60 satellite form factor. After watching the success of $50Sat project, [OzQube] wanted to design a satellite of his own. Since he wanted to add sensors and send more data back to Earth than previous efforts, he needed a higher data rate than the current crop of satellites. This meant going to a high-powered radio. To achieve this, he’s using a  NiceRF RF4463F30 radio module. The module is based upon a Silicon Labs Si4463 RF ISM band chip, coupled with a power amplifier. The module outputs 1 watt, which is quite a bit of power for a tiny satellite!

Want more satellite goodness? Check out Hackaday.io’s freshly minted Satellite List.

The countdown is almost at 0, so that’s just about all the time we have for this episode of the Hacklet. See you next week.  Same hack time, same hack channel, bringing you the best of Hackaday.io!