PDA

View Full Version : How do you program AI with Lua?


Blorx2
2005.04.23, 03:45 PM
Ok, I've gotten the basics of Lua down. Now, how do I program AI with it?

Duane
2005.04.23, 03:52 PM
one can program AI in any language. Think about what you would do in the enemies position, then implement it.

Blorx2
2005.04.23, 03:56 PM
ok, that advice helps but I mean how as in how do you automate it without having to use more keys?
(I'm not looking for sample code just what type of command I should use)

Duane
2005.04.23, 04:00 PM
you just draw it's position on the screen... Have you thought through how the game works? the player is drawn on the screen at pos x and pos y, and the coords change when you press a key, but it can also change without keypresses.

Blorx2
2005.04.23, 04:06 PM
Ok, thanks Nayr

jspoon
2005.04.23, 04:08 PM
First paint your head red. Then take your shirt off to expose your manly chest. Next, get some boxing gloves, or if you don't have boxing gloves, oven mitts will do. Next, duct tape some aluminum foil to some twine. And finally, get your mom to program you an AI.

Seriously, whole books have been written about the subject of writing AIs. Try your local library or look for reviews online. If you're feeling really lucky, look for a tutorial online that is doing more or less what you want.

A lot of artificial intelligence research revolves around making chat bots that can pass for humans-all of this will probably be useless for you. Instead, you want something that can learn the rules of your game and make good moves accordingly. As such, it might be easiest to write your game with human input first and get it working so you know what your AI will have to do before you start writing it.

aarku
2005.04.23, 04:28 PM
http://www.oreilly.com/catalog/ai/ is decent if you're new to the subject

-Jon

Blorx2
2005.04.23, 05:06 PM
@jspoon: First paint your head red. Then take your shirt off to expose your manly chest. Next, get some boxing gloves, or if you don't have boxing gloves, oven mitts will do. Next, duct tape some aluminum foil to some twine. And finally, get your mom to program you an AI. Sounds like that weird mexican wrestler dude off of Homecop Drekelstein or whatever...I think his name was Crud Bag...A friend told me about whatever it was 2 years ago and haven't been there since

@Graveck: I'll try it

deps
2005.05.31, 07:05 AM
Quick and dirty AI "tutorial"

1) Register some c/c++ function to LUA. These functions should return different stuff like position, direction, health, list of other objects (the player, other enemies, etc) close to the current object (sorted if needed), etc. Other functions to set different stuff to, like Move( int xoff, int yoff), Shoot(), Turn(), etc.

2) Start writing lua code. Run away if health is low, shoot the player if he/she is nearby, duck for cover if someone is shooting this way, etc.

3) profit.


And the red headed guy with no shirt and boxing gloves could also be Strong Bad. http://www.homestarrunner.com/sbemail.html

EDIT: Oh, and hello. This is my first post. :)

socksy
2005.05.31, 07:27 AM
Hi deps!
Firstly: Welcome to the forums, and enjoy your stay!

Secondly, this is a rather old thread so it didn't really need to be resurrected. Thirdly, Blorx2 doesn't really mean lua. He means how to implement AI in a programming IDE like xcode that uses a type of lua as it's scripting language. He then looked up lua, which didn't cover half the stuff on the actual IDE, as the IDE uses specific methods of displaying graphics and whatnot.
I doubt if he has made a window that stays up - many people haven't ;)

deps
2005.05.31, 10:09 AM
Firstly: Welcome to the forums, and enjoy your stay!
Thank you. :)

this is a rather old thread so it didn't really need to be resurrected.
D'oh. When I posted I looked more at the day in the month than the actual month the message was posted. :\
I will be more careful in the future. ;)

socksy
2005.05.31, 10:17 AM
I've seen much older gravedigs than this, so I really don't think you will get penalised for doing so here, especially considering you're new :)

It seems you've had some experience with Lua by the looks of your post. Have a look here (http://www.idevgames.com/forum/showthread.php?t=8641) to see the IDE Blorx was referring to.

Blorx2
2005.05.31, 10:20 AM
OH! Hi, deps, welcome :D . Yeah, I remember Homestar...that was funny...Also, I now know more about AI, I've talked to a few people about it