How can I do artificial intelligence like this in construct 3?

  • youtube.com/watch

    Since I saw this video I have not been able to get out of my mind the idea of doing something similar in construct 3, unfortunately I have no experience in artificial intelligence, but maybe someone can tell me what could be a good starting point, know which way take in my research and creation of this algorithm.

    For now I just want to get the subject to detect where the food is and take it from point A to point B, and when there is no food that has that characteristic behavior and movement of the ant.

    If I can get a starting point I will share my progress and how I have been doing it openly in the forum.

    Note: I ask for an advance apology for my English.

  • Pathfinding behaviour : find path to food. On arrived (at food) find path to location B.

  • From a quick look at the code it appears that each instance of an ant runs it's own set of code to determine the pathing and searching behaviour. Because of this, I highly suspect that trying to duplicate that many ants in C3, each acting independently is going to be a challenge as the software that runs all of that doesn't have the overhead of a browser to manage as well.

  • The video seems to suggest they are creating a flow graph for the space. Each grid cell contains a vector saying what direction an ant needs to go to get to the food. The graph only needs to be updated if the space changes. Per tick each ant looks up the grid cell it's in, and moves in the direction the cell contains. If they have food they go in the opposite direction.

    I've done some stuff in the past similar to this for particle simulation, it's relatively easy. The hard bit is generating the flow graph. I expect red blob games has an article on this technique though.

  • Comes under the "all sources, one destination" category apparently. Usefully this article specifically covers this technique for making a tower defence game. It's obviously not using Construct, but he explains the concept as opposed to showing code so it should doable.

    You want to produce a "vector field" for your ants to follow.

  • Fluid flow vector fields are outlined in this article. This isn't artificial intelligence but it is a cell by cell calculation.

    dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf

  • Comes under the "all sources, one destination" category apparently. Usefully this article specifically covers this technique for making a tower defence game. It's obviously not using Construct, but he explains the concept as opposed to showing code so it should doable.

    You want to produce a "vector field" for your ants to follow.

    Yes, I was analyzing a bit more the video there is a moment of the video where you can see some lines, apparently it is where the ants move and this line is painted blue, establishing a diameter that tells the ants that there is a cave, but on the other side the diameter is painted yellow.

     What I could deduce is that the ants inside the diameter detect the coordinate where the food is and when having a piece of food their destination is the coordinate where the cave is, basically it is as said plinkie, it is a Pathfinding, since the Pathfinding is Handles by 16x16 grids in its natural state.

    Reviewing the article that you sent me from Red Blob Games, I see that your example has the same behavior as Pathfinding, when frontiers are redrawn, and doing some tests today with Pathfinding, I could do that in real time while traveling the subject from point A to point B if you place an object recalculates the route to point B without establishing a cut in its route, this is achieved only with an object.

  • youtube.com/watch

    Hello everyone, I told you that I was working on the idea in my free time and here I share the first results.

    This simulation was done with a swarm of 1000 ants, in the tests it reaches up to 3,000 ants but unfortunately the program broke.

    In the video you can see that it manages to give them an autonomous behavior for each ant, although all the ants on the screen are multiple instances of the same object. A very interesting behavior that I do, is that the ants go to the place where I clicked on the screen and then continue with their autonomous behavior, I did it this way because it is the beginning of the behavior I want them to have when they get food.

    Another behavior that I gave them is to update their route in real time when I press any key on the keyboard, of course it is not ready yet and they are still very robotics, but I hope I can improve it, if they have any comments, opinions or suggestions it will be a pleasure to receive them.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi, excellent result, is the number of objects with finding the path and the system does not slow down? Please help me figure out how to implement this. This example would help me a lot with the implementation of my project.

  • Hello WRS, in this project what I did was create a single sprite for the ant and then create multiple instances of the ant.

    To the sprite of the ant add its own variables of instances in this case the variables keep the coordinates generated by the system in a random way and so each instance of the ant behaves independently since each instance keeps its own random coordinates in the instance variables

    At the moment the simulator is a bit more advanced than in the video, they already have a different behavior and look for food, but now if I'm starting to have a bit of memory problems, as soon as I solve it I'll post a new video with the results here and what I did to improve it.

  • I am unfortunately very far from programming, and as you described this next level, I have not yet been reached.

    Could you share the project? Or show an example of what variables, how to set them up? I am stuck in my project at this moment if I use the functions to find the path, then the system hangs already for 500 copies, and this is only a simplest way search.

    I really need your decision, because I myself can not figure out how to generate such behavior of my enemies and despite the fact that they then all gather at the point that you are pressing ... This is just awesome.

    Here is my mail boss.onjfw@ya.ru I would be grateful to you all if you would help me solve this problem.

  • Really nice work, I have been playing with using a pathfinding library (Easystar) and have found that at about pathfinding actors it starts to slow down a bit. This looks really nice going up to a higher actor count and with more interesting behavior. Looking forward to see more of your work on this.

  • youtube.com/watch

    Hi everyone again, in this video you can see a bit of the progress I've had with the simulator, I have not had a significant progress because I've been busy with other projects.

    In this occasion they can observe how the ants can go for the food and establish a route to the cave and after leaving the food again establish a route to the food while it exists, when the food no longer exists in the scene the route disintegrates.

    In the upper left corner, place a real-time fps counter and a counter of objects created in the scene so you can observe the performance at runtime.

    If you are interested a little more about this project, you can download the original file that I have been working on from here, something very important to note is that the comments are written in Spanish because it is my native language, I hope it will help them in something .

  • Great work sir, thanks :-)

    Now in English and with tiny changes.

    drive.google.com/file/d/1eGWb-DQhD-bwpV-wVgv419KuzqlounxZ/view

  • Thanks a lot, now I see what my mistake was. You rescued me! 1000 thanks again !!!!!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)