This is the mail archive of the
xconq7@sources.redhat.com
mailing list for the Xconq project.
Re: Fixing repair
- To: hronne at pp dot sbbs dot se
- Subject: Re: Fixing repair
- From: Jim Kingdon <kingdon at panix dot com>
- Date: Sat, 18 Aug 2001 14:06:29 -0400 (EDT)
- Cc: xconq7 at sources dot redhat dot com
- References: <l03130300b7a3ed92f536@[213.242.185.7]>
> In fact, what we really need to do is to just have ai_decide_plan call
> ai_react_to_action before the to_decide_plan function pointer:
OK, fixing this and another little fix solves the problem, and repair
seems to work. Enclosed is the new patch. It's possible that having
ai_react_to_action actually schedule repair would help the AI
get units out of danger more quickly, but that's a separate project.
> The fix in do_repair_task also seems logical. I guess this is what Stan
> meant with his comment /* and transport repairs */ ...
Yup. I didn't actually observe the bug here, but my change seems
obvious enough.
> This illustrates the fact that a lot of low level ai code (including
> the resupply and repair code) really lives in the kernel (plan.c and
> task.c) rather than in ai.c or the mplayer. It has two
> consequences. First, we don't need network functions for this code
> since it runs the same way on all computers.
Is that why the AI doesn't work with network play? Certainly things
like search_around (called from do_repair_task) involve randomness.
2001-08-18 Jim Kingdon <kingdon@panix.com> and Hans Ronne
Get the AI to repair its units better:
* lib/stdunit.g: Up repair-percent to 75 - much too easy to kill
off bombers (and others) at the default 35.
* kernel/ai.c (ai_decide_plan): Call ai_react_to_action rather
than duplicating the code which calls defensive_reaction &c. This
is so that we check for whether we are looking for repair.
* kernel/task.c (do_repair_task): Only look for repair from a
transport which can provide it.
* kernel/task.c (do_repair_task): Unless we are above
repair_percent, we haven't repaired enough. Also round up on the
80% check - otherwise 1/2 is considered to be >= 80% for example.
Index: kernel/ai.c
===================================================================
RCS file: /cvs/xconq/xconq/kernel/ai.c,v
retrieving revision 1.41
diff -u -r1.41 ai.c
--- ai.c 2000/12/28 15:10:46 1.41
+++ ai.c 2001/08/18 17:44:43
@@ -512,11 +512,7 @@
hostile actions, to make sure that peace garrisons are maintained. Not
sure if this is the best place, though. */
- /* First check that the unit's target (if it has one) is valid. */
- check_current_target(unit);
- /* Deal with tactical emergencies. */
- defensive_reaction(unit);
- offensive_reaction(unit);
+ ai_react_to_action(side, unit);
fn = all_ai_ops[side->aitype].to_decide_plan;
if (fn)
Index: kernel/task.c
===================================================================
RCS file: /cvs/xconq/xconq/kernel/task.c,v
retrieving revision 1.33
diff -u -r1.33 task.c
--- task.c 2000/12/07 17:07:52 1.33
+++ task.c 2001/08/18 17:44:49
@@ -1351,8 +1351,16 @@
}
}
tmpunit = unit;
- /* (should use doctrine to decide when repairs sufficient) */
- if (unit->hp >= (u_hp(u) * 80) / 100) { /* what if unit is multi-part? */
+
+ if (/* Must be repaired enough that the AI won't just push another repair
+ task immediately. */
+ unit->hp > (u_hp_max(u) * unit_doctrine(unit)->repair_percent) / 100
+
+ /* Must be >= 80%, rounding up (should use a new number from
+ doctrine rather than hardcoding 80%, probably). */
+ && unit->hp >= (u_hp(u) * 80 + 99) / 100
+
+ /* what if unit is multi-part? */ ) {
return TASK_IS_COMPLETE;
} else if (u_hp_recovery(u) > 0) {
if (0 /* too close to enemies */) {
@@ -1362,7 +1370,9 @@
set_unit_reserve(unit->side, unit, TRUE, FALSE);
}
return TASK_IS_INCOMPLETE;
- } else if (unit->transport != NULL /* and transport repairs */) {
+ } else if (unit->transport != NULL
+ && uu_auto_repair(unit->transport->type, unit->type) > 0
+ /* || explicit repair */) {
set_unit_reserve(unit->side, unit, TRUE, FALSE);
return TASK_IS_INCOMPLETE;
} else if ((unit2 = repair_here(ux, uy)) != NULL
Index: lib/stdunit.g
===================================================================
RCS file: /cvs/xconq/xconq/lib/stdunit.g,v
retrieving revision 1.8
diff -u -r1.8 stdunit.g
--- stdunit.g 2001/02/01 02:38:27 1.8
+++ stdunit.g 2001/08/18 17:44:51
@@ -600,6 +600,7 @@
(doctrine default-doctrine
(construction-run (u* 1))
(rearm-percent 40)
+ (repair-percent 75)
)
(doctrine place-doctrine