AI Tutorial Scripts - sorry, no actual tutorial yet....

Scripting questions, discussions, etc
7 posts Page 1 of 1
rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Sun Feb 08, 2015 6:30 pm
Here are the scripts for my planned, written, and lost AI Tutorial.

https://github.com/RichardRanft/AITutorial

For easiest testing, create a new Full Template project and dump these scripts in on top. There may be some breakage. Report it here so we can figure it out.

It is wiser to merge the scripts using your favorite merge tool. Things to note -

1) You'll have to add exec() calls to get the support systems working.
2) You'll also have to modify /art/datablocks/datablockExec.cs to point to the new aiPlayer.cs location.
3) You'll need to alter the AI datablocks to use a player model of your choice.
4) I recommend removing the weapon inventory loadout in scripts/server/gameCore.cs GameCore::loadOut() except for one "default" weapon - since the unit is loaded out with the weapon specified in its datablock.

The scripts are pretty well commented with document blocks for most functions and methods. I feel that AIManager and AIClientManager are prime candidates for porting into the engine because they do tons of list iteration and sorting.
Johxz
Posts: 441
Joined: Sat Feb 07, 2015 11:37 pm
by Johxz » Mon Nov 16, 2015 4:54 pm
Hi @
User avatar
rlranft


Any advance in the tutorial? Thanks
rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Wed Nov 25, 2015 9:40 pm
Heh, sadly I haven't gotten back around to those - and the last time I looked at them I was having trouble getting my head back into that spot...

I might see what I can do with them over this long weekend.
rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Sun Feb 07, 2016 7:01 pm
Okay, Still no tutorial, and apparently I was too clever for my own good because I can't understand my own scripts. I swear that I'm going to figure out what the hell I was doing and finish this! Eventually....

Upside, they now seem to function correctly with 3.8 (<shrug> didn't change anything but now it doesn't bring the game to a halt when a grenadier tries to calculate firing angle). Anyway....

And performance seems okay, about 10fps with around 50 units (mixed boombots and soldiers) actively fighting, but this seems to degrade so there might be some cleanup that needs to be done somewhere.
TorqueFan
Posts: 87
Joined: Thu Apr 30, 2015 5:35 am
by TorqueFan » Wed Feb 10, 2016 2:09 pm
Just wanted to post here and give a big "Thank you" to Richard for this and all of the works he's shared in the past. I remember when you mentioned this AI stuff in a post a while back ( might have been the old GG boards ) and I've studied the scripts a lot since then. I've built other systems with Managers and so on based off of the concepts put in place here - using a 'Manager' to add/remove objects or even entire new SimGroups!

In case you've forgotten the details, one of the best additions you made was the 'throttling' of AI think routines based on the AI's proximity to Players. Basically making the AI call a think() function but only when Players were near enough. Otherwise, it could go into a 'sleep' mode and not waste any precious resources thinking about nothing =) The biggest thing here is the 'when Players are near enough' bit. It's been awhile since I've looked at that stuff, but I think what needs to happen is this:
  • Server keeps a list of SpawnSpheres.
  • If a Player gets within range of a SpawnSphere, set an 'awake' flag to true on the SpawnSphere.
  • Have a ScriptTickObject( or something similar, anything that 'ticks' ) that constantly runs a function iterating the list of SpawnSpheres searching for 'awake' flags. For each one that's awake, activate the think() routine for the spawned AI belonging to that SpawnSphere. Could have an early out in the function so it won't do the iterations if none are awake( or even not run the function in the first place ).

Just thinking out loud but that's a direction I was looking into going soon.

In my current project, I am VERY near to setting up AI spawnGroups, think functions, and so on. I will be revisiting this stuff and use it much as a reference guide while building the map's AI. It is likely that I could end up porting those Managers you speak of and if that happens I will definitely let you know =) I do agree that with the Sim lookups going on it could be in the best interest of the resource.

For my goals the largest obstacle is figuring out how to approach the adding/removing of the AI units as Players travel across the rather large map. Currently I plan to use the actual Manager object already in Torque ( the one that fires off NetEvents ) that will activate SpawnSpheres - all based on distance from the Player object. Maybe it'll work, maybe it won't?
rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Wed Feb 10, 2016 3:02 pm
Thanks for the feedback. I'm glad someone is getting some use out of this even with the lack of documentation.

The system actually uses each unit's distance from any player-controlled camera to determine its responsiveness. The manager gets player camera positions and then sorts units into "priority groups" based on their distance from the nearest camera. This way players see responsive, active units and units the player doesn't see can downgrade to use fewer resources. It also has priority assignments for units so that you can force a unit to stay awake, or sleep completely when "idle" to allow for RTS combat units (don't want them lying down on the job) or environment units (those wandering sheep can sleep when we're not looking).

Spawning is all manually controlled. The player can press 'b' to spawn a "bad guy" at the camera location, or use the buttons provided to create buildings and then click the buildings to spawn different types of units. I'm going to have to make a couple of buildings to make them visually distinct, I suppose. One thing that seems like it might have broken is the ability to left-click a unit and then click-to-move that unit, but maybe I wasn't being precise enough - needs more testing.

It was the way I had set up AIPlayer and PlayerData callbacks that I was having trouble getting back into my head, mainly because I was trying to do that while troubleshooting an issue with the grenade launcher datablock apparently not loading or some such - it was weird, and it made it a dozen times harder to remember what the hell I was doing....
TorqueFan
Posts: 87
Joined: Thu Apr 30, 2015 5:35 am
  by TorqueFan » Wed Feb 10, 2016 5:13 pm
Thanks for the feedback. I'm glad someone is getting some use out of this even with the lack of documentation.
No problem. It's tutorials and resources like this that inspire others in the community to follow suit.

As usual, I'm staying pretty busy lately but I DO plan on releasing a whole heap of resources when I'm closer to a 'relaxing' period. I've got all sorts of goodies to share, if only I could find time to get it all uploaded...
Spawning is all manually controlled.
Ah yes, I remember that about your scripts now! For my purposes, though, it's a bit harder in this regard since all the AI will spawn in groups randomly about the map. All of it will need to happen on the server's end, probably by use of Events or something...not really sure, hadn't tackled that fully just yet =)
7 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest