Пример #1
0
def main(args=None):
    for aa, kk in product(asw, ksw):
        print(aa, kk)
        rates['addition'] = aa
        rates['coagulation'] = aa
        rates['subtraction'] = 10.0**-3
        rates['fragmentation'] = 10.0**-3
        ext = "_aa_{}_bb_{}_kk_{}.strup".format(aa, 10**-3, kk)
        # ext2="_aa_{}_kk_{}.up".format(aa,kk)
        fn = runs_name + ext
        # fn2=runs_name+ext2
        rates['nucleation'] = kk
        params['rates'] = rates
        params['simulation']['runs'] = runs_num
        # params['simulation'][]
        os.makedirs(runs_dir + fn + "/", exist_ok=True)
        os.makedirs(runs_dir + fn + "/averaged/", exist_ok=True)
        with open(utils_dir + 'input.data', 'wb') as f:
            pll.dump(params, f)
        with open(runs_dir + fn + "/input.data", 'wb') as f:
            pll.dump(params, f)
        for i in range(1, runs_num + 1):
            ## IF EVERYTHING BREAKS
            # sim.simulation(runs_dir + fn + "/" + fn + "_" + str(i) + ".json")
            if i < 9:
                sim.simulation(runs_dir + fn + "/" + fn + "_0" + str(i) +
                               ".json")
            else:
                sim.simulation(runs_dir + fn + "/" + fn + "_" + str(i) +
                               ".json")
def move_utility(board, block, start_regionid, end_regionid, is_stay, turn):
    """
	returns between 0 and 1
	probability that it will choose again
	"""
    start_region = search.region_id_to_object(board, start_regionid)
    end_region = search.region_id_to_object(board, end_regionid)

    move_utility = 0
    if regroup.noble_home_to_object(board, start_regionid):
        if is_stay:
            move_utility += .4

    simulation_dict = simulations.simulation([block],
                                             end_region.blocks_present, list(),
                                             list())
    move_utility += retreat.retreat(board, end_regionid, [], simulation_dict,
                                    True, turn)['Staying value'] / 150

    if move_utility >= 1:
        move_utility = 0.8
    elif move_utility == 0:
        move_utility = 0.2

    return move_utility
def main():
    blocks1 = initialize_blocks.initialize_blocks()

    print(
        simulations.simulation([
            blocks.Block(
                attack_number=2, attack_letter='A', initial_attack_strength=4)
        ], [
            blocks.Block(
                attack_number=2, attack_letter='A', initial_attack_strength=4)
        ], 1000))
Пример #4
0
 def __init__(self, param_dict):
     self.age = param_dict['age']
     self.retirement_age = param_dict['retirement_age']
     self.terminal_age = param_dict['terminal_age']
     self.non_taxable_balance = param_dict['non_taxable_balance']
     self.taxable_balance = param_dict['taxable_balance']
     self.effective_tax_rate = param_dict['eff_tax_rate']
     self.returns_tax_rate = param_dict['returns_tax_rate']
     self.non_taxable_contribution = param_dict['non_taxable_contribution']
     self.taxable_contribution = param_dict['taxable_contribution']
     self.monthly_retirement_expenses = param_dict['monthly_retirement_expenses']
     self.years = self.terminal_age - self.age + 1
     
     
     self.now = datetime.datetime.now().year
     self.retirement_age = param_dict['retirement_age']
     self.expected_rate_of_return = param_dict['expected_rate_of_return']
     self.asset_volatility = param_dict['asset_volatility']
     self.inflation_rate = param_dict['inflation_rate']
     #self.simdata = simData(self.expected_rate_of_return, self.asset_volatility, self.years)
     #self.plan_dict = self.run_all_sims()
     self.sim = simulation(self.years, self.expected_rate_of_return, self.asset_volatility)
     self.path_dict = self.run_calc()
     self.end_balance = self.get_final_balance()
