Help - Search - Members - Calendar
Full Version: Contest: scripting NPC behaviour!
The Black Wyrm's Lair - Forums > Mod development resources & discussion > Modding Contests
Baronius
Technical Contest #2:

"Complex behaviour"







Introduction

After more than 3 years, it's time for a brand-new Technical Contest!

Welverin is the only person so far who achieved BWL's Technical Modding Cross. It's awarded to those people who are good in the practical or theoretical aspects of a certain field of IE mod development. I remember Welverin to be a good developer indeed, who also partipicated in one of the Total Conversion projects of the old TeamBG. However, I doubt he is the only member who deserves the Technical Modding Cross!

The task Welverin solved was a very short one, but it required knowledge in a certain field of IE mod development, so no submissions had been received for a whole day (until Welverin solved it). The current task won't be easy either, but it's not terribly difficult.

The topic of BWL's Technical Contest #2 (the present contest which thread you're just reading) is nothing else than AI scripting! Since this is a technical contest, it doesn't offer too many possibilities for creativity, but you can show how good you're in scripting and script optimization instead!




The task

We have a hostile Fighter, Archer, Cleric and Mage. All of them have AI scripts assigned, but the actual scripts for the Cleric and Mage are missing. In their present form, their default scripts just make them attack your party, the Mage and Cleric won't do anything useful. Your task is to implement their scripts (2 BAF files) precisely according to the task's specification. The task's specification is attached to the end of the present thread as a PDF file.

Four creature files and three scripts are available, and there are two missing scripts (bwcc_m.baf and bwcc_p.baf). You can install (and later uninstall) these files as a WeiDU-based "mod" with the installer attached to the end of the present thread (testenv.zip). All you have to do is creating the two missing scripts and testing if they work in the game according to the specifications (requirements).

Please read the attached specification for more information on the task, and feel free to ask any arising questions in this topic.




Submissions

The two BAF scripts (bwcc_m.baf, bwcc_p.baf) should be put into a ZIP or RAR package. You should send the package to the contest email address AND send me a forum private message (PM) here after you have sent the email. I will reply to the PM to confirm that I've received the submission. If you don't send a PM, the submission will be ignored. This is required because I might overlook the email otherwise.

One submission is allowed, and you can send an additional, "replacement" submission within one day from the time you've sent the first one. The replacement submission (if sent within the one day limit) will completely replace the first one. Replacements sent after more than one day are ignored (but they don't invalidate the first submission). Submissions sent after the deadline won't be judged.

All files in your ZIP or RAR submissions except bwcc_m.baf and bwcc_p.baf will be ignored, so please don't include anything else. The judge (probably myself, Baronius) will install your script files to the same environment as you have in the attached WeiDU-based package, and will test them in the game (and will also read the script sources). Please see the attached specification file for more information.

DEADLINE: 31st July 2008, 24:00 GMT




Scoring and guidelines

The total score is 100. Most of it consists of minor parts, so you can get partial score for very many things. In fact, scoring will usually start with 100 and (a few) points will be decreased for each problem, glitch.

The most important aspect when judging is the conformance with requirements. That is, if the requirement says "the Druid must summon a Wolf" and your solution summons a bear, you won't get full score for that part. (There is no Druid in the present contest.)

The secondary aspect when judging is (unsurprisingly) elegance, concision, unique ideas. They don't matter nearly as much as the "conformance" (= accuracy) aspect, but they can mean bonus points to your total score. In case of "equally" conform solutions, this aspect might be used to make a difference between them (but, of course, this aspect matters in other cases too).

To sum up, focus on a "good" solution even if it's "long", instead of a "cool" solution that has "wrong" parts.

In order to get the Technical Modding Cross, the winner must have at least 70 points (from 100).




Award

The winner (or winners, depending on the number of participants) will get no less than the Technical Modding Cross of BWL, provided he or she has at least 70 points.



There will be other prizes as well. We will probably give BWL forum portraits (from our Gallery) and custom subtitles too.




Hints

If you know the basics of scripting in IE mod development and want to practise a bit, don't hesitate to enter! As written above, we give partial score in very many places, so you won't get 0 points if your solution doesn't work perfectly. Although it's limited and doesn't introduce a lot of fields of scripting, this task can still be a good practice! smile.gif Also, the author of the best solution gets the Technical Modding Cross, so it might be worth a try!

A few very useful hints:
  • Don't be frightened after the first glance on the specification/requirements! The second part of the solution is actually very easy and includes much copying, because it is very similar to the first part. The specification seems to be long, but it's easy to read, and it explains everything in details to make the solution easier.
  • Although it makes no sense to include them in the real submission, don't be afraid to modify the test files (e.g. creatures) according to your needs! For example, you can set bad saving throws for a creature, to make your tests easier! On the other hand, make sure not to modify something that would change the requirements of the contest! For example, don't change any existing game spells used by any of the contest's files.
  • Your solution should be complete and accurate, but not necessarily optimal, so don't be afraid to use many script blocks if needed! If you think a script block should be duplicated and the only difference will be a minor detail, then don't hesitate to duplicate it if it solves the problem! If you have a partial or full solution that you don't want to submit yet, and you're wondering if the number of your script blocks is reasonable or not, feel free to ask it here! I will give a public hint to everyone in my reply.
