Page 1 of 1
[FINAL] Artificial Intelligence concept V3
Posted: Mon Jan 09, 2017 11:18 pm
by JakSparro98
Hi all Superfighters community,
in this thread you can find all my Artificial intelligence scripts for CPU fighters. Don't be too excited for this, it's only a demostration of how much ScriptAPI can be pushed so far and however it will be soon forgotten and replaced by the official one in the release update.
FEATURES
- advanced and modular pathfinding ,path nodes can be enabled or disabled based on situation (destructible objects like scaffoldings can influence path result).
- ability to use ladders, grab corners and drop from platforms.
- ability to roll in tiny spaces or when on fire.
- ability to shoot on sight and avoid shooting teammates based on real raycast algorithm.
- ability to block thrown weapons/objects (even when on ladders).
- ability to pickup primary and secondary weapons on the ground.
- ability to do some melee combat moves.
MISSING FEATURES:
- ability to travel over portals (due for a Beta 1.0.2c game bug)
- ability to pick up medkits, throwables and melee weapons (planned for the next AI version).
- ability to recognize weapon crates by type.
- manual elevator usage.
- bazooka riding.
- dodging bullets .
Make sure to check this thread periodically, also take a look to the status updates, I will try to keep the latter always filled with the latest news. I'll make at least one new version every time the game is updated and when the API changes significantly for the development of the project.
Download 1.0.2c prototype:[template map] [facility map converted]
VERSION HISTORY:
Download 1.3.4c prototype
Download 1.1.1b prototype: [original] [ 1.3.4c compatible]
WARNING, DO NOT USE THIS FOR FINAL MAP PROJECTS, ONLY FOR TESTING PURPOSE
I know perfectly I'm not the best scripter/programmer, this third generation of bots are more optimized than the others two, but still cannot be involved in something playable, I tried to put them in an official map converted to work with bots, they are mediocre in terms of performance.
If you are a coder and you feels able (and courageous because the code wasn't supposed to be maintained by thirds, it could be difficult to understand) to mess with the code, I will very happy to see some modifications proposed to enhance this code.
KNOWN ISSUES
- If a bot's internal state changes in the very first time he's spawned it will result in a idle-like bot, this can happen when a bot spawns near an enemy, is knocked by a grenade, etc...;
- Due for a game bug sometimes the bot will jump undefinitely and for no reason (1.0.2c);
- Sometimes the aim system gets stuck and the bot will try to shoot without taking aim;
- Sometimes dives aren't performed properly and the bot will run towards the target instead;
- Often bots gets stuck in the ladder drop state;
- Sometimes bots cannot drop from a ladder because they are in cover;
STATUS UPDATES:
► Show Spoiler
Feb 18 2017- With the new Alpha 1.2.0 I can fill a lot of gaps but at the same time it will make me rewrite most of the AI code since the new player commands replace my work and even simplify it

Currently I'm focusing on writing a better raycast.
Apr 17 2017- Finished to
write struggle with the new raycast system, I have to thank ShutDownMan for the concept behind and also for helping me solving lot of issues. But before seeing the raycast in action I need to "teach" the NPC how to use all the environment around him in order to reach his target (using ladders, platforms, jumping, waiting moving platforms to be at same level, etc).
I'm going rewriting the pathfinding for behaving more or less like in the old SF, now I have the tools for doing it.
Jun 03 2017- Something is moving! The movement system of course

. It's done, little polishing will be required but I'm pretty satisfied so far.
Here some examples:
Now it's the turn of collecting guns and the shooting system, but since the new raycast is almost done I've only to insert it to the NPC class to make bots to shoot.
Oct 15 2017- Version two released on SFD 1.3.4c, I did it! I managed to finish in time for the first official one AI! And now I think I will take a break from this project, maybe. Anyway I need to make all the official maps playable with the AI!
Aug 31 2018- The journey ends here, Version Three has been released today, and with it the ScriptAPI AI concept stops updating, the main reason I started a project like that was to prove that scripted bots were possible in early stages of the game, without proper tools to work with and above all before the introduction of something to use official ones' AI.
But where a journey ends, another begins. I won't stop making scripts and other contents, just I will move on something new.
Re: [UNSTABLE] Artificial Intelligence concept
Posted: Fri Jan 13, 2017 9:16 pm
by Dumby Eggy
Oh shit this is quite impressive. I've never seen someone doing a great AI using a simple TutorialA concept. I want to see the Alpha 1.2.0, so you can make it better, keep working dude.
Re: [UNSTABLE] Artificial Intelligence concept
Posted: Sun Jan 22, 2017 5:56 am
by Rhodes
Isn't there a way to check if the player is in front of the CPU? That way you could set it to fire in that precise direction.(Idk how to implement this, just saying.
Re: [UNSTABLE] Artificial Intelligence concept
Posted: Sun Jan 22, 2017 3:31 pm
by JakSparro98
Rhodes wrote:Isn't there a way to check if the player is in front of the CPU? That way you could set it to fire in that precise direction.(Idk how to implement this, just saying.
There's a way to get the distance from the bot to the target and if it is in a specified range you can spawn a fire node in the player position, but what exactly could solve this? since that when a player is enough close to the bot it activates the meele attack.
Re: [UNSTABLE] Artificial Intelligence concept
Posted: Tue Feb 07, 2017 2:16 pm
by Rhodes
JakSparro98 wrote:
There's a way to get the distance from the bot to the target and if it is in a specified range you can spawn a fire node in the player position, but what exactly could solve this? since that when a player is enough close to the bot it activates the melee attack.
Couldn't you freeze the bot or something? Stop it from walking, or spawn an invisible block affecting ONLY the bot?(Yet again, idk how to implement this)
Re: [UNSTABLE] Artificial Intelligence concept
Posted: Tue Feb 07, 2017 3:10 pm
by JakSparro98
Rhodes wrote:JakSparro98 wrote:
There's a way to get the distance from the bot to the target and if it is in a specified range you can spawn a fire node in the player position, but what exactly could solve this? since that when a player is enough close to the bot it activates the melee attack.
Couldn't you freeze the bot or something? Stop it from walking, or spawn an invisible block affecting ONLY the bot?(Yet again, idk how to implement this)
Let me understand, do you want the npc stops when is enough close to the player? And then do you want it spawns a fire node in the player direction? Or do you want to make the npc shoots fire nodes rather than using his gun?
Re: [UNSTABLE] Artificial Intelligence concept
Posted: Wed Feb 08, 2017 10:13 am
by Rhodes
Well, as you posted earlier, if we can stop the CPU from attacking when it is close to the player, THEN spawn a fire node, that would look cool. Also, to use gun, you can use Game.SpawnProjectile(If there were a way to make the CPU pick up stuff, then check what it has picked up, then we could spawn the corresponding projectile, that would be cool.
Re: [UNSTABLE] Artificial Intelligence concept
Posted: Wed Feb 08, 2017 11:59 am
by JakSparro98
Rhodes wrote:Well, as you posted earlier, if we can stop the CPU from attacking when it is close to the player, THEN spawn a fire node, that would look cool. Also, to use gun, you can use Game.SpawnProjectile(If there were a way to make the CPU pick up stuff, then check what it has picked up, then we could spawn the corresponding projectile, that would be cool.
Yes, currently cpu stops near the player and attack him with melee, anyway if you want this specific change from melee attack to fire node attack there's no problem, I will provide you the prototype in a new post soon.
For the pickup system (I said this when I released the cpu concept), I will wait until the next update comes out, it does not make sense make a script that will be repleaced by new API commands the next version

Re: [UNSTABLE] Artificial Intelligence concept
Posted: Thu Feb 09, 2017 5:11 pm
by Rhodes
Jak....
I tested out your script...didn't understand it much but when i tested it my mind was...BLOWN
VERY impressive work MAN!!!This is amazing!
-Now for the details-
I started the map. The CPU started running after me, assault rifles in their hands! Jak, VERY amazing work getting the rifles to follow them. And you said "line of sight wasn't very accurate". I mean, really? They are awesome! Punching, running, pathfinding!Shooting!
They remind me of medium level CPUs from the Flash SF. Sadly(for us) they seem to have infinite ammo...(might wanna fix that) also they can't pick up stuff, but still...their pathfinding is great! They closed in on me from BOTH sides, thorugh the mesh. Amazing work! Hope the next update helps you make it EVEN better!
-Keep scripting!

Re: [UNSTABLE] Artificial Intelligence concept
Posted: Sun Feb 12, 2017 7:18 pm
by JakSparro98
Rhodes wrote:Jak....
I tested out your script...didn't understand it much but when i tested it my mind was...BLOWN
VERY impressive work MAN!!!This is amazing!
-Now for the details-
I started the map. The CPU started running after me, assault rifles in their hands! Jak, VERY amazing work getting the rifles to follow them. And you said "line of sight wasn't very accurate". I mean, really? They are awesome! Punching, running, pathfinding!Shooting!
They remind me of medium level CPUs from the Flash SF. Sadly(for us) they seem to have infinite ammo...(might wanna fix that) also they can't pick up stuff, but still...their pathfinding is great! They closed in on me from BOTH sides, thorugh the mesh. Amazing work! Hope the next update helps you make it EVEN better!
-Keep scripting!

Thank man, I really appreciated

So you didn't tested the concept yet when you asked me to spawn a fire node in front of the NPC? So now, I still have to send the experiment you asked before or not anymore?
Re: [UNSTABLE] Artificial Intelligence concept
Posted: Tue Feb 14, 2017 10:33 am
by Rhodes
Send the script i have the map :p I wanna see how mean they are...
and yeah i hadnt..
Re: [UPDATED] Artificial Intelligence concept V2
Posted: Sun Oct 15, 2017 10:46 pm
by JakSparro98
Hi all,
I'm here again to show you the overhauled AI script before the very first bot will come in the next update expected for the end of the Month.
This thread will be recycled and updated to bring new versions untill a mature artificial intelligence will come out officially,
all the previous and the current version of the code in the main post.
here an epic two team CPUs fight:
A great thanks goes to ShutDownMan for the collaboration in making the new (real) raycast system!
I'm also going to convert all the official maps to test if my little beast is ready to handle real maps, with chaotic situations and changes in the path morphology (yes I managed to handle also that).
Oh, and Gurt, I hope you will read this, I never wanted to challenge you making an AI when you said me multiple times that scripting isn't intended to be used to create an AI, I was only making you to know how powerful your APIs are, and for this reason they deserves to be fed more and more; APIs aren't a niche feature.
Important note:
This version is more heavy than the previous one, with constant lag spikes due for not so much optimized code (but this doesn't mean I didn't optimized it at all, before the introduction of coroutine in my code, the whole script was run at 10 fps, the script wasn't supposed to run in async and I may made some mistakes in optimization), more code even means more bugs and if you think you've found one let me know (provide me something to replicate the issue in some way).
If the game is too laggy for you, try to lower the number of NPCs by changing the repeat count in both two TimerTrigger above the RandomTriggers.
Re: [UPDATED] Artificial Intelligence concept V2
Posted: Mon Oct 16, 2017 11:48 pm
by Billy
Dude, I will check dis out, the gif looks amazing!
Re: [UPDATED] Artificial Intelligence concept V2
Posted: Tue Oct 17, 2017 2:25 am
by Noble
You are always doing these amazing stuff with API right before an update. But for sure you proved incredible things and AIs can be done with script, I thought that wasn't even possible.
Re: [UPDATED] Artificial Intelligence concept V2
Posted: Fri Aug 31, 2018 5:00 pm
by JakSparro98
Hey all, I'm again here, (and for some suspicious reason) like the others times before a major update, to post the latest researches about the AI script concept, we've reached the third generation gentlemen.
All the previous and the current version of the code in the main post.
After the zombie AI addition I realized that, for some weird reason, about the 80% of the logic behind the official bots was almost the same as the one I chosed for mine, It was good to know that I used the correct approach for the problem.
But It was also good comparing the scripted bots' skill with the official ones (as expected mine were terrible) even to know how much I should have pushed their abilities; I was come into conclusion that something was missing, and decided to keep working for adding more mobility to the bots (I was thinking of make a break after the V2 release, but this never made it happen

).
And for more mobility I mean jumping on moving hanging crates (reducing fallings thanks to special waypoints attached to it) or even roll in case of fire or to pass through small spaces, and finally to ledge-grab as zombie bots do. To demonstrate most of this new behaviours I've converted the map "Facility" into a bot-friendly version, bugs won't let me alone, and this last version even suffers two game bugs that will ruin the user experience, one of this on facility map isn't visible because it involves portals travelling as
this report explains, the second basically mess the whole movement system and makes the bots to
jump like jerks.
Here is an example of a game with bots in that map:
We have reached the end gentlemen, this is maybe the last update for this ambitious project to prove the real power of scripting in SFD. It was a challenging experience, and an opportunity to grow myself in programming skills, in these almost three years of self learning I discovered the real meaning of scripting for real time applications, it involves constructs of which I was unaware; things like asyncronous functions, state machines and such are now a big treasure gave from the time I've spent on the project. with this I don't want to say I will stop making scripts but when the release version of the game will come out, it doesn't make sense try to develop an AI in parallel with a more robust, fast and most of all built-in, I will likely to move on other uncharted waters.
Peace.
Re: [UPDATED] Artificial Intelligence concept V2
Posted: Fri Aug 31, 2018 5:56 pm
by KliPeH
JakSparro98 wrote: ↑Fri Aug 31, 2018 5:00 pm
Here is an example of a game with bots in that map:
That's incredible. I was watching a brawl and I was all like "lmao this dude getting owned by a bot" but then I realized that dude
was another bot; their behavior is almost human-like. An amazing feat achieved by a clever scripter and the existing features of the script API system. This may become obsolete in the future but you always have this project under your name to showcase your talent and great script-making ability.
Thanks for putting this much effort into your work and sharing it with us!
Here's a link to the fullscreen GIF for those struggling to see what's actually going on in the fight.