MASSIVE like AI program

General discussion about the development of the open source Blender

Moderators: jesterKing, stiv

IoN_PuLse
Posts: 212
Joined: Wed Oct 16, 2002 6:05 am
Location: Canada, BC
Contact:

Post by IoN_PuLse »

....told ya so.

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

PM's have been disabled on this board, so I'll just post it...

You can get my terrain-following python script here:

http://harkyman.home.comcast.net/FollowTerrain.blend


You move your objects in the x-y plane and they follow the mesh terrain of the designated ground object. Feel free to incorporate it, when the time comes.

IoN_PuLse
Posts: 212
Joined: Wed Oct 16, 2002 6:05 am
Location: Canada, BC
Contact:

Post by IoN_PuLse »

COOL

mr_rob
Posts: 0
Joined: Fri Jul 04, 2003 5:11 pm
Location: US of A
Contact:

Post by mr_rob »

Nice script man, though I really need to brush up on my python. I think I'll write my ideas into pseudocode and try to "translate" them into python.

Josh

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

I wanted to see what I could come up with last night. As I have some pressing projects at work right now, I'll post a blend and an .avi file later today.

Basically: Python script, linkable to Blender objects, that evaluate and react based on factors relating to their proximity to different combinations of enemy and allied objects. I've put about 25 actors (i.e. icospheres) on a rough terrain and linked each of them to both my AI script and my followterrain script.

They went at each other, mostly maintaining their formations. The code is totally crap right now, very redundant and inefficient, but it works. It's slow, though. It's obvious to me that with any large size of opposing forces, it will slow to a crawl. As it was, it took my Dual PII about 8 seconds a frame to calculate the movements of just these 25 spheres. I think a lot of those speed problems can be solved by storing individual actor information in a good database engine (mySQL comes to mind) and letting IT do the heavy lifting vis a vis local object detection, opponent selection, etc. There's no sense making a python script do by brute force the things a relational database was designed to do elleganty and 1000x more quickly.

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

Okay - it only took me a second or two to put this stuff online so here it is...

The .blend file with scripts and objects is there just as a proof of concept. As I said, the code is crap and far from finished, so no crits, please. It's just there in case you want to look at it. The anim is short, but shows the actors, each evaluating individually and what they do. Two teams, a North and South. Watch how they jostle a bit to hold their formations until they get within charging distance of an enemy. BTW, the actors follow the terrain they are on. Divx 5.0.2, I think, and only 260k, so no need to be trepidatious about downloading.

http://66.134.133.114/botattack.blend

http://66.134.133.114/testbots.avi

mr_rob
Posts: 0
Joined: Fri Jul 04, 2003 5:11 pm
Location: US of A
Contact:

WHOA HO HO HO!

Post by mr_rob »

Man that rocks! That is very cool! I'm trying to learn Python right now, and once I do I'll get started coding ASAP. Harkyman you are very good.

I definately will look at your code in detail, maybe it could help me learn Python more.

What version of Blender are you using, I'm using 2.31 and I'm getting an error?

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

I'm using official bf-blender 2.31a, with a full installation of Python 2.23.

BTW, this weekend, I rewrote the script to store all object information in a mySQL database, using the MySQLdb Python library, right out of Blender. When I did this, and used the database for selecting opponents and doing all of the heavy lifting, I got something like a 12x speed increase. So, all of this running on a P4/modern processor shouldn't really be that slow, even for some larger organizations. I believe that the database solution will scale very well. Throw the DB on a dual processor server with a gig of RAM and the thing will run in real time!

It also allows you to intialize the objects, so you can give each one slightly random stats, if you so choose. The output isn't any different at this point than what I posted last week, and you can't really get the blend file to work without the Python additions and MySQL running with an appropriate db and table, so I'm not reposting anything now. Suffice it to say, that this is coming along nicely!

kencanvey
Posts: 0
Joined: Mon Jun 02, 2003 7:54 am
Location: Smethwick West Midlands UK

Post by kencanvey »

Fantastic :D :shock: :D

Great work, what an addition to the Blender arsenal.

Keep it up man :D

Ken

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

New animation to look at...

http://66.134.133.114/battle3comp.avi

It's divx5.0.5 and only 310k. Watch the blue guy at the top center try to run when his buddy bites it. Ha!

This is turning out to be fun. Enjoy!

New things implemented:

- Actual attack and "neutralization". Older animations showed actors getting "stuck" against each other. They now exchange (mathematical) blows until one dies, then move on.

- Randomized actor stats. Upon initialization, actors are given base stats according to their type, randomized to an definable percentage. Seperate intialization stage allows you to hand edit stats in the database if you want to do something special.

- Orders: Defend, Attack, Retreat, Regroup, March (with a heading and speed modifier), and Goal Seek (march toward a user-specified Blender Object). Actors currently receive orders as a group, but will receive them from their commanders in future revisions. Orders can be changed on the fly with a simple update to the database.

Next:

- Hierarchical command and control. Each actor receives orders from its superiors, acts on them, and advertises those orders to their subordinates.

- Effects of the Intellect statistic. Actors will make errors in judgement in their interpretation of Orders and Goals according to their Intellect stat. This will lead to more realistic action.

- Direction. Currently, Actors are omnidirectional. Implementation of which way they are facing.

- Pathfinding. Moving around a set of obstacles and the consideration of terrain (slopes/edges)

- States. Calculation and storing of states for use by the animation side (i.e., "Attacking","Running","Hiking")

- Some code style help. My code is a horrific morass of poo. Not knowing the in's and out's of Python, I'm sure I've done many things in the least efficient manner possible. Maybe once I get it all working, I'll get some help, and do a full rewrite.

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

Argh! Triple post - errors on site.
Last edited by harkyman on Tue Feb 03, 2004 7:30 pm, edited 1 time in total.

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

Argh! Triple post - errors on site.
Last edited by harkyman on Tue Feb 03, 2004 7:29 pm, edited 1 time in total.

harkyman
Posts: 98
Joined: Fri Oct 18, 2002 2:47 pm
Location: Pennsylvania, USA
Contact:

Post by harkyman »

My last post isn't showing as a new post, so I thought I'd hit the thread again. Hmmm.

mr_rob
Posts: 0
Joined: Fri Jul 04, 2003 5:11 pm
Location: US of A
Contact:

Post by mr_rob »

ABSOLUTELY MAGNIFICANT! That is very, very cool! The dude that wrote MASSIVE better watch out, I think you might have his job! How many lines of code are in your scripts for it?

Once again, I am in awe!

mr_rob
Posts: 0
Joined: Fri Jul 04, 2003 5:11 pm
Location: US of A
Contact:

Post by mr_rob »

Double post, I kept getting "General Error: Failure sending email"
Last edited by mr_rob on Tue Feb 03, 2004 8:32 pm, edited 1 time in total.

Post Reply