Members

41

179 Neutral

• Rank
Member
1. ## AI for continuous snake game (trying NEAT algorithm)

Cheers, love the animated gif:)   1. 'it randomly chooses to go either left or right of the obstacle' Ok, imagine I look at a bunch of pixels in front of the snake, if I see some becoming non empty, then it chooses to go left or right of the obstacle. This is very fiddly, or at least your explanation would need a lot of work to make it into something programmable. If I look at a line of pixels in front of the snake and detect some pixels as occupied (not necessarily 1 interval, but possibly any combination of those pixels, edit: OK this is probably addressed in your 3.), then how exactly do I decide to go left of them ? Just go completely left/right of its field of vision. Also the turning radius needs to be taken into account, so not only this pixel line need to be taken into account, but also all the pixels in my planned trajectory. Also this algorithm doesn't look at anything after this line. Anyway I think about it, this doesn't sound programmable actually.   2. 'After 2 or more tries of avoidance, it learns by delaying the turning' Maybe this addresses some of the shortcomings in 1. But I'm not exactly sure how   3. Ok this means go in the middle of the obstacles in the front if it can't go left or right. But again this has no knowledge of anything else than the line in front of you so it wouldn't be very smart. Here I included an image (excuse the drawing skills) showing that the snake could go straight into an obstacle in that case. I know it's a very specific example but I'm pretty sure an algorithm like that just wouldn't work in the general case   Again thanks for the input! But I think your approach is too simplistic. I tried a very interesting different approach a few years ago that I'll post here (didn't manage to export the gmail thread today).
2. ## AI for continuous snake game (trying NEAT algorithm)

Hey Tom thanks! It's a bit hard to understand your grammar but here's my interpretation: 1. You're suggesting that I add a random input when the snake is near obstacles ? That sounds like a bad idea, how could it learn from it ? 2. You're suggesting that I find the direction of the middle of the hole in front of the snake and use that as an input ? The intuition is ok on that one, but this sounds quite fiddly. Also I would think that my smart ray pointing straight ahead already does that.   Of course I'm quite eager for more suggestions, silly or not, thanks!
3. ## AI for continuous snake game (trying NEAT algorithm)

1 min 11s Really silly though as that's not what I'm trying to optimize it for, and it's not fun. It'd probably kick a human ass at that game though https://www.youtube.com/watch?v=Y02tXQPjjAY

5. ## AI for continuous snake game (trying NEAT algorithm)

Sure, I've added the .exe in the first post. Let me know how it works for you !   I've not made huge progress really, I've been mostly playing with the parameters. I got some ideas for new inputs, I'll post again when I implement them!
6. ## AI for continuous snake game (trying NEAT algorithm)

Yes, this sounds fiddly indeed But I appreciate the input and the interest.   I've tuned the AI some more and got something that starts to be a bit decent. Here, I'm playing against it (I'm yellow, the AI is blue). It's actually pretty fun:) I was quite surprised. As you can see, it's still severely lacking in number 4) above (topological analysis) but I do have some ideas for it now. I'll try adding some inputs representing the shape of the topology toward some angles based on the results of some forward search on a grossly discretized state space. It's not yet clear in my mind. I know I need something somewhat continous for the AI to learn from it. Also again it evolves this spiral pattern which is actually not that bad. Surprisingly, as you can see, the evolved neural network has only 2 of the inputs connected (or I don't understand the NEAT algorithm yet) https://www.youtube.com/watch?v=AC-w1xCk-Do I can't wait to get more time on it. If someone wants to play it, I'll be happy to upload an exe (it's very simple to use)
7. ## AI for continuous snake game (trying NEAT algorithm)

Ah, very interesting article thanks, I'll read it carefully tomorrow for insights. Basic avoidance steering would work to avoid obstacles, but it'd be pretty stupid indeed.   A good player needs to: 1) Avoid walls. Your two suggestions address that. 2) Notice occasions when it can 'cut short' the other one (when next to him a bit ahead). 3) Avoid getting 'cut short'. 4) Also ideally a great player would need an idea of the topology of the current 2d space to try to enclose the other one in a smaller space / safeguard himself a bigger space.   My approach seems to have potential indeed as it starts to exhibit 1), 2) and 3). I wonder what other kind of inputs I could give the neural network though... Also for some reason, my networks do not evolve any hidden neurons so far. I probably need to get more familiar with the NEAT algorithm.
8. ## AI for continuous snake game (trying NEAT algorithm)

