Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyCommandCenter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Starcraft AI Course
PyCommandCenter
Commits
f4b6ae7b
Commit
f4b6ae7b
authored
6 years ago
by
David Bergström
Browse files
Options
Downloads
Patches
Plain Diff
Add MapTools and colors
parent
8b14642b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python-api-src/lib_map_tools.cpp
+52
-0
52 additions, 0 deletions
python-api-src/lib_map_tools.cpp
python-api-src/library.cpp
+20
-0
20 additions, 0 deletions
python-api-src/library.cpp
python-api-src/library.h
+2
-1
2 additions, 1 deletion
python-api-src/library.h
with
74 additions
and
1 deletion
python-api-src/lib_map_tools.cpp
0 → 100644
+
52
−
0
View file @
f4b6ae7b
#include
"library.h"
namespace
py
=
pybind11
;
void
define_map_tools
(
py
::
module
&
m
)
{
const
CCColor
white
{
255
,
255
,
255
};
py
::
class_
<
MapTools
>
(
m
,
"MapTools"
)
.
def_property_readonly
(
"width"
,
&
MapTools
::
width
)
.
def_property_readonly
(
"height"
,
&
MapTools
::
height
)
//.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"
))
//.def("draw_line", py::overload_cast<CCPositionType, CCPositionType, CCPositionType, CCPositionType, const CCColor &>(&MapTools::drawLine, py::const_)); // TODO: Default argument??
.
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"
))
.
def
(
"draw_circle"
,
py
::
overload_cast
<
const
CCPosition
&
,
CCPositionType
,
const
CCColor
&>
(
&
MapTools
::
drawCircle
,
py
::
const_
),
py
::
arg
(
"center"
),
py
::
arg
(
"radius"
),
py
::
arg
(
"color"
))
.
def
(
"draw_text"
,
&
MapTools
::
drawText
)
.
def
(
"draw_text_screen"
,
&
MapTools
::
drawTextScreen
);
/*
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;
*/
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
python-api-src/library.cpp
+
20
−
0
View file @
f4b6ae7b
...
...
@@ -13,6 +13,7 @@ PYBIND11_MODULE(library, m)
define_point
(
m
);
define_base_location
(
m
);
define_tech_tree
(
m
);
define_map_tools
(
m
);
py
::
class_
<
Coordinator
>
(
m
,
"Coordinator"
)
.
def
(
py
::
init
())
...
...
@@ -64,6 +65,7 @@ PYBIND11_MODULE(library, m)
.
def
(
"get_player_race"
,
&
IDABot
::
GetPlayerRace
)
.
def_property_readonly
(
"base_location_manager"
,
&
IDABot
::
Bases
)
.
def_property_readonly
(
"tech_tree"
,
&
IDABot
::
TechTree
)
.
def_property_readonly
(
"map_tools"
,
&
IDABot
::
Map
)
.
def_property_readonly
(
"start_location"
,
&
IDABot
::
GetStartLocation
)
.
def_property_readonly
(
"minerals"
,
&
IDABot
::
GetMinerals
)
.
def_property_readonly
(
"current_supply"
,
&
IDABot
::
GetCurrentSupply
)
...
...
@@ -84,6 +86,24 @@ PYBIND11_MODULE(library, m)
.
value
(
"CheatMoney"
,
sc2
::
Difficulty
::
CheatMoney
)
.
value
(
"CheatInsane"
,
sc2
::
Difficulty
::
CheatInsane
);
py
::
class_
<
sc2
::
Color
>
(
m
,
"Color"
)
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<
int
,
int
,
int
>
())
.
def_readwrite
(
"r"
,
&
sc2
::
Color
::
r
)
.
def_readwrite
(
"g"
,
&
sc2
::
Color
::
g
)
.
def_readwrite
(
"b"
,
&
sc2
::
Color
::
b
);
py
::
module
colors
=
m
.
def_submodule
(
"Colors"
,
"Constants for common colors"
);
colors
.
attr
(
"White"
)
=
sc2
::
Colors
::
White
;
colors
.
attr
(
"Red"
)
=
sc2
::
Colors
::
Red
;
colors
.
attr
(
"Green"
)
=
sc2
::
Colors
::
Green
;
colors
.
attr
(
"Yellow"
)
=
sc2
::
Colors
::
Yellow
;
colors
.
attr
(
"Blue"
)
=
sc2
::
Colors
::
Blue
;
colors
.
attr
(
"Teal"
)
=
sc2
::
Colors
::
Teal
;
colors
.
attr
(
"Purple"
)
=
sc2
::
Colors
::
Purple
;
colors
.
attr
(
"Black"
)
=
sc2
::
Colors
::
Black
;
colors
.
attr
(
"Gray"
)
=
sc2
::
Colors
::
Gray
;
m
.
def
(
"create_participants"
,
&
sc2
::
CreateParticipant
,
"Create participant from agent"
);
m
.
def
(
"create_computer"
,
&
sc2
::
CreateComputer
,
"Create participant from built-in Starcraft computer"
);
}
This diff is collapsed.
Click to expand it.
python-api-src/library.h
+
2
−
1
View file @
f4b6ae7b
...
...
@@ -58,4 +58,5 @@ void define_unittype(pybind11::module &m);
void
define_util
(
pybind11
::
module
&
m
);
void
define_point
(
pybind11
::
module
&
m
);
void
define_base_location
(
pybind11
::
module
&
m
);
void
define_tech_tree
(
pybind11
::
module
&
m
);
\ No newline at end of file
void
define_tech_tree
(
pybind11
::
module
&
m
);
void
define_map_tools
(
pybind11
::
module
&
m
);
\ 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