src/aystar.h
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6298 c30fe89622df
child 6872 1c4a4a609f85
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2008
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2008
diff changeset
     2
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 5838
diff changeset
     3
/** @file aystar.h
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
     4
 * This file has the header for AyStar
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
     5
 *  AyStar is a fast pathfinding routine and is used for things like
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
     6
 *  AI_pathfinding and Train_pathfinding.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
     7
 *  For more information about AyStar (A* Algorithm), you can look at
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4171
diff changeset
     8
 *   http://en.wikipedia.org/wiki/A-star_search_algorithm
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
     9
 */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    10
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    11
#ifndef AYSTAR_H
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    12
#define AYSTAR_H
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    13
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    14
#include "queue.h"
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    15
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    16
//#define AYSTAR_DEBUG
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    17
enum {
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    18
	AYSTAR_FOUND_END_NODE,
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    19
	AYSTAR_EMPTY_OPENLIST,
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    20
	AYSTAR_STILL_BUSY,
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    21
	AYSTAR_NO_PATH,
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    22
	AYSTAR_LIMIT_REACHED,
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    23
	AYSTAR_DONE
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    24
};
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    25
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    26
enum{
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    27
	AYSTAR_INVALID_NODE = -1,
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    28
};
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    29
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    30
struct AyStarNode {
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1777
diff changeset
    31
	TileIndex tile;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    32
	int direction;
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    33
	uint user_data[2];
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    34
};
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    35
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    36
// The resulting path has nodes looking like this.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    37
struct PathNode {
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    38
	AyStarNode node;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    39
	// The parent of this item
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    40
	PathNode *parent;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    41
};
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    42
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    43
// For internal use only
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    44
// We do not save the h-value, because it is only needed to calculate the f-value.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    45
//  h-value should _always_ be the distance left to the end-tile.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    46
struct OpenListNode {
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    47
	int g;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    48
	PathNode path;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    49
};
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    50
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    51
struct AyStar;
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    52
/*
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    53
 * This function is called to check if the end-tile is found
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    54
 *  return values can be:
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4171
diff changeset
    55
 *   AYSTAR_FOUND_END_NODE : indicates this is the end tile
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4171
diff changeset
    56
 *   AYSTAR_DONE : indicates this is not the end tile (or direction was wrong)
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    57
 */
1617
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    58
/*
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    59
 * The 2nd parameter should be OpenListNode, and NOT AyStarNode. AyStarNode is
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    60
 * part of OpenListNode and so it could be accessed without any problems.
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    61
 * The good part about OpenListNode is, and how AIs use it, that you can
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    62
 * access the parent of the current node, and so check if you, for example
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    63
 * don't try to enter the file tile with a 90-degree curve. So please, leave
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    64
 * this an OpenListNode, it works just fine -- TrueLight
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    65
 */
55878ca5ada9 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be
truelight
parents: 1459
diff changeset
    66
typedef int32 AyStar_EndNodeCheck(AyStar *aystar, OpenListNode *current);
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    67
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    68
/*
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    69
 * This function is called to calculate the G-value for AyStar Algorithm.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    70
 *  return values can be:
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4171
diff changeset
    71
 *   AYSTAR_INVALID_NODE : indicates an item is not valid (e.g.: unwalkable)
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4171
diff changeset
    72
 *   Any value >= 0 : the g-value for this tile
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    73
 */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    74
typedef int32 AyStar_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    75
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    76
/*
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    77
 * This function is called to calculate the H-value for AyStar Algorithm.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    78
 *  Mostly, this must result the distance (Manhattan way) between the
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    79
 *   current point and the end point
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    80
 *  return values can be:
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4171
diff changeset
    81
 *   Any value >= 0 : the h-value for this tile
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    82
 */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    83
typedef int32 AyStar_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    85
/*
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    86
 * This function request the tiles around the current tile and put them in tiles_around
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    87
 *  tiles_around is never resetted, so if you are not using directions, just leave it alone.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    88
 * Warning: never add more tiles_around than memory allocated for it.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    89
 */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    90
