|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: single.c,v 1.22 2003/05/28 23:03:21 stpohle Exp $ */
|
|
|
|
/* $Id: single.c,v 1.23 2003/05/29 00:56:48 stpohle Exp $ */
|
|
|
|
/* single player */
|
|
|
|
/* single player */
|
|
|
|
|
|
|
|
|
|
|
|
#include "basic.h"
|
|
|
|
#include "basic.h"
|
|
|
@ -116,11 +116,11 @@ ai_easyrunaway (_point p)
|
|
|
|
done = 0;
|
|
|
|
done = 0;
|
|
|
|
/* check the field left and right beside */
|
|
|
|
/* check the field left and right beside */
|
|
|
|
if (i == left || i == right) {
|
|
|
|
if (i == left || i == right) {
|
|
|
|
if (ai_checkfield (pos[i].x, pos[i].y - 1) || ai_checkfield (pos[i].x, pos[i].y + 1))
|
|
|
|
if (ai_findnearbombs (pos[i]) == 0 && (ai_checkfield (pos[i].x, pos[i].y - 1) || ai_checkfield (pos[i].x, pos[i].y + 1)))
|
|
|
|
dir |= (1 << i);
|
|
|
|
dir |= (1 << i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if (ai_checkfield (pos[i].x - 1, pos[i].y) || ai_checkfield (pos[i].x + 1, pos[i].y))
|
|
|
|
if (ai_findnearbombs (pos[i]) == 0 && (ai_checkfield (pos[i].x - 1, pos[i].y) || ai_checkfield (pos[i].x + 1, pos[i].y)))
|
|
|
|
dir |= (1 << i);
|
|
|
|
dir |= (1 << i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos[i].x += m[i].x;
|
|
|
|
pos[i].x += m[i].x;
|
|
|
@ -414,7 +414,7 @@ ai_checkpos (_player * pl, _point * pos)
|
|
|
|
int
|
|
|
|
int
|
|
|
|
ai_choosedir (int dir, int nearbomb, int oldpos) {
|
|
|
|
ai_choosedir (int dir, int nearbomb, int oldpos) {
|
|
|
|
int rdir[4];
|
|
|
|
int rdir[4];
|
|
|
|
int bdir[4];
|
|
|
|
int bdir[4*3];
|
|
|
|
int i, rnr, bnr;
|
|
|
|
int i, rnr, bnr;
|
|
|
|
|
|
|
|
|
|
|
|
for (rnr = bnr= i = 0; i < 4; i++) {
|
|
|
|
for (rnr = bnr= i = 0; i < 4; i++) {
|
|
|
@ -461,6 +461,30 @@ ai_invertdir (int dir) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ai_checknewpos (_point pos,int d) {
|
|
|
|
|
|
|
|
_point m;
|
|
|
|
|
|
|
|
switch (d) {
|
|
|
|
|
|
|
|
case (left):
|
|
|
|
|
|
|
|
m.x = pos.x - 1;
|
|
|
|
|
|
|
|
m.y = pos.y;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (right):
|
|
|
|
|
|
|
|
m.x = pos.x + 1;
|
|
|
|
|
|
|
|
m.y = pos.y;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (up):
|
|
|
|
|
|
|
|
m.x = pos.x;
|
|
|
|
|
|
|
|
m.y = pos.y - 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
m.x = pos.x;
|
|
|
|
|
|
|
|
m.y = pos.y + 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (ai_findnearbombs (m) == 0);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* create a giving number of ai players */
|
|
|
|
/* create a giving number of ai players */
|
|
|
|
void
|
|
|
|
void
|
|
|
@ -485,6 +509,7 @@ single_create_ai (int players)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
single_playergame ()
|
|
|
|
single_playergame ()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -525,8 +550,10 @@ single_loop ()
|
|
|
|
nearbomb = ai_findnearbombs (plpos);
|
|
|
|
nearbomb = ai_findnearbombs (plpos);
|
|
|
|
if (nearbomb == 0) { // no bombs found
|
|
|
|
if (nearbomb == 0) { // no bombs found
|
|
|
|
bestbdir = ai_findbestbombdir (plpos, pl->d, pl->range);
|
|
|
|
bestbdir = ai_findbestbombdir (plpos, pl->d, pl->range);
|
|
|
|
if (bestbdir >= 4)
|
|
|
|
if (bestbdir >= 4) {
|
|
|
|
|
|
|
|
if (ai_easyrunaway (plpos) != 0)
|
|
|
|
player_drop_bomb (p);
|
|
|
|
player_drop_bomb (p);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (bestbdir == -1) {
|
|
|
|
else if (bestbdir == -1) {
|
|
|
|
pl->d = s_random (4);
|
|
|
|
pl->d = s_random (4);
|
|
|
|
pl->m = 1;
|
|
|
|
pl->m = 1;
|
|
|
@ -535,6 +562,8 @@ single_loop ()
|
|
|
|
pl->d = bestbdir;
|
|
|
|
pl->d = bestbdir;
|
|
|
|
pl->m = 1;
|
|
|
|
pl->m = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ai_checknewpos (plpos, pl->d))
|
|
|
|
|
|
|
|
pl->m = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// bombs in the near found
|
|
|
|
// bombs in the near found
|
|
|
|