Пример #5
0
    rates['fragmentation'] = rates['subtraction']
    #rates['fragmentation']=10**-5
    app1 = "aa_{}".format(aa)
    app2 = "kk_{}".format(kk)
    app3 = "bb_{}".format(bb)
    folder = app1 + "/" + app2 + "/" + app3 + "/"
    fn_ext = "_" + app1 + "_" + app2 + "_" + app3 + ".strup"
    #ext2="_aa_{}_kk_{}.up".format(aa,kk)
    fn = folder + runs_name + "_" + fn_ext
    #fn2=runs_name+ext2
    rates['nucleation'] = kk
    params['rates'] = rates
    params['simulation']['runs'] = runs_num
    # params['simulation'][]
    os.makedirs(runs_dir + fn + "/", exist_ok=True)
    os.makedirs(runs_dir + fn + "/averaged/", exist_ok=True)
    with open(utils_dir + 'input.data', 'wb') as f:
        pll.dump(params, f)
    with open(runs_dir + fn + "/input.data", 'wb') as f:
        pll.dump(params, f)
    for i in range(1, runs_num + 1):
        sim.simulation(runs_dir + fn + "/" + fn + "_" + str(i) + ".json")
    os.makedirs(runs_dir + folder, exist_ok=True)
    os.makedirs(runs_dir + folder + "binned/", exist_ok=True)
    with open(utils_dir + 'input.data', 'wb') as f:
        pll.dump(params, f)
    with open(runs_dir + folder + "input.data", 'wb') as f:
        pll.dump(params, f)
    for i in range(1, runs_num + 1):
        sim.simulation(runs_dir + fn + "_" + str(i) + ".json")
Пример #6
0
def good_move(board, num_moves, role, turn, truce, blocks_moved):
    """
    board is a copy of the board
    going to make a move with copies of the board 
    goes and makes the move
    role is scotland or england
    turn is 1 2 3 4 or 5
    finds some utility and throws into random number generator to see if move chosen or not





    READ ME READ ME READ ME READ ME READ ME READ ME
    MAKES A COPY OF THE BOARD DOES THE MOVE EVALUATES THE MOVE IF BAD MOVE AGAIN AND CONTINUE LOOPING
    UNTIL FINDS GOOD MOVE AND THEN IT EXECUTES IT ON THE ACTUAL BOARD
    """

    board_copy = copy.deepcopy(board)

    utility = 0

    #count how man value of location of homes owned before:

    value_loc_before = 0
    for region in board_copy.regions:

        value_loc_before += retreat.value_of_location(board_copy,
                                                      region.regionID, role)

    computer_block = None

    #does movement

    while computer_block in blocks_moved or computer_block == None:
        computer_path, computer_block = other_movement.movement_execution(
            board_copy, 'comp', role, num_moves, truce=truce)

    #debugging why things aren't in combat dictionary
    #for region in board.regions:
    #if region.is_contested():
    #for block in region.blocks_present:
    #if block not in

    #checks utilitiy of the battles using the retreat elliot's thing
    noble_home_after = 0
    for i, region in enumerate(board_copy.regions):
        if region.is_contested():
            board_copy.regions[i] = clean_up_dict(region)
            #board_copy.regions[contested_regions[i].regionID] = contested_regions[i]
    board_copy = clean_up_board(board_copy)
    for region in board_copy.regions:
        if region.is_contested():
            '''
            
            print("***ATTACKING***")
            print(region.combat_dict['Attacking'])
            print("******")
            print("***DEFENDING***")
            print(region.combat_dict['Defending'])
            print("******")
            print('attack reinforcements')
            print(region.combat_dict['Attacking Reinforcements'])
            print('defense reinforcements')
            print(region.combat_dict['Defending Reinforcements'])
            '''

            combat_dict = copy.deepcopy(region.combat_dict)
            #print('IN COMPUTER:',combat_dict)
            #print('REGION IS: ', region)
            #print('ENTERERS:', region.enterers)
            #print(region.is_contested())

            set_up_combat_dict(board_copy, region)
            #print('AFTER:',board_copy.regions[region.regionID].combat_dict)
            simulation_dict = simulations.simulation(region.combat_dict['Attacking'], region.combat_dict['Defending'], 1000, \
                region.combat_dict['Attacking Reinforcements'], region.combat_dict['Defending Reinforcements'])
            '''
            print("***ATTACKING***")
            print(region.combat_dict['Attacking'])
            print("******")
            print("***DEFENDING***")
            print(region.combat_dict['Defending'])
            print("******")

            #for key in region.combat_dict:
                #print(region.combat_dict[key])
            '''

            if len(combat_dict['Attacking']) > 0:
                if role == combat_dict['Attacking'][0].allegiance:
                    is_attacking = True
                else:
                    is_attacking = False
                utility += retreat.retreat(board_copy, region.regionID, [],
                                           simulation_dict, is_attacking, turn,
                                           combat_dict)['Staying value '] * 4

    #account for difference in locations owned values
    value_loc_after = 0
    for region in board_copy.regions:

        value_loc_after += retreat.value_of_location(board_copy,
                                                     region.regionID, role)

    utility += (value_loc_after - value_loc_before) * 2

    #throw in the random number generator with some base bad_move_utility
    #'move' is a substitute for whatever the move will be stored in later
    bad_move_utility = 3.5

    if utility <= 0:
        utility = .01

    utility_dict = {'move': utility, 'not move': bad_move_utility}

    if weighted_prob.weighted_prob(utility_dict) == 'move':
        #if utility > bad_move_utility:
        #total_string = ''
        #pause
        input_toggle.toggle_input('movement')
        print(computer_block.allegiance, 'ready to make a move')

        #input()
        if computer_path[0] != computer_path[
                -1] and computer_block in board.regions[
                    computer_path[0]].blocks_present:
            board.move_block(computer_block,
                             computer_path[0],
                             end=computer_path[-1],
                             position='comp',
                             is_truce=truce,
                             path=computer_path)
        else:
            print('Computer passes a movement point')
        other_movement.reset_total_string()
        print(computer_block.allegiance, 'done with move\n')
        #input_toggle.toggle_input('movement')
        #input()
        return board
    else:

        return good_move(board, num_moves, role, turn, truce, blocks_moved)
