Killer Kork, an ai bot
by devans · 07/03/2006 (11:35 am) · 94 comments
Download Code File
Description:
Killer Kork is an ai bot with a purpose (you guessed it), eliminating opponents, but with a twist! With this resource, Kork must use his new-found senses of sight and sound to track down the enemy. If he hasn't seen or heard you, he doesn't 'magically' know you exist. Even with these limitations, you might find him hard to beat!
To use:
Killer Kork is set in the starter.fps scene. Just download and unzip the four files in killer.kork.ai.zip into the starter.fps\server\scripts folder (backup aiPlayer.cs first, if you want to keep the original), and launch. No TGE engine mods necessary, completely script-based.
By default the scripts will create two teams of bots, the Brains and the Algos, which will commence to battle it out. Simply setting the $AIPlayer::TeamCount, you can set how many bots are spawned on each team. It is also possible to set whether the bots will attack human opponents using the isHumanFriendly boolean in the AIManager class (bottom of aiPlayer). By default, 'Evil Brain' and 'Evil Algo' are the only bots set to attack human players on sight.
The files:
..\server\scripts\aiPlayer.cs -low lvl body functions (heavily modified from original)
..\server\scripts\aiAlgo1.cs -high lvl decision-making functions (new)
..\server\scripts\aiSensObj.cs -sensory feedback (new)
..\server\scripts\consoleFunctions.cs -convenient in-game functions (new, not required)
Features:
- Raytrace vision
- Hearing radius
- Basic flocking
- Retrieval of heath/ammo
- Basic obstacle avoidance
- Avoids bodies of water
- Attempts to get 'unstuck'
- Quick 'dodge' function that can happen between think cycles
Bonus:
- Tons of static variables to set various attributes of the bots
- Heavily commented code
- Configurable debug lvl (set through $AIPlayer::DebugLevel, or on the fly with the Con::setDebug function) of messages sent to console (0 error, 1 critical, ...5 verbose)
- Spawn counter for each team (higher number = losing team)
Bot Behavior states:
- Wander (roam the map, keeping an eye on path markers, look for health/ammo)
- Attack (if any enemies are sensed, go get 'em!)
- Search (look for a lost target)
- Respond (react to unknown threat)
- Follow (follow friendly)
- Assist (assist friendly)
Below I'll briefly try to describe some of the finer points of Kork's ai code, which might not be so obvious on first load.
- Kork has a 'center of vision', and a peripheral vision cone. Players in his center of vision have a much better chance of being spotted. Moving targets are also much easier for Kork to spot.
- If Kork has seen an opponent, then subsequently lost sight of them, he will run to the last location of the sighting and start searching from that point
- In battle, Kork attempts to slide away from the direction his opponent's weapon is facing. This tends to make two bots locked in combat weave back and forth, attempting to get out of the way while compensating for their opponent's movement.
- Kork tries to 'snipe' if his opponent is far enough away and not facing his direction, before running in to close the gap. This helps with aim, since only one object is then in motion.
- Kork will be put into a 'Respond' state if he takes damage or senses a nearby explosion without having a target.
- Kork will go to fetch ammo he might have seen immediately if he runs out, no matter what the situation. If he reaches his 'low' threshold of either ammo or health, however, he will only go to fetch if not engaged with an opponent.
- In order to facilitate retrieval of items (i.e., not getting stuck), upon approach a horizontal line is drawn out from the eyePoint, which is then used to check a clear path by raytracing points (default 40 points at 0.3 units apart)from the line to the item. Kork then uses the average of the points that tested 'good' as his approach route.
- To prevent Kork from straying too far, he attempts to stay within range of the path nodes (DistPathMax), but will freely wander around looking for something to do as long as he's seen a path marker within range.
- Since this is based on the stock starter.fps crossbow weapon, Kork will rely on the explosion radius damage of the crossbow bolt by aiming at the feet of a particularly fast-moving opponent. He does, however, do a pretty good job of anticipating the location of a moving target when shooting a bolt.
Additional info/History:
Killer Kork was born as a project to make TGE 'do' something during a visit from my brother last August. It was originally envisioned as a battleground for pitting each our own ai code against the other, but considering my brother's Ph.D. in physics, as well as 10+ years professional coding experience, it quickly became a losing battle for my ai code (which was busy doing 'victory dances' and such on getting a frag... =). The result I'm posting is his code (with his blessing), developed over a two week period, without any previous torque-script experience. That said, it obviously isn't fully featured, optimized, etc, but hopefully a solid starting point for anyone wanting some ai (and can't wait for the 'real deal').
On a side note, re-implementing the original idea of two sets of combating ai code is easily achievable by simply modifying the AIManager class (and uncomment the execute line at top of AIPlayer) to include two different versions of ai code. We were also using a modified .mission file with a second path, where the other team could start somewhat unmolested.
This code comes AS-IS. It was based on TGE 1.3, but I've given it a quick test in 1.4, and everything seems to run fine. Instead of letting it gather dust on my HD, I hope someone finds it useful. If you do use it in a project, or change it in an interesting way, please send me a mail dgevans at hotmail dot com. It was a learning experience for me, and now hopefully others =)
I'd also like to thank Sam Bacsa for Codeweaver (then called TorqueScript Dev?), which we used extensively. It was a HUGE help!
/daniel
Description:
Killer Kork is an ai bot with a purpose (you guessed it), eliminating opponents, but with a twist! With this resource, Kork must use his new-found senses of sight and sound to track down the enemy. If he hasn't seen or heard you, he doesn't 'magically' know you exist. Even with these limitations, you might find him hard to beat!
To use:
Killer Kork is set in the starter.fps scene. Just download and unzip the four files in killer.kork.ai.zip into the starter.fps\server\scripts folder (backup aiPlayer.cs first, if you want to keep the original), and launch. No TGE engine mods necessary, completely script-based.
By default the scripts will create two teams of bots, the Brains and the Algos, which will commence to battle it out. Simply setting the $AIPlayer::TeamCount, you can set how many bots are spawned on each team. It is also possible to set whether the bots will attack human opponents using the isHumanFriendly boolean in the AIManager class (bottom of aiPlayer). By default, 'Evil Brain' and 'Evil Algo' are the only bots set to attack human players on sight.
The files:
..\server\scripts\aiPlayer.cs -low lvl body functions (heavily modified from original)
..\server\scripts\aiAlgo1.cs -high lvl decision-making functions (new)
..\server\scripts\aiSensObj.cs -sensory feedback (new)
..\server\scripts\consoleFunctions.cs -convenient in-game functions (new, not required)
Features:
- Raytrace vision
- Hearing radius
- Basic flocking
- Retrieval of heath/ammo
- Basic obstacle avoidance
- Avoids bodies of water
- Attempts to get 'unstuck'
- Quick 'dodge' function that can happen between think cycles
Bonus:
- Tons of static variables to set various attributes of the bots
- Heavily commented code
- Configurable debug lvl (set through $AIPlayer::DebugLevel, or on the fly with the Con::setDebug function) of messages sent to console (0 error, 1 critical, ...5 verbose)
- Spawn counter for each team (higher number = losing team)
Bot Behavior states:
- Wander (roam the map, keeping an eye on path markers, look for health/ammo)
- Attack (if any enemies are sensed, go get 'em!)
- Search (look for a lost target)
- Respond (react to unknown threat)
- Follow (follow friendly)
- Assist (assist friendly)
Below I'll briefly try to describe some of the finer points of Kork's ai code, which might not be so obvious on first load.
- Kork has a 'center of vision', and a peripheral vision cone. Players in his center of vision have a much better chance of being spotted. Moving targets are also much easier for Kork to spot.
- If Kork has seen an opponent, then subsequently lost sight of them, he will run to the last location of the sighting and start searching from that point
- In battle, Kork attempts to slide away from the direction his opponent's weapon is facing. This tends to make two bots locked in combat weave back and forth, attempting to get out of the way while compensating for their opponent's movement.
- Kork tries to 'snipe' if his opponent is far enough away and not facing his direction, before running in to close the gap. This helps with aim, since only one object is then in motion.
- Kork will be put into a 'Respond' state if he takes damage or senses a nearby explosion without having a target.
- Kork will go to fetch ammo he might have seen immediately if he runs out, no matter what the situation. If he reaches his 'low' threshold of either ammo or health, however, he will only go to fetch if not engaged with an opponent.
- In order to facilitate retrieval of items (i.e., not getting stuck), upon approach a horizontal line is drawn out from the eyePoint, which is then used to check a clear path by raytracing points (default 40 points at 0.3 units apart)from the line to the item. Kork then uses the average of the points that tested 'good' as his approach route.
- To prevent Kork from straying too far, he attempts to stay within range of the path nodes (DistPathMax), but will freely wander around looking for something to do as long as he's seen a path marker within range.
- Since this is based on the stock starter.fps crossbow weapon, Kork will rely on the explosion radius damage of the crossbow bolt by aiming at the feet of a particularly fast-moving opponent. He does, however, do a pretty good job of anticipating the location of a moving target when shooting a bolt.
Additional info/History:
Killer Kork was born as a project to make TGE 'do' something during a visit from my brother last August. It was originally envisioned as a battleground for pitting each our own ai code against the other, but considering my brother's Ph.D. in physics, as well as 10+ years professional coding experience, it quickly became a losing battle for my ai code (which was busy doing 'victory dances' and such on getting a frag... =). The result I'm posting is his code (with his blessing), developed over a two week period, without any previous torque-script experience. That said, it obviously isn't fully featured, optimized, etc, but hopefully a solid starting point for anyone wanting some ai (and can't wait for the 'real deal').
On a side note, re-implementing the original idea of two sets of combating ai code is easily achievable by simply modifying the AIManager class (and uncomment the execute line at top of AIPlayer) to include two different versions of ai code. We were also using a modified .mission file with a second path, where the other team could start somewhat unmolested.
This code comes AS-IS. It was based on TGE 1.3, but I've given it a quick test in 1.4, and everything seems to run fine. Instead of letting it gather dust on my HD, I hope someone finds it useful. If you do use it in a project, or change it in an interesting way, please send me a mail dgevans at hotmail dot com. It was a learning experience for me, and now hopefully others =)
I'd also like to thank Sam Bacsa for Codeweaver (then called TorqueScript Dev?), which we used extensively. It was a HUGE help!
/daniel
#82
Unable to find object: '' attempting to call function 'getShapeName'
Unable to find object: '' attempting to call function 'getPosition'
Unable to find object: '' attempting to call function 'schedule'
I looked at the replies and none of them seemed to help.
12/23/2008 (12:42 pm)
Unable to find object: '' attempting to call function 'init'Unable to find object: '' attempting to call function 'getShapeName'
Unable to find object: '' attempting to call function 'getPosition'
Unable to find object: '' attempting to call function 'schedule'
I looked at the replies and none of them seemed to help.
#83
02/26/2009 (7:05 pm)
this bots are awsome
#84
03/14/2009 (11:22 am)
I put the files into the scripts section, but the bots are not respawning. I used this script before but my hard drive crashed so I lost the data.
#85
I am using TGEA 1.8.1 and the bots seem to only respawn a few times then break for me. This was not the case in TGE 1.5. There is a warning repeated in the code that may have something to do with it - "duplicate datablock" AISensObj and AIAlgo1. "This will cause problems." Investigating...
05/02/2009 (3:24 pm)
Jon,I am using TGEA 1.8.1 and the bots seem to only respawn a few times then break for me. This was not the case in TGE 1.5. There is a warning repeated in the code that may have something to do with it - "duplicate datablock" AISensObj and AIAlgo1. "This will cause problems." Investigating...
#87
06/20/2009 (3:15 am)
not working.. pls help.. it seems so simple but it wont work for me.. i downloaded the 4 files and placed them in server/script.. i started stronghold but all i c is kork running around as usual.. pls help..
#88
06/20/2009 (8:09 am)
nevermind.. i tried deleting all the dso.. it works now.. n ya, awesome bots.. found it very useful to do some of my college project.. :) thanks a lot for sharing it..
#89
But great resource, have been playing around with it, but im also getting the only one bot spawning issue.
If i try envoking the ::think command it spawns one bot pr. time i do it, all EVIL BRAINS.
In stock stronghold it works like its supposed too, just cant get my head around this one...
im using 1.8.1 with the GMK, but without the GMK aiBot scripts.
Any Clues anyone?
thx
Sebastian
10/13/2009 (12:00 pm)
Hi, first off, i know im a tad bit late :PBut great resource, have been playing around with it, but im also getting the only one bot spawning issue.
If i try envoking the ::think command it spawns one bot pr. time i do it, all EVIL BRAINS.
In stock stronghold it works like its supposed too, just cant get my head around this one...
im using 1.8.1 with the GMK, but without the GMK aiBot scripts.
Any Clues anyone?
thx
Sebastian
#90
But really I would love to get my hands on these they still sound so awesome :D
Thanks
MJ
10/29/2013 (11:15 pm)
I know this Post is Ancient... But Does anyone still have these files somewhere ? Maybe in one of those folders :P you know.. "Stuff/OldStuff/NewOldStuff/CoolStuff/Codes...." lolBut really I would love to get my hands on these they still sound so awesome :D
Thanks
MJ
#92
04/18/2015 (9:53 am)
can anyone share this?
#93
04/22/2015 (11:07 am)
http://www.killerk.com/download/10278.killer.kork.ai.zip
#94
04/23/2015 (7:23 am)
Thank you Charles! 
Torque Owner Pneumatic