typedef void AyStar_GetNeighbours(AyStar *aystar, OpenListNode *current);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    91
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    92
/*
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    93
 * If the End Node is found, this function is called.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    94
 *  It can do, for example, calculate the route and put that in an array
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    95
 */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    96
typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    97
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
    98
// For internal use, see aystar.c
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
    99
typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g);
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   100
typedef int AyStar_Main(AyStar *aystar);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   101
typedef int AyStar_Loop(AyStar *aystar);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   102
typedef int AyStar_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   103
typedef void AyStar_Free(AyStar *aystar);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   104
typedef void AyStar_Clear(AyStar *aystar);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   105
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   106
struct AyStar {
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   107
/* These fields should be filled before initting the AyStar, but not changed
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   108
 * afterwards (except for user_data and user_path)! (free and init again to change them) */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   109
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   110
	/* These should point to the application specific routines that do the
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   111
	 * actual work */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   112
	AyStar_CalculateG *CalculateG;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   113
	AyStar_CalculateH *CalculateH;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   114
	AyStar_GetNeighbours *GetNeighbours;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   115
	AyStar_EndNodeCheck *EndNodeCheck;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   116
	AyStar_FoundEndNode *FoundEndNode;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 84
diff changeset
   117
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   118
	/* These are completely untouched by AyStar, they can be accesed by
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   119
	 * the application specific routines to input and output data.
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   120
	 * user_path should typically contain data about the resulting path
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   121
	 * afterwards, user_target should typically contain information about
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   122
	 * what where looking for, and user_data can contain just about
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   123
	 * everything */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   124
	void *user_path;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   125
	void *user_target;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   126
	uint user_data[10];
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 84
diff changeset
   127
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   128
	/* How many loops are there called before AyStarMain_Main gives
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   129
	 * control back to the caller. 0 = until done */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   130
	byte loops_per_tick;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   131
	/* If the g-value goes over this number, it stops searching
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   132
	 *  0 = infinite */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   133
	uint max_path_cost;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   134
	/* The maximum amount of nodes that will be expanded, 0 = infinite */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 84
diff changeset
   135
	uint max_search_nodes;
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   136
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   137
	/* These should be filled with the neighbours of a tile by
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   138
	 * GetNeighbours */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   139
	AyStarNode neighbours[12];
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   140
	byte num_neighbours;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   141
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   142
	/* These will contain the methods for manipulating the AyStar. Only
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   143
	 * main() should be called externally */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   144
	AyStar_AddStartNode *addstart;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   145
	AyStar_Main *main;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   146
	AyStar_Loop *loop;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   147
	AyStar_Free *free;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   148
	AyStar_Clear *clear;
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   149
	AyStar_CheckTile *checktile;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 84
diff changeset
   150
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   151
	/* These will contain the open and closed lists */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   152
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   153
	/* The actual closed list */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   154
	Hash ClosedListHash;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   155
	/* The open queue */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   156
	Queue OpenListQueue;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   157
	/* An extra hash to speed up the process of looking up an element in
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   158
	 * the open list */
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   159
	Hash OpenListHash;
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   160
};
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   161
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   162
1777
d328484bd6f2 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents: 1617
diff changeset
   163
void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g);
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   164
int AyStarMain_Main(AyStar *aystar);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   165
int AyStarMain_Loop(AyStar *aystar);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   166
int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   167
void AyStarMain_Free(AyStar *aystar);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   168
void AyStarMain_Clear(AyStar *aystar);
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   169
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   170
/* Initialize an AyStar. You should fill all appropriate fields before
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   171
 * callling init_AyStar (see the declaration of AyStar for which fields are
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   172
 * internal */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 2916
diff changeset
   173
void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 84
diff changeset
   174
84
1e0721c29bad (svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
diff changeset
   175
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
   176
#endif /* AYSTAR_H */