def should_retreat(board, attacking = None, defending = None, attacking_reinforcement = list(), defending_reinforcement = list(), is_attacking = None,\
 combat_letter = 'A', combat_round = 0, turn = 'defender', retreat_constant = 0.3, attacking_block = None):
    '''
	This function takes in all the group that are involved in a battle and a boolean about whether the computer is attacking or not. 
	The should_retreat function will return either False, meaning the computer should not retreat, or a location in which the computer should
	retreat its blocks to.
	'''

    attacking_copy = copy.deepcopy(attacking)
    defending_copy = copy.deepcopy(defending)
    attacking_rein_copy = copy.deepcopy(attacking_reinforcement)
    defending_rein_copy = copy.deepcopy(defending_reinforcement)

    simulation_dict = simulations.simulation(attacking_copy, defending_copy,
                                             1000, attacking_rein_copy,
                                             defending_rein_copy,
                                             combat_letter, combat_round, turn)
    win_percentage = 0
    #Calculate the win percentage based on if you are attacking or defending in the simulation

    if is_attacking:
        win_percentage = simulation_dict['attacker wins']
    else:
        win_percentage = simulation_dict['defender wins'] + simulation_dict[
            'attacker retreats']

    #Insert code to check to see if it should retreat

    possible_locations = []

    if is_attacking:

        possible_locations = list(
            retreat_locations(board, [attacking_block], [], is_attacking))
    else:

        possible_locations = list(
            retreat_locations(board, [], [attacking_block], is_attacking))

    if len(possible_locations) == 0:
        return False

    if len(attacking) > 0 and attacking[0].current_strength > 0:
        found_location = find_location(board, attacking[0])
        if found_location:
            current_location = found_location.regionID
        else:
            current_location = None
    elif len(attacking_reinforcement) > 0:
        current_location = find_location(board,
                                         attacking_reinforcement[0]).regionID
    else:
        current_location = find_location(board, defending[0]).regionID
    possible_locations_id = list()
    for location in possible_locations:
        possible_locations_id.append(location.regionID)
    #print('CURRENT LOCATION: ', current_location)
    choice_dictionary = retreat.retreat(board, current_location,
                                        possible_locations_id, simulation_dict,
                                        is_attacking, board.turn)
    choice = weighted_prob.weighted_prob(choice_dictionary)

    if choice == 'Staying value ':
        return False
    else:
        choice = board.regions[int(choice)]

        return choice
