Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyCommandCenter v2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Bonnaudet
PyCommandCenter v2
Commits
20a04e7a
Commit
20a04e7a
authored
6 years ago
by
David Bergström
Browse files
Options
Downloads
Patches
Plain Diff
Add remaining methods to MapTools
parent
d1704107
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/managers.rst
+10
-1
10 additions, 1 deletion
docs/managers.rst
python-api-src/lib_color.cpp
+1
-0
1 addition, 0 deletions
python-api-src/lib_color.cpp
python-api-src/lib_map_tools.cpp
+35
-39
35 additions, 39 deletions
python-api-src/lib_map_tools.cpp
with
46 additions
and
40 deletions
docs/managers.rst
+
10
−
1
View file @
20a04e7a
...
...
@@ -84,13 +84,22 @@ MapTools
.. autoclass:: library.MapTools
:members:
:undoc-members:
Color
~~~~~
.. autoclass:: library.Color
:members:
:undoc-members:
.. TODO: Only include the constructor and the color constants
DistanceMap
~~~~~~~~~~~
.. autoclass:: library.DistanceMap
:members:
:undoc-members:
BuildingPlacer
--------------
...
...
This diff is collapsed.
Click to expand it.
python-api-src/lib_color.cpp
+
1
−
0
View file @
20a04e7a
...
...
@@ -10,6 +10,7 @@ void define_color(py::module & m)
color
.
def_readwrite
(
"r"
,
&
sc2
::
Color
::
r
,
"Red"
);
color
.
def_readwrite
(
"g"
,
&
sc2
::
Color
::
g
,
"Green"
);
color
.
def_readwrite
(
"b"
,
&
sc2
::
Color
::
b
,
"Blue"
);
color
.
def
(
"__repr__"
,
[](
const
sc2
::
Color
&
c
)
{
return
"<Color ("
+
std
::
to_string
(
c
.
r
)
+
", "
+
std
::
to_string
(
c
.
g
)
+
", "
+
std
::
to_string
(
c
.
b
)
+
")>"
;
});
color
.
attr
(
"WHITE"
)
=
sc2
::
Colors
::
White
;
color
.
attr
(
"RED"
)
=
sc2
::
Colors
::
Red
;
color
.
attr
(
"GREEN"
)
=
sc2
::
Colors
::
Green
;
...
...
This diff is collapsed.
Click to expand it.
python-api-src/lib_map_tools.cpp
+
35
−
39
View file @
20a04e7a
...
...
@@ -4,48 +4,44 @@ namespace py = pybind11;
void
define_map_tools
(
py
::
module
&
m
)
{
py
::
class_
<
DistanceMap
>
(
m
,
"DistanceMap"
)
.
def
(
"computer_distance_map"
,
&
DistanceMap
::
computeDistanceMap
,
"bot"
_a
,
"start_tile"
_a
)
.
def
(
"get_distance"
,
py
::
overload_cast
<
const
CCTilePosition
&>
(
&
DistanceMap
::
getDistance
,
py
::
const_
),
"position"
_a
)
.
def
(
"get_distance"
,
py
::
overload_cast
<
const
CCPosition
&>
(
&
DistanceMap
::
getDistance
,
py
::
const_
),
"position"
_a
)
.
def
(
"get_sorted_tiles"
,
&
DistanceMap
::
getSortedTiles
)
.
def
(
"get_start_tile"
,
&
DistanceMap
::
getStartTile
)
.
def
(
"draw"
,
&
DistanceMap
::
draw
,
"bot"
_a
);
const
CCColor
white
{
255
,
255
,
255
};
py
::
class_
<
MapTools
>
(
m
,
"MapTools"
)
.
def_property_readonly
(
"width"
,
&
MapTools
::
width
,
"The width of the map"
)
.
def_property_readonly
(
"height"
,
&
MapTools
::
height
,
"The height of the map"
)
//.def("terrainHeight", &MapTools::terrainHeight, py::const_)
.
def
(
"draw_line"
,
py
::
overload_cast
<
const
CCPosition
&
,
const
CCPosition
&
,
const
CCColor
&>
(
&
MapTools
::
drawLine
,
py
::
const_
),
py
::
arg
(
"start"
),
py
::
arg
(
"stop"
),
py
::
arg
(
"color"
)
=
white
)
.
def
(
"draw_box"
,
py
::
overload_cast
<
const
CCPosition
&
,
const
CCPosition
&
,
const
CCColor
&>
(
&
MapTools
::
drawBox
,
py
::
const_
),
py
::
arg
(
"top_left"
),
py
::
arg
(
"bottom_right"
),
py
::
arg
(
"color"
)
=
white
)
.
def
(
"draw_circle"
,
py
::
overload_cast
<
const
CCPosition
&
,
CCPositionType
,
const
CCColor
&>
(
&
MapTools
::
drawCircle
,
py
::
const_
),
py
::
arg
(
"center"
),
py
::
arg
(
"radius"
),
py
::
arg
(
"color"
)
=
white
)
.
def
(
"draw_text"
,
&
MapTools
::
drawText
,
"position"
_a
,
"text"
_a
,
"color"
_a
=
white
)
.
def
(
"draw_text_screen"
,
&
MapTools
::
drawTextScreen
,
"percentage_x"
_a
,
"percentage_y"
_a
,
"text"
_a
,
"color"
_a
=
white
);
/*
TODO: Left to implement
drawBox(CCPositionType x1, CCPositionType y1, CCPositionType x2, CCPositionType y2, const CCColor & color = CCColor(255, 255, 255)) const;
drawCircle(CCPositionType x1, CCPositionType x2, CCPositionType radius, const CCColor & color = CCColor(255, 255, 255)) const;
isValidTile(int tileX, int tileY) const;
isValidTile(const CCTilePosition & tile) const;
isValidPosition(const CCPosition & pos) const;
isPowered(int tileX, int tileY) const;
isExplored(int tileX, int tileY) const;
isExplored(const CCPosition & pos) const;
isExplored(const CCTilePosition & pos) const;
isVisible(int tileX, int tileY) const;
canBuildTypeAtPosition(int tileX, int tileY, const UnitType & type) const;
getDistanceMap(const CCTilePosition & tile) const;
getDistanceMap(const CCPosition & tile) const;
getGroundDistance(const CCPosition & src, const CCPosition & dest) const;
isConnected(int x1, int y1, int x2, int y2) const;
isConnected(const CCTilePosition & from, const CCTilePosition & to) const;
isConnected(const CCPosition & from, const CCPosition & to) const;
isWalkable(int tileX, int tileY) const;
isWalkable(const CCTilePosition & tile) const;
isBuildable(int tileX, int tileY) const;
isBuildable(const CCTilePosition & tile) const;
isDepotBuildableTile(int tileX, int tileY) const;
getLeastRecentlySeenTile() const;
// returns a list of all tiles on the map, sorted by 4-direcitonal walk distance from the given position
const std::vector<CCTilePosition> & getClosestTilesTo(const CCTilePosition & pos) const;
*/
.
def
(
"draw_line"
,
py
::
overload_cast
<
const
CCPosition
&
,
const
CCPosition
&
,
const
CCColor
&>
(
&
MapTools
::
drawLine
,
py
::
const_
),
py
::
arg
(
"start"
),
py
::
arg
(
"stop"
),
py
::
arg
(
"color"
)
=
sc2
::
Colors
::
White
)
.
def
(
"draw_box"
,
py
::
overload_cast
<
const
CCPosition
&
,
const
CCPosition
&
,
const
CCColor
&>
(
&
MapTools
::
drawBox
,
py
::
const_
),
py
::
arg
(
"top_left"
),
py
::
arg
(
"bottom_right"
),
py
::
arg
(
"color"
)
=
sc2
::
Colors
::
White
)
.
def
(
"draw_circle"
,
py
::
overload_cast
<
const
CCPosition
&
,
CCPositionType
,
const
CCColor
&>
(
&
MapTools
::
drawCircle
,
py
::
const_
),
py
::
arg
(
"center"
),
py
::
arg
(
"radius"
),
py
::
arg
(
"color"
)
=
sc2
::
Colors
::
White
)
.
def
(
"draw_text"
,
&
MapTools
::
drawText
,
"position"
_a
,
"text"
_a
,
"color"
_a
=
sc2
::
Colors
::
White
)
.
def
(
"draw_text_screen"
,
&
MapTools
::
drawTextScreen
,
"percentage_x"
_a
,
"percentage_y"
_a
,
"text"
_a
,
"color"
_a
=
sc2
::
Colors
::
White
)
.
def
(
"is_valid_tile"
,
py
::
overload_cast
<
int
,
int
>
(
&
MapTools
::
isValidTile
,
py
::
const_
),
"x"
_a
,
"y"
_a
)
.
def
(
"is_valid_tile"
,
py
::
overload_cast
<
const
CCTilePosition
&>
(
&
MapTools
::
isValidTile
,
py
::
const_
),
"point_2di"
_a
)
.
def
(
"is_valid_position"
,
py
::
overload_cast
<
const
CCPosition
&>
(
&
MapTools
::
isValidPosition
,
py
::
const_
),
"point_2d"
_a
)
.
def
(
"is_powered"
,
&
MapTools
::
isPowered
,
"x"
_a
,
"y"
_a
)
.
def
(
"is_explored"
,
py
::
overload_cast
<
int
,
int
>
(
&
MapTools
::
isExplored
,
py
::
const_
),
"x"
_a
,
"y"
_a
)
.
def
(
"is_explored"
,
py
::
overload_cast
<
const
CCPosition
&>
(
&
MapTools
::
isExplored
,
py
::
const_
),
"point2d"
_a
)
.
def
(
"is_explored"
,
py
::
overload_cast
<
const
CCTilePosition
&>
(
&
MapTools
::
isExplored
,
py
::
const_
),
"point2di"
_a
)
.
def
(
"is_connected"
,
py
::
overload_cast
<
int
,
int
,
int
,
int
>
(
&
MapTools
::
isConnected
,
py
::
const_
),
"x1"
_a
,
"y1"
_a
,
"x2"
_a
,
"y2"
_a
)
.
def
(
"is_connected"
,
py
::
overload_cast
<
const
CCTilePosition
&
,
const
CCTilePosition
&>
(
&
MapTools
::
isConnected
,
py
::
const_
),
"from"
_a
,
"too"
_a
)
.
def
(
"is_connected"
,
py
::
overload_cast
<
const
CCPosition
&
,
const
CCPosition
&>
(
&
MapTools
::
isConnected
,
py
::
const_
),
"from"
_a
,
"too"
_a
)
.
def
(
"is_walkable"
,
py
::
overload_cast
<
int
,
int
>
(
&
MapTools
::
isWalkable
,
py
::
const_
),
"x"
_a
,
"y"
_a
)
.
def
(
"is_walkable"
,
py
::
overload_cast
<
const
CCTilePosition
&>
(
&
MapTools
::
isWalkable
,
py
::
const_
),
"point2di"
_a
)
.
def
(
"is_buildable"
,
py
::
overload_cast
<
int
,
int
>
(
&
MapTools
::
isBuildable
,
py
::
const_
),
"x"
_a
,
"y"
_a
)
.
def
(
"is_buildable"
,
py
::
overload_cast
<
const
CCTilePosition
&>
(
&
MapTools
::
isBuildable
,
py
::
const_
),
"point2di"
_a
)
.
def
(
"is_visible"
,
&
MapTools
::
isVisible
,
"x"
_a
,
"y"
_a
)
.
def
(
"can_build_type_at_position"
,
&
MapTools
::
canBuildTypeAtPosition
,
"x"
_a
,
"y"
_a
,
"unit_type"
_a
)
.
def
(
"is_depot_buildable_tile"
,
&
MapTools
::
isDepotBuildableTile
,
"x"
_a
,
"y"
_a
)
.
def
(
"get_ground_distance"
,
&
MapTools
::
getGroundDistance
,
"from"
_a
,
"to"
_a
)
.
def
(
"get_distance_map"
,
py
::
overload_cast
<
const
CCTilePosition
&>
(
&
MapTools
::
getDistanceMap
,
py
::
const_
),
"point2di"
_a
)
.
def
(
"get_distance_map"
,
py
::
overload_cast
<
const
CCPosition
&>
(
&
MapTools
::
getDistanceMap
,
py
::
const_
),
"point2d"
_a
)
.
def
(
"get_closest_tiles_to"
,
&
MapTools
::
getClosestTilesTo
,
"Returns a list of positions, where the first position is the closest and the last is the furthest"
,
"point2di"
_a
)
.
def
(
"get_least_recently_seen_tile"
,
&
MapTools
::
getLeastRecentlySeenTile
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment