src/ai/api/ai_tilelist_valuator.hpp
author truelight
Sat, 14 Jul 2007 21:15:49 +0000
branchnoai
changeset 9657 f2c6e332d8bc
parent 9655 e8e43f333832
child 9658 e7675771bca4
permissions -rw-r--r--
(svn r10564) [NoAI] -Add: added a AITileList valuator that checks for a NxM buildable spot with the entry from the AITileList as top-left tile
/* $Id$ */

/** @file ai_tilelist_valuator.hpp all the valuators for tilelist */

#ifndef AI_TILELIST_VALUATOR_HPP
#define AI_TILELIST_VALUATOR_HPP

#include "ai_abstractlist.hpp"

/**
 * Check if tiles are buildable for entries in an AITileList instance.
 * @note resulting items are of the type bool (0 = not buildable, 1 = buildable)
 * @note the input items are of the type TileIndex
 */
class AITileListBuildable : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListBuildable"; }

private:
	int32 Valuate(int32 tile) const;
};

/**
 * Check if tiles are buildable in a rectangle around entries in an AITileList instance, with the entry in the list as top-left.
 * @note resulting items are of the type bool (0 = not buildable, 1 = buildable)
 * @note the input items are of the type TileIndex
 */
class AITileListBuildableRectangle : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListBuildableRectangle"; }

	AITileListBuildableRectangle(uint width, uint height) { this->width = width; this->height = height; }

private:
	uint width, height;

	int32 Valuate(int32 tile) const;
};

/**
 * Check how tiles in an AITileList instance are sloped.
 * @note resulting items are of the type int32 (0 = flat, > 1 = slope)
 * @note the input items are of the type TileIndex
 */
class AITileListSlope : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListSlope"; }

private:
	int32 Valuate(int32 tile) const;
};

/**
 * Count the neighbour tiles which have a piece of road of tiles in AITileList.
 * @note resulting items are of the type int32 (the amount of neighbour road tiles)
 * @note the input items are of the type TileIndex
 */
class AITileListNeighbourRoadCount : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListNeighbourRoad"; }

private:
	int32 Valuate(int32 tile) const;
};

/**
 * Check if the tiles in AITileList have a piece of road on them.
 * @note resulting items are of the type bool (0 = no road, 1 = road)
 * @note the input items are of the type TileIndex
 */
class AITileListRoadTile : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListRoadTile"; }

private:
	int32 Valuate(int32 tile) const;
};

/**
 * Get the amount of estimated accepted cargo for all tiles in AITileList.
 * If this value is >= 8, it means it will accept this cargo. For passengers
 *  and mail it is also a good indicator how much cargo would be brought to
 *  the station.
 * @post values < 8 means this tile does not accept this cargo.
 * @note resulting items are of the type int32 (indicating acceptance)
 * @note the input items are of the type TileIndex
 */
class AITileListCargoAcceptance : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListCargoAcceptance"; }

	/**
	 * Custom constructor, we want a cargo-type as parameter.
	 */
	AITileListCargoAcceptance(CargoID cargo_type) { this->cargo_type = cargo_type; }

private:
	CargoID cargo_type;

	int32 Valuate(int32 tile) const;
};

/**
 * Get the manhattan distance to a tile for entries in an AITileList instance.
 * @note resulting items are of the type distance
 * @note the input items are of the type TileIndex
 */
class AITileListDistanceManhattanToTile : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListDistanceManhattanToTile"; }

	/**
	 * Custom constructor, we want a tile as parameter.
	 */
	AITileListDistanceManhattanToTile(TileIndex tile) { this->tile = tile; }

private:
	TileIndex tile;

	int32 Valuate(int32 station) const;
};

/**
 * Get the sqsuare distance to a tile for entries in an AITileList instance.
 * @note resulting items are of the type distance
 * @note the input items are of the type TileIndex
 */
class AITileListDistanceSquareToTile : public AIAbstractList::Valuator {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AITileListDistanceSquareToTile"; }

	/**
	 * Custom constructor, we want a tile as parameter.
	 */
	AITileListDistanceSquareToTile(TileIndex tile) { this->tile = tile; }

private:
	TileIndex tile;

	int32 Valuate(int32 station) const;
};


#endif /* AI_TILELIST_VALUATOR_HPP */