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
27 * Return an as_data structure with the necessary fields filled in
28 * and space malloced. Return NULL if malloc fails.
31 as_init(int maxneighbors,
33 int (*hashfunc)(struct as_coord),
34 int (*neighborfunc)(struct as_coord, struct as_coord *, void *),
35 double (*lbcostfunc)(struct as_coord, struct as_coord, void *),
36 double (*realcostfunc)(struct as_coord, struct as_coord, void *),
37 double (*seccostfunc)(struct as_coord, struct as_coord, void *),
42 AS_NEW(adp, struct as_data, NULL);
43 AS_NEW_ARRAY(adp->neighbor_coords, struct as_coord,
45 AS_NEW_ARRAY(adp->neighbor_nodes, struct as_node *,
46 maxneighbors + 1, NULL);
47 AS_NEW_ARRAY(adp->hashtab, struct as_hash *, hashsize, NULL);
49 adp->maxneighbors = maxneighbors;
50 adp->hashsize = hashsize;
52 adp->neighbor = neighborfunc;
53 adp->lbcost = lbcostfunc;
54 adp->realcost = realcostfunc;
55 adp->seccost = seccostfunc;
56 adp->userdata = userdata;