class_docstr: Controller.`
  Keep Track of each ship and shipyard
docstr: Take action for ships
  Args:
      board (envs.halite.helpers.Board): the environment
      method (str) : sampling action or greedy action, either sample or predict
  Return:
      action (dict) : a dictionary recording the action for each ship
docstr_tok: ["Take","action","for","ships","Args",":","board","(","envs.halite.helpers.Board",")",":","the","environment","method","(","str",")",":","sampling","action","or","greedy","action",",","either","sample","or","predict","Return",":","action","(","dict",")",":","a","dictionary","recording","the","action","for","each","ship"]
code: def take_shipyard_action(self, board):
      """Take action for ships
      Args:
          board (envs.halite.helpers.Board): the environment
          method (str) : sampling action or greedy action, either sample or predict
      Return:
          action (dict) : a dictionary recording the action for each ship
      """
  
      me = board.current_player
  
      tmp_halite = me.halite
  
      # spwaning ships until the number reaches the threshold
      if len(me.ships) < config["num_ships"]:
          tmp = config["num_ships"] - len(me.ships)
  
          for shipyard in me.shipyards:
              # if there is an opponent shipo nearby, the shipyard can spawn a ship to protect itself
              if check_nearby_ship(board, shipyard, enemy=True):
                  shipyard_policies[1](board, shipyard)
  
              else:
                  # if the player has extra halite, the shipyard can spawn more ships
                  if (
                      tmp_halite > 50
                      and shipyard.cell.ship_id is None
                      and not check_nearby_ship(
                          board, shipyard, enemy=False
                      )
                  ):
                      shipyard_policies[1](board, shipyard)
  
                      tmp -= 1
  
                      tmp_halite -= 50
  
              if tmp == 0:
                  break
  
      return me.next_actions
  
imports: import numpy
  from config import config
  from zerosum_env.envs.halite.helpers import *
  from .agent import Agent
  from .model import Model
  from .algorithm import PPO
  from .obs_parser import get_ship_feature
  from .replay_memory import ReplayMemory
  from .utils import is_alive, check_nearby_ship, nearest_shipyard_position, mahattan_distance
  from .policy import do_nothing_policy, move_up_policy, move_down_policy, move_left_policy, move_right_policy, spawn_policy, return_to_base_policy, mine_policy, convert_policy
label_desc: Use image node_id 7 for calling the Controller obj's underlying member method code with example usage: obj.take_shipyard_action(board) and returns: me