Пример #8
0
def good_move(board, num_moves, role, turn, truce, original_board):

	"""
	board is a copy of the board
	going to make a move with copies of the board 
	goes and makes the move
	role is scotland or england
	turn is 1 2 3 4 or 5
	finds some utility and throws into random number generator to see if move chosen or not





	READ ME READ ME READ ME READ ME READ ME READ ME
	MAKES A COPY OF THE BOARD DOES THE MOVE EVALUATES THE MOVE IF BAD MOVE AGAIN AND CONTINUE LOOPING
	UNTIL FINDS GOOD MOVE AND THEN IT EXECUTES IT ON THE ACTUAL BOARD
	"""

	global total_string

	utility = 0


	#count how man value of location of homes owned before:

	value_loc_before = 0
	for region in board.regions:
		
		value_loc_before += retreat.value_of_location(board, region.regionID, role)


	
	#does movement

	board_copy = copy.deepcopy(board)
	movement_execution(board_copy, 'comp', role, num_moves, truce=truce)


	

	


	#checks utilitiy of the battles using the retreat elliot's thing
	noble_home_after = 0
	for region in board_copy.regions:
		if region.is_contested():

			set_up_combat_dict(board_copy,region)
			
			simulation_dict = simulations.simulation(region.combat_dict['Attacking'], region.combat_dict['Defending'], 1000, \
				region.combat_dict['Attacking Reinforcements'], region.combat_dict['Defending Reinforcements'])
			for key in region.combat_dict:
				print(region.combat_dict[key])
			if role == region.combat_dict['Attacking'][0].allegiance:
				is_attacking = True
			else:
				is_attacking = False
			utility += retreat.retreat(board_copy, region.regionID, [], simulation_dict, is_attacking, turn)['Staying value '] * 4
		


	#account for difference in locations owned values
	value_loc_after = 0
	for region in board_copy.regions:
		
		value_loc_after += retreat.value_of_location(board_copy, region.regionID, role)

	utility += (value_loc_after - value_loc_before) * 2


	#throw in the random number generator with some base bad_move_utility
	#'move' is a substitute for whatever the move will be stored in later
	bad_move_utility = .1 * num_moves

	if utility <= 0:
		utility = .01

	

	utility_dict = {'move': utility, 'not move': bad_move_utility}

	if weighted_prob.weighted_prob(utility_dict) == 'move':
		total_string = ''
		#pause
		print('computer ready to make a move')
		input()
		movement_execution(board, 'comp', role, num_moves, truce=truce)
		original_board = board_copy
		print(total_string)
		total_string = ''
		print('computer done with move')
		input()
		
	else:
		total_string = ''
		good_move(original_board, num_moves, role, turn, truce, original_board)
Пример #9
0
def main():

    finished = False
    first_time = True
    possible_answers = {'y', 'n'}
    attack_or_defense = ['attack', 'defense']
    index = 0
    attack = list()
    defense = list()
    '''
	while not finished:
		
		if not first_time:
			bad_input = True
			while bad_input:
				input1 = input('do you want to add more blocks (y) or (n): ')
				if input1 not in possible_answers:
					print('Type y or n')
				else:
					bad_input = False
					if input1 == 'n':
						finished = True

		if not finished:
			bad = True
			while bad:
				print('What strength block do you want to add to', attack_or_defense[index])
				strength = input('>')
				if strength.isdigit():
					bad = False
			bad = True
			while bad:
				print('What letter block you want to add to', attack_or_defense[index])
				letter = input('>')
				if letter.isalpha() and len(letter) == 1:
					bad = False
			bad = True
			while bad:
				print('What attack number do you want to add to', attack_or_defense[index])
				attack_number1 = input('>')
				if attack_number1.isdigit():
					bad = False
			new_block = blocks.Block(initial_attack_strength = int(strength), attack_letter = letter, attack_number = int(attack_number1))
			if index == 1:
				defense.append(new_block)
			else:
				attack.append(new_block)
		index = 1 - index

		if not first_time and not finished:
			bad_input = True
			while bad_input:
				input1 = input('do you want to add more blocks (y) or (n): ')
				bad_input = False
				if input1 not in possible_answers:
					print('Type y or n')
				else:
					if input1 == 'n':
						finished = True
		if not finished:
			bad = True
			while bad:
				print('What strength block do you want to add to', attack_or_defense[index])
				strength = input('>')
				if strength.isdigit():
					bad = False
			bad = True
			while bad:
				print('What letter block you want to add to', attack_or_defense[index])
				letter = input('>')
				if letter.isalpha() and len(letter) == 1:
					bad = False
			bad = True
			while bad:
				print('What attack number do you want to add to', attack_or_defense[index])
				attack_number1 = input('>')
				if attack_number1.isdigit():
					bad = False
			new_block = blocks.Block(initial_attack_strength = int(strength), attack_letter = letter, attack_number = int(attack_number1))
			

			if index == 1:
				defense.append(new_block)
			else:
				attack.append(new_block)
		index = 1 - index
		first_time = False
	'''

    attack = [
        blocks.Block(attack_number=3,
                     attack_letter='A',
                     initial_attack_strength=4)
    ]
    defense = [
        blocks.Block(attack_number=4,
                     attack_letter='B',
                     initial_attack_strength=4)
    ]
    bad_input = True
    while bad_input:
        try:
            num_times = int(input('How many times do you want to run this: '))
            bad_input = False
        except ValueError:
            print('type number')

    print('SIMULATION RUNNING')
    print(simulations.simulation(attack, defense, num_times))
