def initialize_particles(**kwargs): """ Initialize N particles in a circular distribution around a center point, where N=number. Keyword arguments include a radius from the center, an identifier pattern and other keyword arguments that would instantiate a particle. """ # Initialize variables needed to do initialization klass = kwargs.get('type', Particle) number = kwargs.get('number', world_parameters.get('team_size')) center = kwargs.get('center', (750,750)) radius = kwargs.get('radius', 100) team = kwargs.get('team', 'ally') maxvel = kwargs.get('maximum_velocity', world_parameters.get('maximum_velocity')) home = kwargs.get('home', None) params = kwargs.get('params', world_parameters) # Generate coordinates and particles coords = zip(*circular_distribute(num=number, center=center, r=radius)) for idx, coord in enumerate(coords): position = Vector.arrp(*coord) velocity = Vector.rand(maxvel) if maxvel > 0 else Vector.zero() name = team + "%02i" % (idx+1) yield klass(position, velocity, name, team=team, home=home, params=params)
def create_ally_home(): """ Constructs the ALLY_HOME on a per-simulation basis. """ return ResourceParticle(Vector.arrp(750, 750), identifier="ally_home", stash_size=0)
def initialize_particles(**kwargs): """ Initialize N particles in a circular distribution around a center point, where N=number. Keyword arguments include a radius from the center, an identifier pattern and other keyword arguments that would instantiate a particle. """ # Initialize variables needed to do initialization klass = kwargs.get('type', Particle) number = kwargs.get('number', world_parameters.get('team_size')) center = kwargs.get('center', (750, 750)) radius = kwargs.get('radius', 100) team = kwargs.get('team', 'ally') maxvel = kwargs.get('maximum_velocity', world_parameters.get('maximum_velocity')) home = kwargs.get('home', None) params = kwargs.get('params', world_parameters) # Generate coordinates and particles coords = zip(*circular_distribute(num=number, center=center, r=radius)) for idx, coord in enumerate(coords): position = Vector.arrp(*coord) velocity = Vector.rand(maxvel) if maxvel > 0 else Vector.zero() name = team + "%02i" % (idx + 1) yield klass(position, velocity, name, team=team, home=home, params=params)
def create_enemy_home(): """ Constructs the ENEMY_HOME on a per-simulation basis. """ return ResourceParticle(Vector.arrp(2250, 2250), identifier="enemy_home", stash_size=0)
def initialize_resources(**kwargs): """ Initialize N particles in a linear distribution along a line with a slope and an intercept. N=number. Keyword arguments include the slope, the intercept, and the length of the line to distribute along. """ # Initialize variables needed to do initialization klass = kwargs.get('type', ResourceParticle) number = kwargs.get('number', world_parameters.get('deposits')) + 2 # Add two to skip corners length = kwargs.get('length', 3000) slope = kwargs.get('slope', -1) yint = kwargs.get('yint', 3000) coords = zip(*linear_distribute(number, length, slope, yint)) for idx, coord in enumerate(coords): if coord[0] in (0.0, length): continue # Skip corners yield klass(Vector.arrp(*coord), identifier="mineral%2i" % (idx+1))
def initialize_resources(**kwargs): """ Initialize N particles in a linear distribution along a line with a slope and an intercept. N=number. Keyword arguments include the slope, the intercept, and the length of the line to distribute along. """ # Initialize variables needed to do initialization klass = kwargs.get('type', ResourceParticle) number = kwargs.get( 'number', world_parameters.get('deposits')) + 2 # Add two to skip corners length = kwargs.get('length', 3000) slope = kwargs.get('slope', -1) yint = kwargs.get('yint', 3000) coords = zip(*linear_distribute(number, length, slope, yint)) for idx, coord in enumerate(coords): if coord[0] in (0.0, length): continue # Skip corners yield klass(Vector.arrp(*coord), identifier="mineral%2i" % (idx + 1))
def create_enemy_home(): """ Constructs the ENEMY_HOME on a per-simulation basis. """ return ResourceParticle(Vector.arrp(2250,2250), identifier="enemy_home", stash_size=0)
def create_ally_home(): """ Constructs the ALLY_HOME on a per-simulation basis. """ return ResourceParticle(Vector.arrp(750,750), identifier="ally_home", stash_size=0)