src/ai/api/ai_map.hpp
author truebrain
Mon, 31 Mar 2008 06:48:59 +0000
branchnoai
changeset 9834 9abe20fc83e5
parent 9829 80fbe02a4184
child 9836 54afebfded49
permissions -rw-r--r--
(svn r12497) [NoAI] -Change [API CHANGE]: AIMap.DemolishTile -> AITile.DemolishTile (that makes much more sense, doesn't it? ;))
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     1
/* $Id$ */
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     2
9829
80fbe02a4184 (svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents: 9737
diff changeset
     3
/** @file ai_map.hpp Everything to query and manipulate map metadata. */
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     4
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     5
#ifndef AI_MAP_HPP
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     6
#define AI_MAP_HPP
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     7
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     8
#include "ai_object.hpp"
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
     9
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    10
/**
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    11
 * Class that handles all map related functions.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    12
 */
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    13
class AIMap : public AIObject {
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    14
public:
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    15
	static const char *GetClassName() { return "AIMap"; }
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    16
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9526
diff changeset
    17
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    18
	 * Checks whether the given tile is valid.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    19
	 * @param t the tile to check.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    20
	 * @return true is the tile it within the boundaries of the map.
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    21
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    22
	static bool IsValidTile(TileIndex t);
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    23
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    24
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    25
	 * Gets the number of tiles in the map.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    26
	 * @return the size of the map in tiles.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    27
	 * @post return value is always positive.
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    28
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    29
	static TileIndex GetMapSize();
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    30
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    31
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    32
	 * Gets the amount of tiles along the SW and NE border.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    33
	 * @return the length along the SW and NE borders.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    34
	 * @post return value is always positive.
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    35
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    36
	static uint32 GetMapSizeX();
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    37
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    38
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    39
	 * Gets the amount of tiles along the SE and NW border.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    40
	 * @return the length along the SE and NW borders.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    41
	 * @post return value is always positive.
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    42
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    43
	static uint32 GetMapSizeY();
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    44
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    45
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    46
	 * Gets the place along the SW/NE border (X-value).
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    47
	 * @param t the tile to get the X-value of.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    48
	 * @pre t has to be valid (use IsValidTile(t)).
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    49
	 * @return the X-value.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    50
	 * @post return value is lower than GetMapSizeX().
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    51
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    52
	static uint32 GetTileX(TileIndex t);
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    53
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    54
	/**
9448
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    55
	 * Gets the place along the SE/NW border (Y-value).
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    56
	 * @param t the tile to get the Y-value of.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    57
	 * @pre t has to be valid (use IsValidTile(t)).
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    58
	 * @return the Y-value.
2a4c4340233d (svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents: 9427
diff changeset
    59
	 * @post return value is lower than GetMapSizeY().
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
    60
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    61
	static uint32 GetTileY(TileIndex t);
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    62
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    63
	/**
9502
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    64
	 * Gets the TileIndex given a x,y-coordinate.
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    65
	 * @param x the X coordinate.
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    66
	 * @param y the Y coordinate.
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    67
	 * @pre x has to be lower than GetMapSizeX().
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    68
	 * @pre y has to be lower than GetMapSizeY().
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    69
	 * @return the TileIndex for the given x,y coordinate.
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    70
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    71
	static TileIndex GetTileIndex(uint32 x, uint32 y);
9502
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    72
5eb285182114 (svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents: 9489
diff changeset
    73
	/**
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    74
	 * Calculates the Manhattan distance; the difference of
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    75
	 * the X and Y added together.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    76
	 * @param t1 the start.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    77
	 * @param t2 the destination.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    78
	 * @pre t1 has to be valid (use IsValidTile(t1)).
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    79
	 * @pre t2 has to be valid (use IsValidTile(t2)).
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    80
	 * @return the Manhattan distance.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    81
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    82
	static uint32 DistanceManhattan(TileIndex t1, TileIndex t2);
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    83
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    84
	/**
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    85
	 * Calculates the distance between xy1 and xy2 via 1D calculation.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    86
	 *  (so the distance between X or the distance between Y, depending
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    87
	 *    on which one is bigger).
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    88
	 * @param t1 the start.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    89
	 * @param t2 the destination.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    90
	 * @pre t1 has to be valid (use IsValidTile(t1)).
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    91
	 * @pre t2 has to be valid (use IsValidTile(t2)).
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    92
	 * @return the maximum distance of X and Y.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    93
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
    94
	static uint32 DistanceMax(TileIndex t1, TileIndex t2);
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    95
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    96
	/**
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    97
	 * The squared distance between the two tiles.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    98
	 * This is the distance is the length of the shortest straight
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
    99
	 * line between both points.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   100
	 * @param t1 the start.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   101
	 * @param t2 the destination.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   102
	 * @pre t1 has to be valid (use IsValidTile(t1)).
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   103
	 * @pre t2 has to be valid (use IsValidTile(t2)).
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   104
	 * @return the distance.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   105
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
   106
	static uint32 DistanceSquare(TileIndex t1, TileIndex t2);
9489
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   107
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   108
	/**
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   109
	 * Calculates the shortest distance to the edge.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   110
	 * @param t from where the distance has to be calculated.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   111
	 * @pre t has to be valid (use IsValidTile(t)).
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   112
	 * @return the distances to the closest edge.
d7ee0a65ead9 (svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents: 9448
diff changeset
   113
	 */
9655
e8e43f333832 (svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents: 9596
diff changeset
   114
	static uint32 DistanceFromEdge(TileIndex t);
9379
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
   115
};
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
   116
6e89b780c2c9 (svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff changeset
   117
#endif /* AI_MAP_HPP */