Hi!   I'm trying to evolve an AI for a game of 'continuous' snake. Check this vid to understand the game: https://www.youtube.com/watch?v=sFA6rQM_rsE Basically, the snake drives a bit like a car and the first one of the 2 players to crash into his trail or the other's trail loses the game. What ideas would you have guys to design an AI for this ? The state space is huge: ideally there'd be 60fps per second and every frame, the snake can steer from -1 (left) to +1 (right) including all the values in between. So A* wouldn't cut it.   My current try is to use the NEAT algorithm (http://www.cs.ucf.edu/~kstanley/neat.html). I have the framework working and the AI is starting to show some traces of intelligence. The fitness value doesn't go up much though and it tends to converge toward the spiral pattern. It might be a good strategy though The inputs I've chosen so far are: - the opponent angle relative to us - the opponent distance - the opponent heading relative to us - the eyes: inputs representing how far a certain number of ray casts can go before hitting a wall (represented on the vid)   I've attached the code to this post if anyone wants to try it. You just need to install the SharpDX packages using nuget and hit F5.   Basically I'm interested in knowing what you think, and what other ideas you could give me for coding an AI for this game.   Thanks!   edit: Added the exe Numpad 4 and 6 : turn left and right Space : Restart a game against the new champion E : Pause/Unpause evolution. Useful to get a responsive UI. Pauses after the current iteration (8s on my machine)
9. ## Pixel perfect mario physic ?

I've always wondered, does anyone know the equations for running and jumping behind the first mario game ? I mean, how would I go to recreate a game with the exact same feel ? - capture lots of screenshots and deduce the equations ? - reverse engineer the nes code ? - someone has done it before ? (A quick google search didn't turn up anything)
10. ## General advice on making a replay system ?

Thanks very interesting. I will go the route of recording the inputs, it's definitely the easiest. And try to make it as seamless as possible in my code. I need to work within the cocos2d framework though but it should be possible Also the gamasutra article mentions using a stream to avoid having to create data structures. This seems like a brilliant idea, I'll try that
11. ## General advice on making a replay system ?

I've already made the beginning of a 2d (4p max) multiplayer game on ipad. I'm using cocos2d. The games last maximum 1 minute. I want to get a replay of the most epic ones and use them to decorate the front menu (kind of sceensaver function) I've already done some replay system (for the same game on PC), but they had some problems/bugs. Mainly from a lack of a consistent interface across all the game objects for replays. I know it's very vague sorry. My question is, do you have any general advice on making a replay system ? Even if it's stupid advice. Like "implement StartRecord() and StopRecord()", any advice from someone who has implemented one. Like a postmortem on gamasutra would be great
12. ## AI for snake game with steering ?

Ah yes, thanks guys, I had found the link and contacted the author. He was very helpful, and basically said that I can apply his exact same algorithm if I cut my space in a grid.
13. ## How to draw "lines" in Op

Alright, GL_EXT_blend_minmax is supported on the iPad and works like a charm. Here's a screenie. Thanks to both of you guys
14. ## How to draw "lines" in Op

karwosts: Your suggestion is interesting and thanks for the drawing. But it wouldn't display properly when 2 lines would be drawn side by side (eg: snake going back along its trail or 2 snakes going close to each other). It wouldn't "blend" properly. osmanb: What extension is that exactly ? I don't think the iPad would have it. For a moment, I thought the logic OR operation would work (kind of returning the max of the incoming fragment and the destination fragment). But it doesn't. I'll also check if I can use OGLES 2.0 in the middle of my cocos2d game or if I can use the experimental OGLES 2.0 build of cocos2d. Any other suggestions ? Thanks
15. ## How to draw "lines" in Op

I'm using a circle gradient texture to draw lines with a smooth edge. The texture goes from 255,255,255,255 in the center to 255,255,255,0 on the outside. So to draw a line, I draw the line body using the vertical middle slice of the texture. And I draw a cap on each end to make it look nice. I'm using these lines to draw a snake (tron style but that can turn 360 degrees). I need these caps because sometimes a segment gets removed and I want the surrounding segments to look nice. As you can see in the screenshot, I can't seem to find the correct GLES 1.1 mode to get the lines to draw properly one after the other. The Blend mode uses the classic: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Which does not draw the lines properly (the alpha is wrong at the intersection). Also I tried a couple of silly logic operations. What I need is to draw the pixel only if its alpha value is higher than what's already displayed. I looked at glAlphaFunc, but it can only compare the incoming alpha to a set value. Is there's any way to do that using the fixed pipeline of OGLES 1.1 ? (It's on the iPad) Thanks ! PS: sorry I mistyped the title, can't seem to correct it.