This is the mail archive of the
xconq7@sources.redhat.com
mailing list for the Xconq project.
Possible movement improvement
- From: Brian Dunn <bd1 at sysmatrix dot net>
- To: xconq7 at sources dot redhat dot com
- Date: Mon, 05 Jul 2004 17:37:40 +0800
- Subject: Possible movement improvement
- Organization: http://www.sysmatrix.net
- Reply-to: bd1 at sysmatrix dot net
Both mplayer.c and iplayer.c have the following:
/* Try moving sideways. */
if (probability(80)) {
dx = task->args[0] - unit->x; dy = task->args[1] - unit->y;
fact = (flip_coin() ? 50 : -50);
x1 = unit->x - ((fact * dy) / 100);
y1 = unit->y + ((fact * dx) / 100);
if (inside_area(x1, y1)) {
DMprintf("%s blocked, moving sideways to (%d, %d).", unit_desig(unit), x1, y1);
net_push_move_to_task(unit, x1, y1, 1);
}
}
This is called when a unit is blocked and could not perform a move_to task.
If I read the code correctly, it seems to only allow two of the possible four directions to be tried. I have seen units get stuck behind 'C' shaped obstacles, and this may partly explain why. A proposed change would be:
fact = (flip_coin() ? 50 : -50);
x1 = unit->x - ((fact * dy) / 100);
fact = (flip_coin() ? 50 : -50); /* this line is new */
y1 = unit->y + ((fact * dx) / 100);
This may allow the unit to try any of four directions randomly.
If this change makes sense, it will need to be in both mplayer.c and iplayer.c.
Brian