2 * A* Search - A search library used in Empire to determine paths between
4 * Copyright (C) 1990-1998 Phil Lapsley
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #if !defined(lint) && !defined(SABER)
25 static char sccsid[] = "@(#)as_init.c 1.4 11/13/90";
29 * Return an as_data structure with the necessary fields filled in
30 * and space malloced. Return NULL if malloc fails.
33 as_init(int maxneighbors,
35 int (*hashfunc) (struct as_coord),
36 int (*neighborfunc) (struct as_coord, struct as_coord *, s_char *),
37 double (*lbcostfunc) (struct as_coord, struct as_coord, s_char *),
38 double (*realcostfunc) (struct as_coord, struct as_coord,
40 double (*seccostfunc) (struct as_coord, struct as_coord, s_char *),
45 AS_NEW(adp, struct as_data, NULL);
46 AS_NEW_ARRAY(adp->neighbor_coords, struct as_coord,
48 AS_NEW_ARRAY(adp->neighbor_nodes, struct as_node *,
49 maxneighbors + 1, NULL);
50 AS_NEW_ARRAY(adp->hashtab, struct as_hash *, hashsize, NULL);
52 adp->maxneighbors = maxneighbors;
53 adp->hashsize = hashsize;
55 adp->neighbor = neighborfunc;
56 adp->lbcost = lbcostfunc;
57 adp->realcost = realcostfunc;
58 adp->seccost = seccostfunc;
59 adp->userdata = userdata;