Any questions are welcome! If you plan to enter, please write it too (if you don't want to be a secret winner smile.gif ) so we know how many participants we should expect.
Razfallow
Hi Baronius,

Do I understand it correctly, that mage and cleric are allowed to cast only their memorized spells (mage's two spells and cleric's nine spells) and nothing else?

(Note: Archer hasn't strength high enough to use composite long bow.)
Baronius
QUOTE
Do I understand it correctly, that mage and cleric are allowed to cast only their memorized spells (mage's two spells and cleric's nine spells) and nothing else?
Yes, only their memorized spells, and only according to the requirements. The definition in your question is a more concise form indeed, as the specification defines it in a bit long-winded way (though it gives hints too, but this task isn't for complete beginners anyway):

QUOTE
That is, when the specification says “the cleric casts a spell”, it means that he will make an attempt to cast it, provided he has it memorized. That is, the HaveSpell(…) trigger and Spell(…) action must be used everywhere where spellcasting is involved.


The Archer creature is from the game (only the assigned scripts were replaced and XP set to 0, practically), but I can imagine it has such problems (as we know, the game isn't free of glitches). Feel free to set the Strength to the proper minimum value, it won't change the requirements or influence the results (as you also surely know, but less experienced participants might not). Thanks for the remark.
Razfallow
Another question, have you tested that it's all feasible?
Baronius
Of course, I have a reference implementation for myself to make the checking of contest entries faster.

However, if the specification isn't clear somewhere, please do ask.
Razfallow
"That is, instead of following the usual priority order (i.e. instead of restarting from Step 1), the conditions of Step 3 must be evaluated."

Does this mean that script can't be restarted (evaluation starts again from the top of the script)?
Baronius
If that solves the problem, then yes, it can mean that, otherwise it doesn't. That is, any solution is perfect which solves the problem. I can't reveal if the implementation mentioned in your question in brackets is the good one (or a good one) or not -- if you believe it meets the requirement (and your tests confirm it), then don't hesitate to use it.

Assume that the Cleric (with less than 60% HP) has just cast Protection from Fire on the Fighter, and meanwhile the (unlucky) Fighter got feebleminded and your characters have started attacking the Cleric. In this case, the conditions of Step 1 (60% HP, attacked) and Step 4 (Fighter feebleminded) are both true. Without the requirement in question, the order of Steps would be Step1(-Step2-Step3)-Step4, and not Step4-Step1-... (In fact, the first order even wouldn't be realized, because Step1 results in a state transition to S3 so the poor Fighter would never get cured from Feeblemind).
Razfallow
"That is, instead of following the usual priority order (i.e. instead of restarting from Step 1), the conditions of Step 3 must be evaluated."

OK another question on the same topic, can he check steps 1 and 2 (they will be false), before he evaluates step 3? Or does he have to go directly to step 3 without checking anything else?

"If the Archer is alive, but is feebleminded and/or blinded, he casts Cure Disease on the Archer."

What is valid - AND or OR?
Baronius
QUOTE
"That is, instead of following the usual priority order (i.e. instead of restarting from Step 1), the conditions of Step 3 must be evaluated."

OK another question on the same topic, can he check steps 1 and 2 (they will be false), before he evaluates step 3? Or does he have to go directly to step 3 without checking anything else?
I think the requirement is clear enough, but could you explain why you think both step1 and step2 will be necessarily false anyway? It will be considered as a hint to other participants, so no problem if we discuss that certain case here (but only this one).

One important note: any solution that meets the requirement will be given full score (for each requirement), so the primary scoring guideline isn't "how close is the submission to the reference implementation" (as always, it might be possible to make more elegant solutions than the reference one -- participants have more time for implementation than I had smile.gif). So there is no such thing as "expected implementation" in terms of technical solutions: the way it works in the game should just meet the text requirements -- that's all.


QUOTE
"If the Archer is alive, but is feebleminded and/or blinded, he casts Cure Disease on the Archer."

What is valid - AND or OR?

The specification tries to follow natural language, but without ambiguities. In real speech, when we say OR, we usually mean exclusive "or" by that. On the other hand, in boolean algebra, A or B means "A or B or both are true". In written texts, and/or is meant to express that both the "everyday" AND and OR are allowed (so basically it's boolean OR). The answer to your question is: it's boolean OR in the specification. I answered this question because it applied to interpretation, not the solution.
Razfallow
QUOTE(Baronius @ Jul 1 2008, 07:52 PM) *
QUOTE
"That is, instead of following the usual priority order (i.e. instead of restarting from Step 1), the conditions of Step 3 must be evaluated."

OK another question on the same topic, can he check steps 1 and 2 (they will be false), before he evaluates step 3? Or does he have to go directly to step 3 without checking anything else?
I think the requirement is clear enough, but could you explain why you think both step1 and step2 will be necessarily false anyway? It will be considered as a hint to other participants, so no problem if we discuss that certain case here (but only this one).


I don't think they will be false, I know they will be. It's ease to make them false, when I need it. But I will rather use different solution (where he will check directly step3) as this is still unclear to me.

Baronius
QUOTE
I don't think they will be false, I know they will be. It's ease to make them false, when I need it.

If you can make them false without violating the requirements e.g. with some special scriptings tricks, then I can imagine giving full score for that too (even if it means a bit broader -- but acceptable and reasonable -- intepretation of this requirement from my side). I suppose you meant you could ensure that they are always false when and only when Step 2 ends. This also guarantees that the next character who the Cleric helps if needed will be the Fighter in all circumstances.

However, I said "without violating the requirements". For example, ensuring with some active trick that the Cleric doesn't detect the attacks of the party at that time is not a valid solution (as the requirement says "if has has been attacked...", which is an undenyable fact if it happens).
Razfallow
QUOTE(Baronius @ Jul 1 2008, 08:48 PM) *
QUOTE
I don't think they will be false, I know they will be. It's ease to make them false, when I need it.

If you can make them false without violating the requirements e.g. with some special scriptings tricks, then I can imagine giving full score for that too (even if it means a bit broader -- but acceptable and reasonable -- intepretation of this requirement from my side). I suppose you meant you could ensure that they are always false when and only when Step 2 ends. This also guarantees that the next character who the Cleric helps if needed will be the Fighter in all circumstances.

However, I said "without violating the requirements". For example, ensuring with some active trick that the Cleric doesn't detect the attacks of the party at that time is not a valid solution (as the requirement says "if has has been attacked...", which is an undenyable fact if it happens).

I don't know, is using of global variable to make one block false for a moment ilegal? No matter, I've found another different solution.
Baronius
Now I know what you mean. Although the requirement also includes "instead of restarting from Step 1", solutions which use a correctly handled global variable will also be accepted (so actually, "it can restart but the next step which conditions can be true must be Step 3"). It's up to you to decide what solution you find the most elegant or suitable, but if it works correctly, it will mean no significant difference in the total score (though when submissions are compared to each other, nicer solutions can get more points).
Baronius
Razfallow, you're using the "Cast and Attack" pattern in your submission. I know it's considered as a good practice, but the requirements specify steps that directly follow each other -- no attacks are permitted between these steps (it violates several requirements). Feel free to revise and re-send your submission according to this, it won't be penalized at all.

This possibility doesn't mean any advantages or disadvantages to Razfallow over other participants, because Razfallow is the only one who has submitted an entry so far. It's a hint to others as well, because "Cast & Attack" is considered as a good practice in mods, so other participants might also believe that its use is expected or means bonus points.
Razfallow
Then you should have written so in the requirements more clearly, because I can't find it there.

QUOTE
no attacks are permitted between these steps (it violates several requirements)

What exactly? Doesn't he cast right spells?
Baronius
It implicitly follows from the fact that there are strict steps (1,2,3,...) for each state and it's mentioned nowhere that other actions can be executed between these steps. Furthermore, there is an explicit reminder about it as well (see the quote below). The triggers are precisely defined by the specification (in the form "if this and this is true, then ..."). It's written nowhere that "the Cleric should attack its enemies between the steps" or "the default scripts of the Cleric should run between the steps". The same applies to the Mage.

For example, when Step 3 is casting Protection from Fire and Step 4 is curing Disease, your Cleric starts to attack between the two steps, practically introducing a new step (attack actions) between the two. More precisely, it allows the default script to be executed, which appears as a plus step between the aforementioned Step 3 and Step 4 (for example).

The requirement violation wouldn't be too spectacular if it was just a few quick attacks e.g. between a Prot. from Fire and Cure Disease, but if the player's character is far away, it causes a significant difference: the Cleric starts moving to the character's direction (to be able to attack him), and when the action timer expires, he walks back to the Fighter to heal him. If the requirement is accurately met, this can't happen, because the Cleric will wait at the Fighter between casting the two spells.

The explicit text also warns about it:
QUOTE
All requirements -- and only these requirements -- that apply to a given state must be met in that certain state (preferably without irrelevant, unnecessary additional features).

Cast and Attack isn't a requirement. It's an additional feature of your submission. While it is good practice in real mods, this contest tests the participants' skills of solving a well-defined task (preferably in a systematic way), not the knowledge of various good techniques (on a side note, we plan such a contest as well for the future). That's why Cast & Attack is omitted from the requirements. This contest is also a possibility for less experienced script writers, because they can achieve good results with a bit systematic approach, even without the knowledge of good techniques.

However, as I've emphasized, this isn't a mistake from your part. It's natural that a mod developer assumes that Cast & Attack should be used, so it's easy to forget or misinterpret the specification in such a case. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.