class_docstr: An agent for solving CollectMineralShards with raw units and actions.
  
  Controls the two marines independently:
  - move to nearest mineral shard that wasn't the previous target
  - swap marine and repeat
class_docstr_tok: ["An","agent","for","solving","CollectMineralShards","with","raw","units","and","actions",".","Controls","the","two","marines","independently",":","-","move","to","nearest","mineral","shard","that","was","n't","the","previous","target","-","swap","marine","and","repeat"]
code: def step(self, obs):
      super(CollectMineralShardsRaw, self).step(obs)
      marines = [
          unit
          for unit in obs.observation.raw_units
          if unit.alliance == _PLAYER_SELF
      ]
      if not marines:
          return RAW_FUNCTIONS.no_op()
      marine_unit = next(
          (m for m in marines if m.tag != self._last_marine)
      )
      marine_xy = [marine_unit.x, marine_unit.y]
  
      minerals = [
          [unit.x, unit.y]
          for unit in obs.observation.raw_units
          if unit.alliance == _PLAYER_NEUTRAL
      ]
  
      if self._previous_mineral_xy in minerals:
          # Don't go for the same mineral shard as other marine.
          minerals.remove(self._previous_mineral_xy)
  
      if minerals:
          # Find the closest.
          distances = numpy.linalg.norm(
              numpy.array(minerals) - numpy.array(marine_xy), axis=1
          )
          closest_mineral_xy = minerals[numpy.argmin(distances)]
  
          self._last_marine = marine_unit.tag
          self._previous_mineral_xy = closest_mineral_xy
          return RAW_FUNCTIONS.Move_pt(
              "now", marine_unit.tag, closest_mineral_xy
          )
  
      return RAW_FUNCTIONS.no_op()
  
imports: import numpy
  from pysc2.agents import base_agent
  from pysc2.lib import actions
  from pysc2.lib import features
label_desc: Use image node_id 3 for calling the CollectMineralShardsRaw obj's underlying member method code with example usage: obj.step(obs) and returns: RAW_FUNCTIONS, RAW_FUNCTIONS, RAW_FUNCTIONS