Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Fabian on August 23, 2007, 10:19:08 am

Title: Modularization of AI Code - finished
Post by: Fabian on August 23, 2007, 10:19:08 am
Hi,

I've just finished the general modularization approach (http://www.hard-light.net/forums/index.php/topic,47447.0.html).

So the hard part of wrapping all 267 function calls is done.

This means anyone who wants it can now start changing and improving the AI without breaking compatibility with Retail!

Now we only have to decide how a new AI can be hooked into the existing code.

Lets use a launcherflag ... ;-) (just kidding, I know thats a bad idea).

At the moment I think of a global mission, mod or campaign flag, which does a static:

if (AICode == "new")
{
     aicode_new_setup_hooks();
}

This _new_ AI code could then be extended to again branch into fighter or bomber or ... specific AI based on AI Class for example.

The ai_evade hook could then for example be written like:

if (aip->class == "special")
       ainew::special.evade(params)
else
{
//    do some new stuff
// now call the _old_ code
    aicode_old_ct->ai_evade(params);
}

With that kind of polymorphic approach, one can slowly extend and rewrite the existing AI. (and perhaps finally fix the collision avoidance ;-) )

One thing needed for sure for a new AI is a custom field in aip, where it can store its data, but besides that and the decision where to setup the hooks, its done.

Let me know what you think.

cu

Fabian

PS: Sorry for the delay, but I was very busy.

[attachment deleted by admin]
Title: Re: Modularization of AI Code - finished
Post by: Topgun on August 23, 2007, 11:04:53 am
I don't understand the code. what's with all the +'s?
Title: Re: Modularization of AI Code - finished
Post by: Shade on August 23, 2007, 11:18:22 am
It's a diff versus, presumably, the 3.6.9 branch. Each + denotes an added line, each - denotes a removed line. So it can't be read alone, it has to be seen as a patch to already existing code, and merging the two using the rules above will result in the actual final product.
Title: Re: Modularization of AI Code - finished
Post by: Topgun on August 23, 2007, 01:04:21 pm
oh. I get it now.
Title: Re: Modularization of AI Code - finished
Post by: Grizzly on August 23, 2007, 03:05:48 pm
Quote
This means anyone who wants it can now start changing and improving the AI without breaking compatibility with Retail!

Critical hit... Critical hit... Critical hit...
Title: Re: Modularization of AI Code - finished
Post by: Goober5000 on August 23, 2007, 07:54:16 pm
Excellent! :yes: :yes: :yes:

I will try to merge this over the weekend. :)
Title: Re: Modularization of AI Code - finished
Post by: jr2 on August 24, 2007, 03:04:27 am
Cool.  :yes:  Thx, Fabian.
Title: Re: Modularization of AI Code - finished
Post by: IPAndrews on August 29, 2007, 11:54:30 am
This is quite an achievement.
Title: Re: Modularization of AI Code - finished
Post by: jr2 on August 29, 2007, 05:09:31 pm
Go Fabian!!  (http://images.devshed.com/fdh/smilies/beerchug.gif)

(http://images.devshed.com/fdh/smilies/honorhim.gif)

Title: Re: Modularization of AI Code - finished
Post by: chief1983 on August 29, 2007, 10:34:19 pm
Someone get that guy a medal, or a badge or a pic or something.  Or at least a nice custom title.  I'm pretty sure everyone will love this.  Now maybe fighters can stop running into capital ships :)
Title: Re: Modularization of AI Code - finished
Post by: jr2 on August 30, 2007, 01:42:44 am
... and SW X-Wings and TIEs can be modded for optimal high-speed manuevers!  <.<
Title: Re: Modularization of AI Code - finished
Post by: Cobra on August 30, 2007, 11:37:31 am
What he needs to do is help out the BtRL team so that AI fighters don't smash into Scar's asteroid. :P
Title: Re: Modularization of AI Code - finished
Post by: Mobius on August 30, 2007, 11:44:49 am
Basically, Fabian solved many of the AI problems?

[size=9]
EXCELLENT JOB MAN!!![/size]
[/glow][/b]
Title: Re: Modularization of AI Code - finished
Post by: Grizzly on August 30, 2007, 01:13:31 pm
Actually, he allowed many ai problems to be solved.

Can we also fix the problem with your wingmen completely forgetting about fighters on their tails when they have a capship to protect? (That is, when they are beyond their "interception range")
Title: Re: Modularization of AI Code - finished
Post by: akenbosch on August 30, 2007, 01:24:46 pm
and the multipart turrets that shoot through their parent ship?

AND theproblem with wingmen ignoring friendly ships in-between them and their target?

sweet.
Title: Re: Modularization of AI Code - finished
Post by: Turambar on August 30, 2007, 01:27:02 pm
time to fix the speed barrier!
Title: Re: Modularization of AI Code - finished
Post by: akenbosch on August 30, 2007, 01:28:37 pm
never heard of the speed barrier. could you please elaborate?
Title: Re: Modularization of AI Code - finished
Post by: Turambar on August 30, 2007, 01:30:10 pm
the barrier beyond which the AI becomes retarded and starts running into stuff.
Title: Re: Modularization of AI Code - finished
Post by: Turey on August 30, 2007, 01:32:05 pm
the barrier beyond which the AI becomes retarded and starts running into stuff.

It's around 350m/s, IIRC.
Title: Re: Modularization of AI Code - finished
Post by: Mobius on August 30, 2007, 02:22:42 pm
I know it is 300 mps.

And thank you for fixing that bug, I have intention of using Joshua's tables :)
Title: Re: Modularization of AI Code - finished
Post by: Turey on August 30, 2007, 05:30:56 pm
And thank you for fixing that bug

Ok, I'm going to clear this up right now. Many of you (not all) seem to be under the impression that Fabian has made some sort of end-user-visible change to the AI code. That's wrong. If he did his job right, the AI should act exactly the same as it did before. The only difference is that the AI code will be running behind an extra layer of abstraction that will let us, in the future, easily change the AI code without breaking retail.

He has not solved any of the AI-related problems mentioned in this thread, he has only made it possible for them to be fixed.

Understand?
Title: Re: Modularization of AI Code - finished
Post by: Mobius on August 30, 2007, 05:47:50 pm
It remains an achievement. So:

And thank you for helping the SCP with[7b] that bug

;)
Title: Re: Modularization of AI Code - finished
Post by: karajorma on August 30, 2007, 05:49:01 pm
What he needs to do is help out the BtRL team

Who do you think signed him up in the first place? ;)
Title: Re: Modularization of AI Code - finished
Post by: chief1983 on August 30, 2007, 06:10:29 pm
****, we really need to get better at nabbing FotG-minded coders.
Title: Re: Modularization of AI Code - finished
Post by: jr2 on August 30, 2007, 09:26:01 pm
FotG?
Title: Re: Modularization of AI Code - finished
Post by: chief1983 on August 30, 2007, 10:12:21 pm
Fate of the Galaxy.  (In my sig)
Title: Re: Modularization of AI Code - finished
Post by: Nuke on August 31, 2007, 06:13:43 am
damn it btrl, stop stealing all the coders :D
im kidding of course.
Title: Re: Modularization of AI Code - finished
Post by: karajorma on August 31, 2007, 09:44:03 am
We're not stealing them. We're bringing in more from outside sources. That's the exact opposite of stealing them. :p
Title: Re: Modularization of AI Code - finished
Post by: Nuke on August 31, 2007, 10:10:32 am
you didnt read the fine print :D
Title: Re: Modularization of AI Code - finished
Post by: karajorma on August 31, 2007, 02:41:03 pm
I did. It was just funnier to pretend I hadn't.