author | rubidium |
Wed, 09 Jan 2008 18:11:12 +0000 | |
branch | noai |
changeset 9723 | eee46cb39750 |
parent 9700 | e442ce398e83 |
child 9753 | 7209db94ad12 |
permissions | -rw-r--r-- |
9592
c5c09cfde63a
(svn r9625) [NoAI] -Add: added AITileList() and one valuator for now: AITileListBuildable()
truelight
parents:
diff
changeset
|
1 |
#include "ai_tilelist_valuator.hpp" |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9611
diff
changeset
|
2 |
#include "ai_tile.hpp" |
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9611
diff
changeset
|
3 |
#include "ai_road.hpp" |
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:
9617
diff
changeset
|
4 |
#include "ai_map.hpp" |
9603
49323bf80ebd
(svn r9747) [NoAI] -Add: added AITileListRoadTile and AITileListNeighbourRoad as Valuators for AITileList
truelight
parents:
9592
diff
changeset
|
5 |
#include "../../road_map.h" |
9592
c5c09cfde63a
(svn r9625) [NoAI] -Add: added AITileList() and one valuator for now: AITileListBuildable()
truelight
parents:
diff
changeset
|
6 |
|
c5c09cfde63a
(svn r9625) [NoAI] -Add: added AITileList() and one valuator for now: AITileListBuildable()
truelight
parents:
diff
changeset
|
7 |
int32 AITileListBuildable::Valuate(int32 tile) const |
c5c09cfde63a
(svn r9625) [NoAI] -Add: added AITileList() and one valuator for now: AITileListBuildable()
truelight
parents:
diff
changeset
|
8 |
{ |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9611
diff
changeset
|
9 |
return AITile::IsBuildable(tile); |
9592
c5c09cfde63a
(svn r9625) [NoAI] -Add: added AITileList() and one valuator for now: AITileListBuildable()
truelight
parents:
diff
changeset
|
10 |
} |
9603
49323bf80ebd
(svn r9747) [NoAI] -Add: added AITileListRoadTile and AITileListNeighbourRoad as Valuators for AITileList
truelight
parents:
9592
diff
changeset
|
11 |
|
9698
1d50fe99b7e9
(svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents:
9694
diff
changeset
|
12 |
int32 AITileListWater::Valuate(int32 tile) const |
1d50fe99b7e9
(svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents:
9694
diff
changeset
|
13 |
{ |
1d50fe99b7e9
(svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents:
9694
diff
changeset
|
14 |
return AITile::IsWater(tile); |
1d50fe99b7e9
(svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents:
9694
diff
changeset
|
15 |
} |
1d50fe99b7e9
(svn r10939) [NoAI] -Add: added AITileList valuator Water
truelight
parents:
9694
diff
changeset
|
16 |
|
9657
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
17 |
int32 AITileListBuildableRectangle::Valuate(int32 tile) const |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
18 |
{ |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
19 |
uint tx, ty; |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
20 |
|
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
21 |
tx = AIMap::GetTileX(tile); |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
22 |
ty = AIMap::GetTileY(tile); |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
23 |
|
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
24 |
for (uint x = tx; x < this->width + tx; x++) { |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
25 |
for (uint y = ty; y < this->height + ty; y++) { |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
26 |
if (!AITile::IsBuildable(AIMap::GetTileIndex(x, y))) return false; |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
27 |
} |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
28 |
} |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
29 |
|
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
30 |
return true; |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
31 |
} |
f2c6e332d8bc
(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
truelight
parents:
9655
diff
changeset
|
32 |
|
9611
5cf58c6571b7
(svn r9776) [NoAI] -Add: added AITileListSlope as valuator to see if tiles are flat or not
truelight
parents:
9609
diff
changeset
|
33 |
int32 AITileListSlope::Valuate(int32 tile) const |
5cf58c6571b7
(svn r9776) [NoAI] -Add: added AITileListSlope as valuator to see if tiles are flat or not
truelight
parents:
9609
diff
changeset
|
34 |
{ |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9611
diff
changeset
|
35 |
return AITile::GetSlope(tile); |
9611
5cf58c6571b7
(svn r9776) [NoAI] -Add: added AITileListSlope as valuator to see if tiles are flat or not
truelight
parents:
9609
diff
changeset
|
36 |
} |
5cf58c6571b7
(svn r9776) [NoAI] -Add: added AITileListSlope as valuator to see if tiles are flat or not
truelight
parents:
9609
diff
changeset
|
37 |
|
9700
e442ce398e83
(svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents:
9698
diff
changeset
|
38 |
int32 AITileListHeight::Valuate(int32 tile) const |
e442ce398e83
(svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents:
9698
diff
changeset
|
39 |
{ |
e442ce398e83
(svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents:
9698
diff
changeset
|
40 |
return AITile::GetHeight(tile); |
e442ce398e83
(svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents:
9698
diff
changeset
|
41 |
} |
e442ce398e83
(svn r10941) [NoAI] -Add: added AITile::GetHeight and AITileList valuator Height
truelight
parents:
9698
diff
changeset
|
42 |
|
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9611
diff
changeset
|
43 |
int32 AITileListNeighbourRoadCount::Valuate(int32 tile) const |
9603
49323bf80ebd
(svn r9747) [NoAI] -Add: added AITileListRoadTile and AITileListNeighbourRoad as Valuators for AITileList
truelight
parents:
9592
diff
changeset
|
44 |
{ |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9611
diff
changeset
|
45 |
return AIRoad::GetNeighbourRoadCount(tile); |
9603
49323bf80ebd
(svn r9747) [NoAI] -Add: added AITileListRoadTile and AITileListNeighbourRoad as Valuators for AITileList
truelight
parents:
9592
diff
changeset
|
46 |
} |
49323bf80ebd
(svn r9747) [NoAI] -Add: added AITileListRoadTile and AITileListNeighbourRoad as Valuators for AITileList
truelight
parents:
9592
diff
changeset
|
47 |
|
49323bf80ebd
(svn r9747) [NoAI] -Add: added AITileListRoadTile and AITileListNeighbourRoad as Valuators for AITileList
truelight
parents:
9592
diff
changeset
|
48 |
int32 AITileListRoadTile::Valuate(int32 tile) const |
49323bf80ebd
(svn r9747) [NoAI] -Add: added AITileListRoadTile and AITileListNeighbourRoad as Valuators for AITileList
truelight
parents:
9592
diff
changeset
|
49 |
{ |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9658
diff
changeset
|
50 |
return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) != ROAD_TILE_DEPOT; |
9603
49323bf80ebd
(svn r9747) [NoAI] -Add: added AITileListRoadTile and AITileListNeighbourRoad as Valuators for AITileList
truelight
parents:
9592
diff
changeset
|
51 |
} |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9604
diff
changeset
|
52 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9604
diff
changeset
|
53 |
int32 AITileListCargoAcceptance::Valuate(int32 tile) const |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9604
diff
changeset
|
54 |
{ |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9657
diff
changeset
|
55 |
return AITile::GetCargoAcceptance(tile, this->cargo_type, this->width, this->height, this->radius); |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9604
diff
changeset
|
56 |
} |
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:
9617
diff
changeset
|
57 |
|
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:
9617
diff
changeset
|
58 |
int32 AITileListDistanceManhattanToTile::Valuate(int32 tile) const |
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:
9617
diff
changeset
|
59 |
{ |
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:
9617
diff
changeset
|
60 |
return AIMap::DistanceManhattan(this->tile, tile); |
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:
9617
diff
changeset
|
61 |
} |
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:
9617
diff
changeset
|
62 |
|
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:
9617
diff
changeset
|
63 |
int32 AITileListDistanceSquareToTile::Valuate(int32 tile) const |
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:
9617
diff
changeset
|
64 |
{ |
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:
9617
diff
changeset
|
65 |
return AIMap::DistanceSquare(this->tile, tile); |
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:
9617
diff
changeset
|
66 |
} |