TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cherrypi::Jitter Class Reference

When featurizing units, we represent each 2D cell as having one unit. More...

#include <jitter.h>

Inherits cherrypi::BaseJitter.

Inherited by cherrypi::LayeredJitter.

Public Member Functions

 Jitter (State *st, Rect const &crop, bool allowSameType)
 
Position operator() (Unit *u) const override
 
- Public Member Functions inherited from cherrypi::BaseJitter
 BaseJitter ()
 
virtual ~BaseJitter ()=default
 

Protected Member Functions

 Jitter ()
 
void fillJitter (State *st, Rect const &crop, std::function< bool(Unit *, Unit *)> const &compatible)
 

Protected Attributes

std::unordered_map< Unit *, PositionjitteredPos_
 

Detailed Description

When featurizing units, we represent each 2D cell as having one unit.

Of course, StarCraft isn't so neat and tidy. Multiple units can be stacked on one location; sometimes ground units, but frequently air units as well.

In order to featurize units on a 2D grid, we apply jitter to shake those units out into a one-to-one cell-to-(unit or no unit) mapping. Units get moved into nearby cells for featurization.

This jitter class treats all units indiscriminately. If allowSameType is true, then we allow units of the same type to be on the same tile (no matter if they are jittered or not).

Warning: This will not behave as expected for tanks since sieged and unsieged are two different units. However, stacked tanks should be almost impossible in normal situations.

Note that neutral units will always be ignored.

Constructor & Destructor Documentation

cherrypi::Jitter::Jitter ( State st,
Rect const &  crop,
bool  allowSameType 
)
cherrypi::Jitter::Jitter ( )
inlineprotected

Member Function Documentation

void cherrypi::Jitter::fillJitter ( State st,
Rect const &  crop,
std::function< bool(Unit *, Unit *)> const &  compatible 
)
protected
Position cherrypi::Jitter::operator() ( Unit u) const
overridevirtual

Implements cherrypi::BaseJitter.

Member Data Documentation

std::unordered_map<Unit*, Position> cherrypi::Jitter::jitteredPos_
protected

The documentation for this class was generated from the following files: