author | truebrain |
Wed, 27 Feb 2008 21:07:31 +0000 | |
branch | noai |
changeset 9792 | e1222f4674c2 |
parent 9778 | 38560cd27070 |
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 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
7 |
int32 AITileList_vBuildable::Valuate(int32 tile) const |
9592
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 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
12 |
int32 AITileList_vWater::Valuate(int32 tile) const |
9698
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 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
17 |
int32 AITileList_vBuildableRectangle::Valuate(int32 tile) const |
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
|
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 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
33 |
int32 AITileList_vSlope::Valuate(int32 tile) const |
9611
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 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
38 |
int32 AITileList_vHeight::Valuate(int32 tile) const |
9700
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 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
43 |
int32 AITileList_vNeighbourRoadCount::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 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
48 |
int32 AITileList_vRoadTile::Valuate(int32 tile) const |
9603
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 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
53 |
int32 AITileList_vCargoAcceptance::Valuate(int32 tile) const |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9604
diff
changeset
|
54 |
{ |
9778
38560cd27070
(svn r12273) [NoAI] -Documentation: big change of many list-related comments. It is now more readable, more explaining, and all unneeded things (API-wise) are removed
truebrain
parents:
9771
diff
changeset
|
55 |
return AITile::GetCargoAcceptance(tile, this->cargo_id, 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 |
|
9771
769496a7b02e
(svn r12264) [NoAI] -Add: added AITileList_vCargoProduction (yorick)
truebrain
parents:
9753
diff
changeset
|
58 |
int32 AITileList_vCargoProduction::Valuate(int32 tile) const |
769496a7b02e
(svn r12264) [NoAI] -Add: added AITileList_vCargoProduction (yorick)
truebrain
parents:
9753
diff
changeset
|
59 |
{ |
9778
38560cd27070
(svn r12273) [NoAI] -Documentation: big change of many list-related comments. It is now more readable, more explaining, and all unneeded things (API-wise) are removed
truebrain
parents:
9771
diff
changeset
|
60 |
return AITile::GetCargoProduction(tile, this->cargo_id, this->width, this->height, this->radius); |
9771
769496a7b02e
(svn r12264) [NoAI] -Add: added AITileList_vCargoProduction (yorick)
truebrain
parents:
9753
diff
changeset
|
61 |
} |
769496a7b02e
(svn r12264) [NoAI] -Add: added AITileList_vCargoProduction (yorick)
truebrain
parents:
9753
diff
changeset
|
62 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
63 |
int32 AITileList_vDistanceManhattanToTile::Valuate(int32 tile) const |
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
|
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::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
|
66 |
} |
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
|
67 |
|
9753
7209db94ad12
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents:
9723
diff
changeset
|
68 |
int32 AITileList_vDistanceSquareToTile::Valuate(int32 tile) const |
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
|
69 |
{ |
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
|
70 |
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
|
71 |
} |