Game Development Community

How To Make AI Discussion

by Bryce · in Technical Issues · 11/04/2004 (2:44 pm) · 156 replies

I'm making a game called Metal vs. Flesh and I cant figure out how to make AI players.
#101
12/04/2004 (9:00 pm)
I've duplicated your errors, my first question would have to be whether or not the current .exe for RW is compiled with the AIPlayer.cc and AIPlayer.h files in the project.

If they are, then we shouldn't be getting the errors for the conobject.

Interesting. I'll try a few other things.
#102
12/05/2004 (4:19 pm)
Yes I'm still involved a little bit with the rw project. I'm not sure if they are compiled with them or not, although even of a new build a aiplayer.cs file exists in the d/l from gg. So t might be but I'm not certain.
#103
12/06/2004 (5:10 am)
Ahhhh, I've tried tons of stuff in rw, still just cant seem to get a working ai bot for him. What he needs is a simple cut a paste dirty bot just to drop into the game so as it would sense and fire at a player if they come near or even into a trigger. With work at the time being so busy right now, I dont think I will have time to work on this for a while. If you guys come up with a simple cut and paste script just to drop something into RW for him, plz let me know so I can pass it forward and he'll be happy.

@Mark - Thx for all your effort into this. I really appreciate it. BTW if you ever are able to get your AI bot into RW so it works the way you have set it up; email me and let me know. Your bot code has so much potential that it is amazing. It would certianly set some of the RW proggies that I know into fits of astonishment; since RW's pathing engine was ripped out of it.

@Everyone else, keep up the good work. You guys are awesome.

I'll keep checking in to see whats going on in this thread, if anything to help out the RW guys. And when work slows back up I'll definately be back in here helping to figure things out with you guys.
#104
12/07/2004 (8:43 pm)
@Mark: Can you copy me (my emails in my profile) the location to your resource? I'd like to check it out if you don't mind and see if it can at least point me in the right direction with my fiddling. No game planned yet just trying to learn the engines ins and outs. Thank you so much for your contributions.
#105
12/13/2004 (10:27 pm)
Hey guys, take a peek at what's next...

Should have the resource ready in the next day or two.

users.ev1.net/~lostknight/ctf1.wmv

users.ev1.net/~lostknight/ctf2.wmv

users.ev1.net/~lostknight/nav1.wmv
#106
12/13/2004 (10:42 pm)
Nice work Mark! You do a great job!

Nick
#107
12/13/2004 (11:05 pm)
Mark

Since you don't have an email listed do you mind contacting me at mine?

TIA
#108
12/14/2004 (12:47 am)
I get path errors on all the links.... Hey Gonzo.... hows the Ai .plan coming ???? Can't wait ...
#109
12/14/2004 (8:11 am)
Phil, Sorry bout that I forgot you're a MAC user. I think you might be getting problems because the files are in WMV format.

What file formats can you view for video? Let me know and I'll see if i can make one for you.

Gonzo: Email sent.

Nick: Thanks.
#110
12/14/2004 (12:00 pm)
I can view that I have Windows Media Player 9 , even a direct d/l of the file pukes WMP
Can you do QuickTime?
#111
12/14/2004 (12:51 pm)
Odd... I can't do quicktime. I can do .AVI though.

Here's a thought though. Check to see if there are any updates for your codecs. If I'm using a newer version than the one you have it could be causing the upchuck.

I'll try to post the AVI later, and may a screen shot or two.
#112
12/14/2004 (12:56 pm)
V9 is it for the Mac, Micro "trash" always likes going their own path. Luckily the viruses and spyware follow :o)
#113
12/16/2004 (8:17 pm)
Mark is there any estimated release date for the New AI?
#114
12/16/2004 (8:55 pm)
Not at the moment. I haven't had the time to work on it much the last couple of days. I've got about half of the resource written up for it, but still have the rest to work out.

I'll definitely let you guys know as soon as it's ready to go.
#115
12/16/2004 (8:58 pm)
I watched the movies, looking very nice! One question though--I am assuming that -all- of the actors were AI?

If so, it definitely looks impressive and a great middle ground solution!
#116
12/16/2004 (9:16 pm)
Yes, the 6 bots were all AI. My player was actually standing way off in the corner pouting. :)

