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
4fce66f8
Commit
4fce66f8
authored
4 years ago
by
Hannes Jämtner
Browse files
Options
Downloads
Patches
Plain Diff
carry now exist in IDABot
parent
32cfd745
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Uppdaterat API
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
docs/idabot.rst
+4
-0
4 additions, 0 deletions
docs/idabot.rst
python-api-src/library.cpp
+22
-18
22 additions, 18 deletions
python-api-src/library.cpp
src/IDABot.cpp
+16
-0
16 additions, 0 deletions
src/IDABot.cpp
src/IDABot.h
+7
-0
7 additions, 0 deletions
src/IDABot.h
with
49 additions
and
18 deletions
docs/idabot.rst
+
4
−
0
View file @
4fce66f8
...
...
@@ -59,6 +59,10 @@ IDABot
Sends the string 'message' to the game chat
.. method:: IDABot.carry_vespene(self, unit) -> Boolean
"Returns true if unit carries a vespene"
Attributes:
.. autoattribute:: minerals
...
...
This diff is collapsed.
Click to expand it.
python-api-src/library.cpp
+
22
−
18
View file @
4fce66f8
...
...
@@ -66,24 +66,28 @@ PYBIND11_MODULE(library, m)
// IDABot is a specialization of Agent
py
::
class_
<
IDABot
,
PyIDABot
,
sc2
::
Agent
>
(
m
,
"IDABot"
)
.
def
(
py
::
init
())
.
def
(
"on_game_start"
,
&
IDABot
::
OnGameStart
)
.
def
(
"on_step"
,
&
IDABot
::
OnStep
)
.
def
(
"send_chat"
,
&
IDABot
::
SendChat
,
"Send a message to the game chat"
,
"message"
_a
)
.
def
(
"get_all_units"
,
&
IDABot
::
GetAllUnits
,
"Returns a list of all units"
)
.
def
(
"get_my_units"
,
&
IDABot
::
GetMyUnits
,
"Returns a list of all units beloning to the player"
)
.
def
(
"get_player_race"
,
&
IDABot
::
GetPlayerRace
)
.
def_property_readonly
(
"base_location_manager"
,
&
IDABot
::
Bases
)
.
def_property_readonly
(
"tech_tree"
,
&
IDABot
::
GetTechTree
)
.
def_property_readonly
(
"map_tools"
,
&
IDABot
::
Map
)
.
def_property_readonly
(
"building_placer"
,
&
IDABot
::
GetBuildingPlacer
)
.
def_property_readonly
(
"start_location"
,
&
IDABot
::
GetStartLocation
,
"CCPosition representing the start location"
)
.
def_property_readonly
(
"start_locations"
,
&
IDABot
::
GetStartLocations
,
"CCPosition representing the start locations"
)
.
def_property_readonly
(
"minerals"
,
&
IDABot
::
GetMinerals
,
"How much minerals we currently have"
)
.
def_property_readonly
(
"current_supply"
,
&
IDABot
::
GetCurrentSupply
,
"How much supply we are currently using"
)
.
def_property_readonly
(
"max_supply"
,
&
IDABot
::
GetMaxSupply
,
"How much supply we can currently use"
)
.
def_property_readonly
(
"gas"
,
&
IDABot
::
GetGas
,
"How much gas we currently have"
)
.
def_property_readonly
(
"current_frame"
,
&
IDABot
::
GetCurrentFrame
,
"Which frame we are currently on"
);
.
def
(
py
::
init
())
.
def
(
"on_game_start"
,
&
IDABot
::
OnGameStart
)
.
def
(
"on_step"
,
&
IDABot
::
OnStep
)
.
def
(
"send_chat"
,
&
IDABot
::
SendChat
,
"Send a message to the game chat"
,
"message"
_a
)
.
def
(
"get_all_units"
,
&
IDABot
::
GetAllUnits
,
"Returns a list of all units"
)
.
def
(
"get_my_units"
,
&
IDABot
::
GetMyUnits
,
"Returns a list of all units beloning to the player"
)
.
def
(
"get_player_race"
,
&
IDABot
::
GetPlayerRace
)
.
def
(
"carry_vespene"
,
&
IDABot
::
isCarryingVespene
,
"If unit carries a vespene"
)
.
def
(
"carry_mineral"
,
&
IDABot
::
isCarryingMineral
,
"If unit carries a mineral"
)
.
def_property_readonly
(
"base_location_manager"
,
&
IDABot
::
Bases
)
.
def_property_readonly
(
"tech_tree"
,
&
IDABot
::
GetTechTree
)
.
def_property_readonly
(
"map_tools"
,
&
IDABot
::
Map
)
.
def_property_readonly
(
"building_placer"
,
&
IDABot
::
GetBuildingPlacer
)
.
def_property_readonly
(
"start_location"
,
&
IDABot
::
GetStartLocation
,
"CCPosition representing the start location"
)
.
def_property_readonly
(
"start_locations"
,
&
IDABot
::
GetStartLocations
,
"CCPosition representing the start locations"
)
.
def_property_readonly
(
"minerals"
,
&
IDABot
::
GetMinerals
,
"How much minerals we currently have"
)
.
def_property_readonly
(
"current_supply"
,
&
IDABot
::
GetCurrentSupply
,
"How much supply we are currently using"
)
.
def_property_readonly
(
"max_supply"
,
&
IDABot
::
GetMaxSupply
,
"How much supply we can currently use"
)
.
def_property_readonly
(
"gas"
,
&
IDABot
::
GetGas
,
"How much gas we currently have"
)
.
def_property_readonly
(
"current_frame"
,
&
IDABot
::
GetCurrentFrame
,
"Which frame we are currently on"
);
// API extended summer 2020
py
::
class_
<
sc2
::
PlayerSetup
>
(
m
,
"PlayerSetup"
);
...
...
This diff is collapsed.
Click to expand it.
src/IDABot.cpp
+
16
−
0
View file @
4fce66f8
...
...
@@ -224,3 +224,19 @@ const TypeData & IDABot::Data(const MetaType & type) const
{
return
m_techTree
.
getData
(
type
);
}
/*
API extended summer 2020
*/
bool
IDABot
::
isCarryingVespene
(
Unit
const
unit
)
const
{
const
sc2
::
Unit
*
sc2unit
=
unit
.
getUnitPtr
();
return
Observation
()
->
IsUnitCarryVespene
(
*
sc2unit
);
}
bool
IDABot
::
isCarryingMineral
(
Unit
const
unit
)
const
{
const
sc2
::
Unit
*
sc2unit
=
unit
.
getUnitPtr
();
return
Observation
()
->
IsUnitCarryMineral
(
*
sc2unit
);
}
This diff is collapsed.
Click to expand it.
src/IDABot.h
+
7
−
0
View file @
4fce66f8
...
...
@@ -59,6 +59,13 @@ public:
const
std
::
vector
<
Unit
>
GetUnits
(
const
UnitType
&
type
,
int
player
=
Players
::
Self
)
const
;
const
std
::
vector
<
CCPosition
>
&
GetStartLocations
()
const
;
/*
API extended summer 2020
*/
bool
isCarryingVespene
(
Unit
const
unit
)
const
;
bool
isCarryingMineral
(
Unit
const
unit
)
const
;
// Not needed, just convenience functions
const
TypeData
&
Data
(
const
UnitType
&
type
)
const
;
const
TypeData
&
Data
(
const
CCUpgrade
&
type
)
const
;
...
...
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