Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

[FINAL] Artificial Intelligence concept V3

Share questions, scripts and tutorials related to the ScriptAPI in SFD.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

[FINAL] Artificial Intelligence concept V3

Post by JakSparro98 » Mon Jan 09, 2017 11:18 pm

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
Last edited by JakSparro98 on Fri Aug 31, 2018 5:02 pm, edited 20 times in total.
14 x

Dumby Eggy
Superfighter
Superfighter
Posts: 66
Joined: Wed Dec 21, 2016 4:22 am
SFD Account: Huevon NEO
SFD Alias: Huevon SFD
Started SFD: PreAlpha 1.8.8
Location: Honduras
Gender:
Age: 21

Post by Dumby Eggy » Fri Jan 13, 2017 9:16 pm

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.
4 x
HINT: You will not surprise me if you are good with snipers and magnums and katanas; but I will give my respect for someone who is a weapon-master. So don't wait any cheer marksmen...8-)

User avatar
Rhodes
Superfighter
Superfighter
Posts: 83
Joined: Wed Sep 21, 2016 12:48 pm
Title: I am Rhodes!
SFD Account: Rhodes
SFD Alias: Rhodes
Started SFD: August 2015
Location: I'm...right beside you bro!!
Gender:
Age: 19

Post by Rhodes » Sun Jan 22, 2017 5:56 am

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.
Last edited by Rhodes on Tue Feb 07, 2017 2:25 pm, edited 4 times in total.
0 x
IF YOU PLAY SFD I'M COMING AFTER YOU!!

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Sun Jan 22, 2017 3:31 pm

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.
0 x

User avatar
Rhodes
Superfighter
Superfighter
Posts: 83
Joined: Wed Sep 21, 2016 12:48 pm
Title: I am Rhodes!
SFD Account: Rhodes
SFD Alias: Rhodes
Started SFD: August 2015
Location: I'm...right beside you bro!!
Gender:
Age: 19

Post by Rhodes » Tue Feb 07, 2017 2:16 pm

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)
0 x
IF YOU PLAY SFD I'M COMING AFTER YOU!!

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Tue Feb 07, 2017 3:10 pm

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?
0 x

User avatar
Rhodes
Superfighter
Superfighter
Posts: 83
Joined: Wed Sep 21, 2016 12:48 pm
Title: I am Rhodes!
SFD Account: Rhodes
SFD Alias: Rhodes
Started SFD: August 2015
Location: I'm...right beside you bro!!
Gender:
Age: 19

Post by Rhodes » Wed Feb 08, 2017 10:13 am

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.
0 x
IF YOU PLAY SFD I'M COMING AFTER YOU!!

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Wed Feb 08, 2017 11:59 am

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 ;)
1 x

User avatar
Rhodes
Superfighter
Superfighter
Posts: 83
Joined: Wed Sep 21, 2016 12:48 pm
Title: I am Rhodes!
SFD Account: Rhodes
SFD Alias: Rhodes
Started SFD: August 2015
Location: I'm...right beside you bro!!
Gender:
Age: 19

Post by Rhodes » Thu Feb 09, 2017 5:11 pm

Jak....
I tested out your script...didn't understand it much but when i tested it my mind was...BLOWN :o
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! :) ;)
1 x
IF YOU PLAY SFD I'M COMING AFTER YOU!!

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Sun Feb 12, 2017 7:18 pm

Rhodes wrote:Jak....
I tested out your script...didn't understand it much but when i tested it my mind was...BLOWN :o
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?
0 x

User avatar
Rhodes
Superfighter
Superfighter
Posts: 83
Joined: Wed Sep 21, 2016 12:48 pm
Title: I am Rhodes!
SFD Account: Rhodes
SFD Alias: Rhodes
Started SFD: August 2015
Location: I'm...right beside you bro!!
Gender:
Age: 19

Post by Rhodes » Tue Feb 14, 2017 10:33 am

Send the script i have the map :p I wanna see how mean they are...
and yeah i hadnt..
0 x
IF YOU PLAY SFD I'M COMING AFTER YOU!!

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Sun Oct 15, 2017 10:46 pm

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:
► Show Spoiler
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.
2 x

User avatar
Billy
Superfighter
Superfighter
Posts: 285
Joined: Fri Apr 22, 2016 3:56 pm
Title: Owner of a failed Clan
SFD Account: Billy
SFD Alias: Billy
Started SFD: October 2015
Location: Austria
Gender:
Age: 22

Post by Billy » Mon Oct 16, 2017 11:48 pm

Dude, I will check dis out, the gif looks amazing!
0 x
Join Delta Squad today, if you mail me now you will get this cool private rank for FREE, but thats not all, you will also get an imaginary Cookie, so better hurry up!
Yea, ehh, that was a big fail...

User avatar
Noble
Moderator
Moderator
Posts: 482
Joined: Wed Mar 30, 2016 6:46 pm
Title: Modest guy
SFD Alias: Best player
Location: Brazil
Gender:

Post by Noble » Tue Oct 17, 2017 2:25 am

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.
0 x
When I was 22 I read this book
And I swore
"I'll stay my way, I'll stay my way"

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Fri Aug 31, 2018 5:00 pm

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 :cry: ).

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:
► Show Spoiler
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.
3 x

User avatar
KliPeH
Moderator
Moderator
Posts: 914
Joined: Sat Mar 19, 2016 3:03 pm
Title: [happy moth noises]
SFD Account: KliPeH
Started SFD: Pre-Alpha 1.4.2
Gender:
Contact:

Post by KliPeH » Fri Aug 31, 2018 5:56 pm

JakSparro98 wrote:
Fri Aug 31, 2018 5:00 pm
Here is an example of a game with bots in that map:
► Show Spoiler
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.
3 x
 
Image

Post Reply