Since the videos were taken, I've built a different simple map that I'll be able to distribute as a demo ground with the project when I get the resource finished and written up.
#117
12/17/2004 (11:28 pm)
Mark I have some question for you:

1- are you planing to add team ai for the new AI resource?
2- What are the new improvment you plan to add?

regards
#118
12/18/2004 (8:00 am)
The new resource is mostly about the navigation system that controls where the bots go and how they get there. It started out because I wanted to revise my old bots to be able to navigate without getting stuck.

As of right now here's what I've done.

Created a waypoint based navigation system that allows you to add points in your maps to set where your bots go.

Coded an algorithm based on A* that allows you to simply say 'SetBotOnPath(%bot, %tgt)' and it creates a path for the bot that will take it from it's current point to the target object via the waypoints.
There's a function built that allows you to walk and drop nodes as you walk around.

To demontrate the functionality of the navigation and just for some fun I've built a simple CTFBot and a simple ctf script file.

When adding waypoints you give one the type 'RedFlag' another 'BlueFlag', then you can also give other nodes types of RDefend and BDefend. This tells your bots what positions to take up when they are put in "DefendTheBase" mode.

The CTF script loads the flags, and sets their position at the appropriate node, loads the defense points into arrays to make them easier to access later, and loads the CTF bots.

For now I'm still using the same way of adding the bots - a marker at a specific point. I know it would be fairly simple to use the Spawn spheres and have them drop in at random points - but I really wanted to work on a navigation system. On a bot's marker you add the 'team' variable to be 'Red' or 'Blue' and then when they spawn they know who they are.

Anyway, the new bots are customized for CTF.
They have two standing orders "Offense" and "Defense"
There is a set of decisions at the top of the 'think' function that helps them decide what they should be doing based on the status of their flag and the teams flag.

For instance - if the bot is on defense - but it somehow ends up with the opponents flag - it gets kicked over to Offense.

When it checks to see what it should do on Offense - it is told that since it is the flag carrier it needs to 'CapTheFlag' so it starts heading back to base.

It's all fairly simple logic - nothing great. Again - I wasn't aiming to make the best CTF game. I just wanted something that could give me the ability to run multiple bots, and have them have a purpose while I was working out the kinks in the nav system.

The current script does display the score in the message window, but I haven't added any GUI's to select a team for the player and such. Right now to join a team - you just add a team="Red" or team="Blue" into the players datablock and they're set.

If someone were to seriously want to expand this into a fullblown CTF -the basis is there, but the pretty wrappings would have to be added. There are some 'team orders' built into the CTF script that will do such things as send all the blue team to defense mode, or the reds to offense, etc.

Now to make a true team based deal - You'd have to create a gui to select how many bots, and what team you want the client to be on when they join the game.
Then you'd have to add a team script to handle balancing the teams, etc... I'd basically have the checkteambalance code called when a client was added, or at the end of a round.
In that code you'd have to do your checking to see if the teams were fairly balanced, and be able to drop off an extraneous bot to balance them if so desired to keep the team numbers even. Simple stuff.

Then inside there is where I would put the codes to issue 'teamorders' - which would basically probably consist of displaying a message to human players, and then running a random based chance for each bot - to determine if they were going to follow that order. (You would also want to trap certain bots like the flag carrier - from coming to help you - etc...)

That would get you going on the right path.

I hope that answers your questions Firas, and I apologize about being slow in getting this finished up - ran into a few personal issues that have been slowing me up.
#119
12/18/2004 (8:05 am)
One other thing to add:

I've built a simple map - not the one in the demo videos that can be used with the basic starter.fps resources that I intend to include.

Also I want to point out something else, with the exception of adding one new file to handle the arrays (from a resource already on GG), and the two new class declarations for the CTF bot - everything is done in script. That means a recompile is necessary, but all of the real meat of the navigation system and the AI is in script. Which may make it slower, but it does allow for non C programmers to tweak it and do what they want with it.
#120
12/18/2004 (11:33 am)
Mark this is great, do you know when I see your name on any post I will so happy to read it :), keep up the great work what else I can say this is one of the greatest resource here in GG tell now.