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

0 favourites
From the Asset Store
High quality sound effect pack, in the following categories: computer voice
  • I found an incomprehensible pattern.

    I can not understand what it is connected with in this layout. Maybe you can help me figure it out.

    in 1 line (at the start of the layout) we destroy the FoodPile object

    So here. If this object is not destroyed, then the ants measure in place.

    Even if we turn off the scripts with FoodPile everywhere and we’re not going to use it, (but at the same time, we’ll leave it in line 1), all ants will move normally.

    How is the destruction of the object FoofPile at the start of the layout with the movement of ants? Considering the fact that we do not refer more to FoodPile anywhere.

    Subscribe to Construct videos now
  • The same situation happens if I try to copy everything completely. That is, I create a new file, copy all the objects from this, all the conditions and simply transfer it to another.

    As a result, the Ants also measure up. File similar to the original. What could be the reason?

    As I understand them, the speed of movement of the post becomes 0. But why is this happening I can not understand

    File

    yadi.sk/d/mt75CqIbw6VMMg

  • I'm not sure what your object with UID2 is, but apparently it does exist so the ant stops because it has nothing to do.

    It found the last path, so failed to find a path is false so it doesn't execute that.

    It arrived at the destination but object ID 2 exists so that's false and it doesn't execute that.

    It has nothing left to do so, it stops.

    + Zombie1: On Pathfinding arrived

    + [DISABLED] System: [X] Object with UID 2 exists

    -> Zombie1: Set Pathfinding acceleration to random(60,150)

    -> Zombie1: Set Pathfinding speed to random(60,150)

    -> Zombie1: Set AntPosX to random(0, LayoutWidth)

    -> Zombie1: Set AntPosY to random(0, LayoutHeight)

    -> Zombie1: Find path to (random(0,LayoutHeight), random(0,LayoutWidth))

    -> System: Wait for previous actions to complete

    -> Zombie1: Move along path

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh I see.

    UID2 is the obstacle. If it exists ANYWHERE you're telling the ant to not find a new path so it stops. You have the original one off to the side of your layout so ID2 does exist.

  • Thank you very much. I removed the line UID 2 but it only helped half. I added a line to check the speed when moving and if it drops to 0 then reload the search path.

    But this is not the right decision. Since UID 2 is food. And if food is absent ants should go about their business.

    That is, we can not remove the UID 2

  • When I ran it, UID2 was the obstacle.

  • Thank you very much. I removed the line UID 2 but it only helped half. I added a line to check the speed when moving and if it drops to 0 then reload the search path.

    But this is not the right decision. Since UID 2 is food. And if food is absent ants should go about their business.

    That is, we can not remove the UID 2

    Hello, I'm glad to see what I did help you.

    WRS so that the zombies can have a random movement you just have to eliminate the UID2 line that refers to foopile, because if you eliminate the line destroy at the beginning of the scene, then the foodpile exists, and the condition says yes there is UID2 so that they move randomly.

    If you want them to only move from one side to another, just remove the UID2 line, that's it, I already tested it in the original file and it works.

  • Thank you very much, you not only helped but also broadened my horizons about the possibilities of the designer)))

    I will wait for more cool examples from you!)

  • WRSOf course, I have more ideas for this simulator since it is helping me to learn many things, I plan to make the ants dig their own caves like an anthill of acrylic, there will be a queen that will generate the ants, and the worker ants will have to to be able to grow their food so that it becomes the mushroom they can eat, they will have a system of hunger and thirst and I was thinking of making a pheromone system but it would complicate my life, so for now I will not, maybe I will I'm late in uploading videos because I'm with other projects and this project I'm doing just as a learning method.

  • Found this to be a fascinating subject. Apparently there's been a lot written on group behaviour and lots of code written to simulate ants, flocks of birds and schools of fish.

    So, I decided yesterday to play around with this a bit. Here's my half-assed attempt at ant AI

    twistedvoid.com/antz

    I'm only using a maximum of 300 ants so that it runs on my old laptop well. Since each ant is animated I didn't want to lag things out with gobs of ants.

    Ants exit the ant hill periodically and begin searching for food in a mostly random pattern. If food is located, it then uses the pathing behaviour to find it's way back home. As it travels back home it looks for a trail of 'pheromones' to see if another ant has found the food and went home. If so, it refreshes the trail. If not, it lays a new trail. The trail lasts 10 seconds if not refreshed.

    Rather than pathing, the trail is used to help ants find the food source (somewhat like real ants).

    Ants that step on the trail examine it to see which way the trail points and then, attempt to follow it's direction to the food source. Since they don't yet know if the food exists, they don't refresh the trail.

    Each food item has 100 points and each time an ant takes some it reduces those points by 100. If the food reaches 0, it despawns.

    When ants carrying food return to the ant hill, they despawn.

    If an ant has been wandering around for a while and steps on the ant hill, it despawns.

    You can download this very crude experiment here:

    twistedvoid.com/antz/Antz.c3p

  • Faced a critical error.

    I use this example for my project, but when converting it to xCode, the behavior of the ants stopped working.

    I tried to convert the author's source file and it also does not work on an iOS device. What could be the reason? For some reason, the scripts on the device are not running.

    Ants will not be removed on condition that the path is not found.

  • I'm not quite sure what's going on. When I first uploaded it, it crashed to a white screen. Ashely correctly diagnosed this and clearing the browser cache fixed it. On another run, the ants were all blinking.

    Since I don't own any apple products, I can't help you there.

  • The file in the browser works fine. This confused me.

    On the iPhone, path finding for 99% of instances stops working.

    I tried to give a delay before the start, I tried to activate the scripts after some time. But nothing helps. 1 ant out of 20 can start running. But the rest are worth it. Moreover, they are not removed if they appear in the walls, it is the same tied to finding the way. I think that something is not being converted as the project works fine in the browser.

  • Well, keep in mind I didn't spend a LOT of time on this and I know for a fact the logic has flaws. For example, I'm not iterating through every ant to see what it's status is or to give it instructions. Consider this to just be a very, very crude idea and a rough example of how to implement pheromones.

  • Found this to be a fascinating subject. Apparently there's been a lot written on group behaviour and lots of code written to simulate ants, flocks of birds and schools of fish.

    So, I decided yesterday to play around with this a bit. Here's my half-assed attempt at ant AI

    https://www.twistedvoid.com/antz/

    I'm only using a maximum of 300 ants so that it runs on my old laptop well. Since each ant is animated I didn't want to lag things out with gobs of ants.

    Ants exit the ant hill periodically and begin searching for food in a mostly random pattern. If food is located, it then uses the pathing behaviour to find it's way back home. As it travels back home it looks for a trail of 'pheromones' to see if another ant has found the food and went home. If so, it refreshes the trail. If not, it lays a new trail. The trail lasts 10 seconds if not refreshed.

    Rather than pathing, the trail is used to help ants find the food source (somewhat like real ants).

    Ants that step on the trail examine it to see which way the trail points and then, attempt to follow it's direction to the food source. Since they don't yet know if the food exists, they don't refresh the trail.

    Each food item has 100 points and each time an ant takes some it reduces those points by 100. If the food reaches 0, it despawns.

    When ants carrying food return to the ant hill, they despawn.

    If an ant has been wandering around for a while and steps on the ant hill, it despawns.

    You can download this very crude experiment here:

    https://www.twistedvoid.com/antz/Antz.c3p

    I find it very interesting but I can not open the file because it was saved in version r158 and I have version r157, could you upload a version for r157 please?

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