AI code for Bots to race or battle

I’m just writing AI-code for my bees to find flowers an the way back to the hive. Quite easy so far… but … I’m going to include some minigames like a water baloon battle or a race escaping a maze… And here I still simple don’t know even how to start :slight_smile:
Anyone already done something or knew a good side, where I can learn a bit.
Every little bit is very welcome…

@Albertos has recently done something similar in his game I think!

Hay @Gurki! I would like to help you, but I do not yet understand exactly what part you need help with. Can you give an extra explanation please?


I’ve designt a multiplayer game, but most likely there won’t be enaugh player online for a match. So I want to fill up with bots… But I haven’t got any idea, how to make the bots act reasonable, like they are controlled by some player :frowning:

For the maze, I think I can make one bot always turn right an another always turn left…
but this leaks a bit of a challenge.

Best for me to start with would be some samples I can learn from an addept to my needs. I need insparation… some yaers ago I made maps for Unreal, so I still always think about apples and sniperPoints :slight_smile:

Okay sounds interesting. So if I understand correctly you can program yourself but you only need some suggestions?

For this I would just let the system choose between left or right.


I can write code that will work, but won’t look nice…
learned my first language in the 80th, and my skills havent improved by then…

Yeah suggestion, insperation, samples is what I’m looking for

I have the same problem because I am still learning programming. So also my code will not be perfect.

To start with, I would use 2 sensors for the race car AI (front left and front right). In addition, I would make a number of checkpoints on the course. Have the race car facing the checkpoint unless the sensors are touching something. In that case, steer the race car slightly to the left or right.

For the maze AI I would start by making a characters with 3 sensors (front, left and right). The sensors know where the character can go and where not. If the character can go for example to the right or straight ahead, you let the system choose to go to the right or straight ahead. If all sensors hit something then the character has to go back.

It won’t work perfectly at first, but you need to improve this bit by bit.


Thank You so much,

thats exatly what I was looking for. I’m so blockheaded, it doesen’t even came to my mind to use more than one sensor. Although my first AI has two, but I didn’t noticed :slight_smile: I sure can make something out of this …

1 Like

@Gurki, how experienced are you as a coder? If you have a few years of experience you could throw in some reinforcement learning algorithms that would really make your characters learn like a human would!

I’m not realy that experienced… I’ve started with laguages like Cobol or Pascal, Although I’ve switched to java as my first object orientated in the late 90th, I still got my difficults,
Took me quite a time, to bind the ansychronus database in, and I can’t hardly handle eventhandlers… but I’d like to learn about these algorithms. Maby I’m able to simplify one :slight_smile: … I’m more focused on game mechanics … coding is just a tool to implement my ideas

Try this course👆. It’s one of the easiest machine learning courses for beginners in js, and would help you get a lot of ml fundamentals down.

1 Like

If you need any help, let me know!

1 Like

Hey I s There A Way To Give A Neural Network A List Of Outputs And Have It Choose One (IE: Choose A Tile From A List Of Available Tiles)

DevilZ did something like that in TowerTakeDown the neural network analysis the first 60 or so levels, and then choose towers for automatic generated levels…


For the project that @Gurki mentioned, I used the current levels as training data, and then used that to build a convolutional neural network to predict more levels. This will of course change depending on your game.