Live data from Hacker News

Super Hexagon Bot

crackedopenmind.com

1–10 of 31 posts

Re: Super Hexagon Bot

#2
Not having managed to get past 30 sec on level 6, I applaud this bot. Using DLL injection was a very good idea too, but I wish the algorithm could play the post-finish level for a bit longer.

Re: Super Hexagon Bot

#4
Hmm, I'm a bit surprised that some sort of ad-hoc AI is used, instead of extracting the topology of the level and running a pathfinding algorithm on it.

Once you remove all the human-confusing effects, the levels are actually very simple, being just 4-6 columns. Since the minimum thickness of obstacles is quite high and they are aligned with each other, you could even represent the level as a graph, and run your pathfinding without having to manage the geometry explicitly.

But then again, I'm the guy who thought about implementing a bot when the game came out, instead of actually doing it.

Re: Super Hexagon Bot

#5
post #4

Hmm, I'm a bit surprised that some sort of ad-hoc AI is used, instead of extracting the topology of the level and running a pathfinding algorithm on it. Once you remove all the human-confusing effects, the levels are actually very simple, being just 4-6 columns. Since the minimum thickness of obstacles is quite high and they are aligned with each other, you could even represent the level as a graph, and run your path…

Yeah much of the game is based on human perception. All the rotation moves both level and human, the walls don't ever rotate relative to the player.

Re: Super Hexagon Bot

#6
Ever since my 8-year old son beat the game multiple times on level 6, I have been working on getting there as well. The best I have made has been 19 seconds on level 6 - though I have beat the first five levels, level 6 is truly insane.

Watching my son play is quite the experience. It seems my reflexes are not what they once were. It's an amazing game.

I want to think that writing my own bot would count as beating the game, but I doubt my son would say it counts. So, here's to the next few thousand attempts at level 6. "Again!"

Re: Super Hexagon Bot

#8
(I initially posted this on the Reddit thread yesterday, but I thought I'd repeat it here since there are many programmer types who might attempt this here.)

From the article:

> Of course, because we replaced the function with our own, we have to actually swap the buffers by explicitly calling the original glutSwapBuffer() function. I did this by undoing the hook, calling the original function and hooking it again.

Background qualification: I do this sort of debug launcher + DLL injection thing a lot. For one example with source, see my tool header magic ( http://www.romhacking.net/utilities/796/ )

As someone with experience, please take it from me: this is a really bad idea. If you rewrite functions to call the originals, it becomes possible for another thread to call that function in the middle of your rewrite, and end up executing illegal instructions. Not only is this theoretically possible, it routinely happens all the time. Even when you think for sure that your program is not multi-threaded. Even something like hooking a Windows file size function, you'll learn that the open file dialog on Windows Vista+ is threaded, and will bomb out on you with alarming frequency.

The proper way to do this is to create "trampolines" instead. The idea is that you copy the first few instructions from the original routine, and put them somewhere else. And at the end, you jump back into the original function after your patched jump. The address of where you put the original instructions is your pointer to the "original function" that you can use if you want.

So basically, something like this:

    originalFunction:
      opcode1
      opcode2
      opcode3
Becomes:

    originalFunction:
      jmp detourFunction
      nop 
    resumeAddress:
      opcode3
    
    trampolineFunction:
      opcode1
      opcode2
      jmp resumeAddress
    
    detourFunction:
      
      call trampolineFunction 
      
Now, I know this sounds horrifyingly complicated: you probably think you'll need a full-on x86/amd64 disassembler+assembler. And it's theoretically possible to make a near-impossible function to trampoline. But keep in mind that 99% of APIs are built in higher level languages, and as such, have very consistent function prologues (usually saving the stack frame.) So in practice, you can write trampoline installers using one or two "signatures" and hook nearly every function you'd ever want to.

But if that seems too challenging, there is also a library called Detours ( http://research.microsoft.com/en-us/projects/detours/ ) that you could try instead. I didn't find it necessary for my own purposes.

Re: Super Hexagon Bot

#9
post #6

Ever since my 8-year old son beat the game multiple times on level 6, I have been working on getting there as well. The best I have made has been 19 seconds on level 6 - though I have beat the first five levels, level 6 is truly insane. Watching my son play is quite the experience. It seems my reflexes are not what they once were. It's an amazing game. I want to think that writing my own bot would count as beating th…

i saw a 6 year old play Temple Run on an iPad and i was amazed! Someone jokingly said that he doesn't trust kids; they pretend not to know how to speak, then they make transactions and build empires on their iPad.

Re: Super Hexagon Bot

#10
post #6

Ever since my 8-year old son beat the game multiple times on level 6, I have been working on getting there as well. The best I have made has been 19 seconds on level 6 - though I have beat the first five levels, level 6 is truly insane. Watching my son play is quite the experience. It seems my reflexes are not what they once were. It's an amazing game. I want to think that writing my own bot would count as beating th…

I got pretty good at Super Hexagon and can beat all 6 levels, but on their hard mode's I can't get very far on levels 5 & 6.

I think my level 1 record is somewhere near 10 minutes now.

Post reply on HN