Пример #10
0
def main():
    sim = simulation(sim_data_1)

    boids_xy = np.array([np.complex(x, y) for (x, y) in sim['boids_xy']])
    boids_dxy = np.array([np.complex(0, 0) for _ in sim['boids_xy']])
    boids_towards = boids_xy[..., np.newaxis] - boids_xy
    MA = np.tile(boids_xy[:, np.newaxis], boids_xy.size)
    boids_dist = abs(MA - MA.T)
    obstacles_xy = np.array([complex(x, y) for (x, y) in sim['obstacles_xy']])
    obstacles_towards = np.array(boids_xy[..., np.newaxis] - obstacles_xy)
    obstacles_dist = abs(obstacles_towards)
    checkpoint_xy = np.array([
        complex(*b.checkpoint) for b in itertools.chain(
            sim['boids'][Sheep]['objects'],
            sim['boids'][Dog]['objects'],
            sim['boids'][Wolf]['objects'],
        )
    ])
    checkpoint_towards = boids_xy - checkpoint_xy
    wall_dist = np.array(
        [[xy.real, xy.imag, consts.WIDTH - xy.real, consts.HEIGHT - xy.imag]
         for xy in boids_xy])
    wall_towards = np.array(
        [[complex(-1, 0),
          complex(0, -1),
          complex(1, 0),
          complex(0, 1)] for _ in boids_xy])

    global state
    state = {
        'objects': [
            b for b in itertools.chain(
                sim['boids'][Sheep]['objects'],
                sim['boids'][Dog]['objects'],
                sim['boids'][Wolf]['objects'],
            )
        ],
        'boids_xy':
        boids_xy,
        'boids_dxy':
        boids_dxy,
        'boids_towards':
        boids_towards,
        'boids_dist':
        boids_dist,
        'obstacles':
        sim['obstacles'],
        'obstacles_xy':
        obstacles_xy,
        'obstacles_towards':
        obstacles_towards,
        'obstacles_dist':
        obstacles_dist,
        'checkpoint_xy':
        checkpoint_xy,
        'checkpoint_towards':
        checkpoint_towards,
        'wall_dist':
        wall_dist,
        'wall_towards':
        wall_towards,
        'max_dist':
        defaultdict(
            lambda: np.array([[0] * len(boids_xy)]), **{
                consts.WALLS:
                np.array([consts.WALL_DISTANCE for _ in range(len(boids_xy))]),
                consts.OBSTACLES:
                np.array(
                    [consts.OBSTACLE_DISTANCE for _ in range(len(boids_xy))]),
                consts.SEPARATION:
                np.array([[
                    x for x in itertools.chain(
                        [Sheep(100, []).SEPARATION_DISTANCES.get(Sheep, 0)] *
                        len(sim['boids'][Sheep]['objects']),
                        [Sheep(100, []).SEPARATION_DISTANCES.get(Dog, 0)] *
                        len(sim['boids'][Dog]['objects']),
                        [Sheep(100, []).SEPARATION_DISTANCES.get(Wolf, 0)] *
                        len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Sheep]['objects']) + [[
                    x for x in itertools.chain(
                        [Dog(100, []).SEPARATION_DISTANCES.get(Sheep, 0)] *
                        len(sim['boids'][Sheep]['objects']),
                        [Dog(100, []).SEPARATION_DISTANCES.get(Dog, 0)] *
                        len(sim['boids'][Dog]['objects']),
                        [Dog(100, []).SEPARATION_DISTANCES.get(Wolf, 0)] *
                        len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Dog]['objects']) + [[
                    x for x in itertools.chain(
                        [Wolf(100, []).SEPARATION_DISTANCES.get(Sheep, 0)] *
                        len(sim['boids'][Sheep]['objects']),
                        [Wolf(100, []).SEPARATION_DISTANCES.get(Dog, 0)] *
                        len(sim['boids'][Dog]['objects']),
                        [Wolf(100, []).SEPARATION_DISTANCES.get(Wolf, 0)] *
                        len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Wolf]['objects'])),
                consts.ALIGNMENT:
                np.array([[
                    x for x in itertools.chain(
                        [64] * len(sim['boids'][Sheep]['objects']),
                        [0] * len(sim['boids'][Dog]['objects']),
                        [0] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Sheep]['objects']) + [[
                    x for x in itertools.chain(
                        [0] * len(sim['boids'][Sheep]['objects']),
                        [0] * len(sim['boids'][Dog]['objects']),
                        [0] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Dog]['objects']) + [[
                    x for x in itertools.chain(
                        [0] * len(sim['boids'][Sheep]['objects']),
                        [0] * len(sim['boids'][Dog]['objects']),
                        [0] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Wolf]['objects'])),
                consts.COHESION:
                np.array([[
                    x for x in itertools.chain(
                        [64] * len(sim['boids'][Sheep]['objects']),
                        [64] * len(sim['boids'][Dog]['objects']),
                        [0] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Sheep]['objects']) + [[
                    x for x in itertools.chain(
                        [64] * len(sim['boids'][Sheep]['objects']),
                        [64] * len(sim['boids'][Dog]['objects']),
                        [0] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Dog]['objects']) + [[
                    x for x in itertools.chain(
                        [0] * len(sim['boids'][Sheep]['objects']),
                        [0] * len(sim['boids'][Dog]['objects']),
                        [0] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Wolf]['objects'])),
                consts.HUNT:
                np.array([[
                    x for x in itertools.chain(
                        [0] * len(sim['boids'][Sheep]['objects']),
                        [0] * len(sim['boids'][Dog]['objects']),
                        [0] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Sheep]['objects']) + [[
                    x for x in itertools.chain(
                        [0] * len(sim['boids'][Sheep]['objects']),
                        [0] * len(sim['boids'][Dog]['objects']),
                        [160] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Dog]['objects']) + [[
                    x for x in itertools.chain(
                        [160] * len(sim['boids'][Sheep]['objects']),
                        [0] * len(sim['boids'][Dog]['objects']),
                        [0] * len(sim['boids'][Wolf]['objects']),
                    )
                ]] * len(sim['boids'][Wolf]['objects'])),
            }),
        'weights': {
            consts.ALIGNMENT:
            np.array([[
                x for x in itertools.chain(
                    [sim['boids'][Sheep]['rules'][Sheep][consts.ALIGNMENT]] *
                    len(sim['boids'][Sheep]['objects']),
                    [0] * len(sim['boids'][Dog]['objects']),
                    [0] * len(sim['boids'][Wolf]['objects']),
                )
            ]] * len(sim['boids'][Sheep]['objects']) +
                     [[0] * len(sim['boids_xy'])] *
                     (len(sim['boids'][Dog]['objects']) +
                      len(sim['boids'][Wolf]['objects']))),
            consts.COHESION:
            np.array([[
                x for x in itertools.chain(
                    [sim['boids'][Sheep]['rules'][Sheep][consts.COHESION]] *
                    len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Sheep]['rules'][Dog][consts.COHESION]] *
                    len(sim['boids'][Dog]['objects']),
                    [0] * len(sim['boids'][Wolf]['objects']),
                )
            ]] * len(sim['boids'][Sheep]['objects']) + [[
                x for x in itertools.chain(
                    [sim['boids'][Dog]['rules'][Sheep][consts.COHESION]] *
                    len(sim['boids'][Sheep]['objects']),
                    [0] * len(sim['boids'][Dog]['objects']),
                    [0] * len(sim['boids'][Wolf]['objects']),
                )
            ]] * len(sim['boids'][Dog]['objects']) +
                     [[0] * len(sim['boids_xy'])] *
                     len(sim['boids'][Wolf]['objects'])),
            consts.SEPARATION:
            np.array([[
                x for x in itertools.chain(
                    [sim['boids'][Sheep]['rules'][Sheep][consts.SEPARATION]] *
                    len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Sheep]['rules'][Dog][consts.SEPARATION]] *
                    len(sim['boids'][Dog]['objects']),
                    [sim['boids'][Sheep]['rules'][Wolf][consts.SEPARATION]] *
                    len(sim['boids'][Wolf]['objects']),
                )
            ]] * len(sim['boids'][Sheep]['objects']) + [[
                x for x in itertools.chain(
                    [sim['boids'][Dog]['rules'][Sheep][consts.SEPARATION]] *
                    len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Dog]['rules'][Dog][consts.SEPARATION]] *
                    len(sim['boids'][Dog]['objects']),
                    [0] * len(sim['boids'][Wolf]['objects']),
                )
            ]] * len(sim['boids'][Dog]['objects']) + [[
                x for x in itertools.chain(
                    [0] * len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Wolf]['rules'][Dog][consts.SEPARATION]] *
                    len(sim['boids'][Dog]['objects']),
                    [sim['boids'][Wolf]['rules'][Wolf][consts.SEPARATION]] *
                    len(sim['boids'][Wolf]['objects']),
                )
            ]] * len(sim['boids'][Wolf]['objects'])),
            consts.WALLS:
            np.identity(boids_xy.shape[0]) * np.array([
                x for x in itertools.chain(
                    [sim['boids'][Sheep]['rules'][Sheep][consts.WALLS]] *
                    len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Dog]['rules'][Dog][consts.WALLS]] *
                    len(sim['boids'][Dog]['objects']),
                    [sim['boids'][Wolf]['rules'][Wolf][consts.WALLS]] *
                    len(sim['boids'][Wolf]['objects']),
                )
            ]),
            consts.OBSTACLES:
            np.identity(boids_xy.shape[0]) * np.array([
                x for x in itertools.chain(
                    [sim['boids'][Sheep]['rules'][Sheep][consts.OBSTACLES]] *
                    len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Dog]['rules'][Dog][consts.OBSTACLES]] *
                    len(sim['boids'][Dog]['objects']),
                    [sim['boids'][Wolf]['rules'][Wolf][consts.OBSTACLES]] *
                    len(sim['boids'][Wolf]['objects']),
                )
            ]),
            consts.CHECKPOINT:
            np.identity(boids_xy.shape[0]) * np.array([
                x for x in itertools.chain(
                    [sim['boids'][Sheep]['rules'][Sheep][consts.CHECKPOINT]] *
                    len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Dog]['rules'][Dog][consts.CHECKPOINT]] *
                    len(sim['boids'][Dog]['objects']),
                    [0] * len(sim['boids'][Wolf]['objects']),
                )
            ]),
            consts.HUNT:
            np.identity(boids_xy.shape[0]) * np.array([
                x for x in itertools.chain(
                    [0] * len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Dog]['rules'][Wolf][consts.HUNT]] *
                    len(sim['boids'][Dog]['objects']),
                    [sim['boids'][Wolf]['rules'][Sheep][consts.HUNT]] *
                    len(sim['boids'][Wolf]['objects']),
                )
            ]),
            consts.MAINTENANCE:
            np.identity(boids_xy.shape[0]) * np.array([
                x for x in itertools.chain(
                    [sim['boids'][Sheep]['rules'][Sheep][consts.MAINTENANCE]] *
                    len(sim['boids'][Sheep]['objects']),
                    [sim['boids'][Dog]['rules'][Dog][consts.MAINTENANCE]] *
                    len(sim['boids'][Dog]['objects']),
                    [sim['boids'][Wolf]['rules'][Wolf][consts.MAINTENANCE]] *
                    len(sim['boids'][Wolf]['objects']),
                )
            ]),
            consts.KILL:
            np.zeros(boids_xy.shape[0]),
        },
        'speed':
        np.array([
            x for x in itertools.chain(
                [Sheep.MAX_SPEED] * len(sim['boids'][Sheep]['objects']),
                [Dog.MAX_SPEED] * len(sim['boids'][Dog]['objects']),
                [Wolf.MAX_SPEED] * len(sim['boids'][Wolf]['objects']),
            )
        ])
    }
    state['kill_dist'] = np.array([[a.kill_dist(b) for b in state['objects']]
                                   for a in state['objects']])

    # Open up our window
    arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
    arcade.set_background_color(arcade.color.GREEN)

    # Tell the computer to call the draw command at the specified interval.
    arcade.schedule(draw, 1 / 60)

    # Run the program
    arcade.run()