Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Simulates the KOL Crimbo 2014 factory. Poorly...
- //This source code is in the public domain.
- #include <iostream>
- #include <vector>
- #include <map>
- #include <thread>
- #include <random>
- #include <chrono> //! crono! wake up, crono!
- #include <queue>
- const bool setting_simulate_schematics_as_well = true;
- const int setting_simulate_floor_min = 1;
- const int setting_simulate_floor_max = 3;
- const bool setting_use_exact_simulation = true; //Calculate the numbers exactly, rather than fiddling with monte carlo. Will not output rooms reached information. Thanks for the idea, Satsuoni!
- const bool setting_preoptimise_room_options = true; //Speedup.
- typedef std::mt19937 std_random_generator_class;
- enum class robot_capability
- {
- blam,
- light,
- pow,
- roll,
- run,
- zap,
- hover,
- lube,
- pinch,
- decode,
- freeze,
- burn
- };
- //Using a map here is slightly inefficient, but we pre-prune capabilities before simulation, so it won't affect performance.
- class RobotCapabilities
- {
- public:
- void addCapability(const robot_capability & capability);
- void addCapabilities(const RobotCapabilities & capabilities_other);
- bool hasCapability(const robot_capability & capability) const;
- int capabilityAmount(const robot_capability & capability) const;
- bool capabilityWillFulfillOurs(const RobotCapabilities & capabilities_other) const;
- private:
- std::map <robot_capability,int> capabilities_map;
- };
- void RobotCapabilities::addCapability(const robot_capability & capability)
- {
- capabilities_map[capability] += 1;
- }
- void RobotCapabilities::addCapabilities(const RobotCapabilities & capabilities_other)
- {
- for (auto & iterator : capabilities_other.capabilities_map)
- {
- capabilities_map[iterator.first] += iterator.second;
- }
- }
- bool RobotCapabilities::hasCapability(const robot_capability & capability) const
- {
- return capabilityAmount(capability) > 0;
- }
- int RobotCapabilities::capabilityAmount(const robot_capability & capability) const
- {
- if (capabilities_map.count(capability) == 0)
- return 0;
- return capabilities_map.find(capability)->second;
- }
- bool RobotCapabilities::capabilityWillFulfillOurs(const RobotCapabilities & capabilities_other) const
- {
- for (auto & iterator : capabilities_map)
- {
- if (capabilities_other.capabilityAmount(iterator.first) < iterator.second)
- return false;
- }
- return true;
- }
- struct SimulationStateMutable
- {
- SimulationStateMutable() : current_hp(0), room(0) {}
- bool operator<(const SimulationStateMutable & rhs) const;
- bool operator==(const SimulationStateMutable & rhs) const;
- int current_hp;
- int room;
- };
- bool SimulationStateMutable::operator<(const SimulationStateMutable & rhs) const
- {
- if (room < rhs.room)
- return true;
- if (room == rhs.room)
- {
- if (current_hp < rhs.current_hp)
- return true;
- }
- return false;
- }
- bool SimulationStateMutable::operator==(const SimulationStateMutable & rhs) const
- {
- return (current_hp == rhs.current_hp && room == rhs.room);
- }
- struct SimulationStateFixed
- {
- template <typename ... T>
- SimulationStateFixed(const int base_hp_in, const T & ... capabilities); //capabilities must be of type robot_capability
- int base_hp;
- RobotCapabilities capabilities;
- int chosen_floor;
- int chosen_maze_strategy_1; //for floor 2, 1 means up, 2 means down
- bool choose_parts_over_schematics;
- void addToCapabilities(const SimulationStateFixed & other);
- };
- template <typename ... T>
- SimulationStateFixed::SimulationStateFixed(const int base_hp_in, const T & ... capabilities_in) : base_hp(base_hp_in)
- {
- chosen_maze_strategy_1 = 1;
- choose_parts_over_schematics = false;
- const robot_capability capabilities_in_array[] = { capabilities_in... };
- for (robot_capability capability : capabilities_in_array)
- {
- capabilities.addCapability(capability);
- }
- }
- void SimulationStateFixed::addToCapabilities(const SimulationStateFixed & other)
- {
- base_hp += other.base_hp;
- capabilities.addCapabilities(other.capabilities);
- }
- struct RoomOption
- {
- RoomOption() : schematics_given(0), parts_given(0), minimum_hp_damage_dealt(0), maximum_hp_damage_dealt(0) {}
- //template <typename ... T>
- //RoomOption(int schematics_given_in, double parts_given_in, int hp_damage_dealt_in, T ... capabilities); //capabilities must be of type robot_capability
- template <typename ... T>
- RoomOption(int schematics_given_in, double parts_given_in, int minimum_hp_damage_dealt_in, int maximum_hp_damage_dealt_in, T ... capabilities); //capabilities must be of type robot_capability
- RobotCapabilities required_capabilities;
- int schematics_given;
- double parts_given;
- int minimum_hp_damage_dealt;
- int maximum_hp_damage_dealt;
- bool capableOfChoosingChoice(const RobotCapabilities & with_capabilities) const;
- };
- /*template <typename ... T>
- RoomOption::RoomOption(int schematics_given_in, double parts_given_in, int hp_damage_dealt_in, T ... capabilities_in) : schematics_given(schematics_given_in), parts_given(parts_given_in), minimum_hp_damage_dealt(hp_damage_dealt_in), maximum_hp_damage_dealt(hp_damage_dealt_in)
- {
- const robot_capability capabilities_in_array[] = { capabilities_in... };
- for (robot_capability capability : capabilities_in_array)
- {
- required_capabilities.addCapability(capability);
- }
- }*/
- template <typename ... T>
- RoomOption::RoomOption(int schematics_given_in, double parts_given_in, int minimum_hp_damage_dealt_in, int maximum_hp_damage_dealt_in, T ... capabilities_in) : schematics_given(schematics_given_in), parts_given(parts_given_in), minimum_hp_damage_dealt(minimum_hp_damage_dealt_in), maximum_hp_damage_dealt(maximum_hp_damage_dealt_in)
- {
- const robot_capability capabilities_in_array[] = { capabilities_in... };
- for (robot_capability capability : capabilities_in_array)
- {
- required_capabilities.addCapability(capability);
- }
- }
- bool RoomOption::capableOfChoosingChoice(const RobotCapabilities & with_capabilities) const
- {
- return required_capabilities.capabilityWillFulfillOurs(with_capabilities);
- }
- struct Room
- {
- Room();
- Room(std::string name_in, const std::vector <RoomOption> & options_in) : name(name_in), options(options_in) {}
- std::vector <RoomOption> options;
- std::string name;
- };
- struct RoomCollection
- {
- std::vector <Room> potential_rooms;
- };
- struct FactoryLayout
- {
- std::map <int, RoomCollection> first_area_layout; //room number - 2 is the start
- std::map <int, RoomCollection> second_area_layout_up_path;
- std::map <int, RoomCollection> second_area_layout_down_path;
- std::map <int, RoomCollection> third_area_layout_easy_path;
- std::map <int, RoomCollection> third_area_layout_hard_path;
- std::map <int, RoomCollection> third_area_layout_hard_then_easy_path;
- };
- enum class robot_part_location
- {
- left_arm,
- right_arm,
- torso,
- propulsion
- };
- struct RobotPart
- {
- RobotPart(const std::string & name_in, const robot_part_location & location_in, const SimulationStateFixed & capability_modifiers_in) : name(name_in), location(location_in), capability_modifiers(capability_modifiers_in) {}
- std::string name;
- robot_part_location location;
- SimulationStateFixed capability_modifiers;
- };
- void simulateOnce(std_random_generator_class & rng_generator, const std::vector <RoomCollection> & area_layout, const SimulationStateFixed & fixed_state, double * parts_found_out, int * schematics_found_out, int * room_ended_at_out)
- {
- SimulationStateMutable state = SimulationStateMutable();
- state.current_hp = fixed_state.base_hp;
- state.room = 2;
- const bool output_debug = false;
- if (output_debug)
- printf("-\n");
- while (state.current_hp > 0)
- {
- if (state.room >= area_layout.size() || state.room < 0)
- {
- break;
- }
- const RoomCollection & room_collection = area_layout[state.room];
- if (room_collection.potential_rooms.size() == 0)
- {
- printf("INTERNAL ERROR: Room collection too small.\n");
- break;
- }
- //Generate a room:
- //int picked_id = random() % room_collection.potential_rooms.size();
- int picked_id = std::uniform_int_distribution<>(0, (int)room_collection.potential_rooms.size() - 1)(rng_generator);
- const Room & current_room = room_collection.potential_rooms[picked_id];
- const RoomOption * chosen_option = 0;
- int chosen_option_score = 0;
- for (const RoomOption & option : current_room.options)
- {
- if (!option.capableOfChoosingChoice(fixed_state.capabilities))
- continue;
- bool is_better = false;
- int score = 0;
- if (fixed_state.choose_parts_over_schematics)
- {
- score += option.parts_given * 100.0;
- score += option.schematics_given * 10;
- }
- else
- {
- score += option.parts_given * 10.0;
- score += option.schematics_given * 100;
- }
- score -= (option.minimum_hp_damage_dealt + option.maximum_hp_damage_dealt);
- //Is this better?
- if (!chosen_option)
- is_better = true;
- else if (score > chosen_option_score)
- is_better = true;
- if (is_better)
- {
- chosen_option = &option;
- chosen_option_score = score;
- }
- }
- if (output_debug)
- printf("\tOn room %i. HP is %i.\n", state.room, state.current_hp);
- if (!chosen_option)
- {
- printf("INTERNAL ERROR: No option.\n");
- break;
- }
- *parts_found_out += chosen_option->parts_given;
- *schematics_found_out += chosen_option->schematics_given;
- if (chosen_option->maximum_hp_damage_dealt != 0)
- {
- if (output_debug)
- printf("\t\tGenerating random HP damage in range [%i, %i]\n", chosen_option->minimum_hp_damage_dealt, chosen_option->maximum_hp_damage_dealt);
- int damage_done = std::uniform_int_distribution<>(chosen_option->minimum_hp_damage_dealt, chosen_option->maximum_hp_damage_dealt)(rng_generator);
- state.current_hp -= damage_done;
- if (output_debug)
- printf("\t\tTook %i damage.\n", damage_done);
- }
- if (state.current_hp > 0)
- state.room += 1;
- }
- *room_ended_at_out = state.room;
- }
- struct PathSimulationResult
- {
- long double parts_found;
- long double schematics_found;
- };
- PathSimulationResult simulateEntirePath(const std::vector <RoomCollection> & area_layout, const SimulationStateFixed & fixed_state, SimulationStateMutable mutable_state, std::map <SimulationStateMutable, PathSimulationResult> & cached_results)
- {
- PathSimulationResult result = PathSimulationResult();
- if (mutable_state.current_hp <= 0)
- return result;
- //Look us up in the cached results:
- if (cached_results.find(mutable_state) != cached_results.end())
- {
- return cached_results[mutable_state];
- }
- //Go through each option:
- if (mutable_state.room >= area_layout.size() || mutable_state.room < 0)
- {
- return result;
- }
- int options_seen = 0;
- for (const Room & room : area_layout[mutable_state.room].potential_rooms)
- {
- //Pick the choice we want:
- const RoomOption * chosen_option = 0;
- int chosen_option_score = 0;
- for (const RoomOption & option : room.options)
- {
- if (!option.capableOfChoosingChoice(fixed_state.capabilities))
- continue;
- bool is_better = false;
- int score = 0;
- if (fixed_state.choose_parts_over_schematics)
- {
- score += option.parts_given * 100.0;
- score += option.schematics_given * 10;
- }
- else
- {
- score += option.parts_given * 10.0;
- score += option.schematics_given * 100;
- }
- score -= (option.minimum_hp_damage_dealt + option.maximum_hp_damage_dealt);
- //Is this better?
- if (!chosen_option)
- is_better = true;
- else if (score > chosen_option_score)
- is_better = true;
- if (is_better)
- {
- chosen_option = &option;
- chosen_option_score = score;
- }
- }
- if (!chosen_option)
- continue;
- PathSimulationResult room_result = PathSimulationResult();
- for (int i = chosen_option->minimum_hp_damage_dealt; i <= chosen_option->maximum_hp_damage_dealt; i++)
- {
- room_result.parts_found += chosen_option->parts_given;
- room_result.schematics_found += chosen_option->schematics_given;
- SimulationStateMutable altered_state = mutable_state;
- altered_state.room += 1;
- altered_state.current_hp -= i;
- PathSimulationResult result2 = simulateEntirePath(area_layout, fixed_state, altered_state, cached_results);
- room_result.parts_found += result2.parts_found;
- room_result.schematics_found += result2.schematics_found;
- }
- long double divisor = (long double)(chosen_option->maximum_hp_damage_dealt - chosen_option->minimum_hp_damage_dealt + 1);
- if (divisor != 0)
- {
- if (divisor != 1)
- {
- room_result.parts_found /= divisor;
- room_result.schematics_found /= divisor;
- }
- result.parts_found += room_result.parts_found;
- result.schematics_found += room_result.schematics_found;
- options_seen++;
- }
- }
- if (options_seen > 0)
- {
- long double options_seen_double = (long double)options_seen;
- result.parts_found /= options_seen_double;
- result.schematics_found /= options_seen_double;
- }
- if (cached_results.count(mutable_state) == 0)
- {
- cached_results[mutable_state] = result;
- }
- return result;
- }
- void simulateAllAndOutput(const FactoryLayout & factory_layout, const unsigned int simulation_count, const RobotPart & part_left_arm, const RobotPart & part_right_arm, const RobotPart & part_torso, const RobotPart & part_propulsion, const int floor_in, const int maze_strategy_in, const bool pick_parts_over_schematics)
- {
- //Create state for this set of parts:
- SimulationStateFixed fixed_state = SimulationStateFixed(0);
- fixed_state.addToCapabilities(part_left_arm.capability_modifiers);
- fixed_state.addToCapabilities(part_right_arm.capability_modifiers);
- fixed_state.addToCapabilities(part_torso.capability_modifiers);
- fixed_state.addToCapabilities(part_propulsion.capability_modifiers);
- fixed_state.chosen_floor = floor_in;
- fixed_state.chosen_maze_strategy_1 = maze_strategy_in;
- fixed_state.choose_parts_over_schematics = pick_parts_over_schematics;
- if (fixed_state.chosen_floor == 2 && !fixed_state.capabilities.hasCapability(robot_capability::pinch))
- {
- return;
- }
- if (fixed_state.chosen_floor == 3 && !fixed_state.capabilities.hasCapability(robot_capability::decode))
- {
- return;
- }
- std::vector <int> total_rooms_ended_at_frequency;
- //std_random_generator_class rng_generator = std_random_generator_class(std::chrono::high_resolution_clock::now().time_since_epoch().count());
- std_random_generator_class rng_generator = std_random_generator_class(std::random_device()());
- double total_parts_found = 0;
- uint64_t total_schematics_found = 0;
- uint64_t total_rooms_ended_at = 0;
- const std::map <int, RoomCollection> * area_layout_map = &factory_layout.first_area_layout;
- if (fixed_state.chosen_floor == 2)
- {
- if (fixed_state.chosen_maze_strategy_1 == 1)
- area_layout_map = &factory_layout.second_area_layout_up_path;
- else
- area_layout_map = &factory_layout.second_area_layout_down_path;
- }
- if (fixed_state.chosen_floor == 3)
- {
- if (fixed_state.chosen_maze_strategy_1 == 1)
- area_layout_map = &factory_layout.third_area_layout_easy_path;
- else if (fixed_state.chosen_maze_strategy_1 == 2)
- area_layout_map = &factory_layout.third_area_layout_hard_path;
- else if (fixed_state.chosen_maze_strategy_1 == 3)
- area_layout_map = &factory_layout.third_area_layout_hard_then_easy_path;
- }
- if (area_layout_map->size() == 0)
- return;
- double average_parts_found = 0.0;
- double average_schematics_found = 0.0;
- double average_rooms_ended_at = 0.0;
- std::vector <RoomCollection> area_layout;
- for (const auto & iterator : *area_layout_map)
- {
- const int & room_id = iterator.first;
- const RoomCollection & room_collection_source = iterator.second;
- if (room_id >= area_layout.size())
- area_layout.resize(room_id + 1);
- area_layout[room_id] = room_collection_source;
- if (setting_preoptimise_room_options)
- {
- //Modify the room. Remove choices we can't choose, and remove the requirements for the ones we can.
- RoomCollection & room_collection_active = area_layout[room_id];
- for (Room & room : room_collection_active.potential_rooms)
- {
- std::vector <RoomOption> new_options;
- for (RoomOption & option : room.options)
- {
- if (!option.capableOfChoosingChoice(fixed_state.capabilities))
- continue;
- option.required_capabilities = RobotCapabilities();
- new_options.push_back(option);
- }
- room.options = new_options;
- }
- }
- }
- if (setting_use_exact_simulation)
- {
- SimulationStateMutable base_mutable_state;
- base_mutable_state.current_hp = fixed_state.base_hp;
- base_mutable_state.room = 2;
- std::map <SimulationStateMutable, PathSimulationResult> cached_results;
- PathSimulationResult simulation_result = simulateEntirePath(area_layout, fixed_state, base_mutable_state, cached_results);
- average_parts_found = simulation_result.parts_found;
- average_schematics_found = simulation_result.schematics_found;
- }
- else
- {
- //Run simulation:
- for (int i = 0; i < simulation_count; i++)
- {
- double parts_found = 0;
- int schematics_found = 0;
- int room_ended_at = 0;
- simulateOnce(rng_generator, area_layout, fixed_state, &parts_found, &schematics_found, &room_ended_at);
- total_parts_found += parts_found;
- total_schematics_found += schematics_found;
- total_rooms_ended_at += room_ended_at;
- if (room_ended_at >= total_rooms_ended_at_frequency.size())
- total_rooms_ended_at_frequency.resize(room_ended_at + 1);
- total_rooms_ended_at_frequency[room_ended_at] += 1;
- }
- average_parts_found = ((double)total_parts_found) / ((double)simulation_count);
- average_schematics_found = ((double)total_schematics_found) / ((double)simulation_count);
- average_rooms_ended_at = ((double)total_rooms_ended_at) / ((double)simulation_count);
- }
- int furtherest_room_ended_at = 0;
- for (int room_number = 0; room_number < total_rooms_ended_at_frequency.size(); room_number++)
- {
- int amount = total_rooms_ended_at_frequency[room_number];
- if (amount > 0 && room_number > furtherest_room_ended_at)
- furtherest_room_ended_at = room_number;
- }
- double chance_of_last_room = 0.0;
- if (total_rooms_ended_at_frequency.size() > furtherest_room_ended_at)
- chance_of_last_room = ((double)total_rooms_ended_at_frequency[furtherest_room_ended_at]) / ((double)simulation_count);
- std::string strategy_string = "N/A";
- if (fixed_state.chosen_floor == 2)
- {
- if (fixed_state.chosen_maze_strategy_1 == 1)
- strategy_string = "ascend";
- else
- strategy_string = "descend";
- }
- if (fixed_state.chosen_floor == 3)
- {
- if (fixed_state.chosen_maze_strategy_1 == 1)
- strategy_string = "easy";
- else if (fixed_state.chosen_maze_strategy_1 == 2)
- strategy_string = "hard always";
- else if (fixed_state.chosen_maze_strategy_1 == 3)
- strategy_string = "hard first, easy second";
- }
- std::string parts_or_schematics;
- if (fixed_state.choose_parts_over_schematics)
- parts_or_schematics = "parts";
- else
- parts_or_schematics = "schematics";
- if (average_parts_found == 0.0 && average_schematics_found == 0.0) //certain options cannot gain anything; level 2 descending, for instance
- return;
- if (setting_use_exact_simulation)
- printf("%i\t%s\t%s\t%s\t%s\t%s\t%s\t%f\t%f\n", fixed_state.chosen_floor, strategy_string.c_str(), parts_or_schematics.c_str(), part_left_arm.name.c_str(), part_right_arm.name.c_str(), part_torso.name.c_str(), part_propulsion.name.c_str(), average_parts_found, average_schematics_found);
- else
- printf("%i\t%s\t%s\t%s\t%s\t%s\t%s\t%f\t%f\t%f\t%i\t%f\n", fixed_state.chosen_floor, strategy_string.c_str(), parts_or_schematics.c_str(), part_left_arm.name.c_str(), part_right_arm.name.c_str(), part_torso.name.c_str(), part_propulsion.name.c_str(), average_parts_found, average_schematics_found, average_rooms_ended_at, furtherest_room_ended_at, chance_of_last_room);
- }
- int main(int argc, const char * argv[])
- {
- auto start_time = std::chrono::high_resolution_clock::now();
- std::map <robot_part_location, std::vector <RobotPart> > parts_list;
- for (robot_part_location location : {robot_part_location::left_arm, robot_part_location::right_arm, robot_part_location::torso, robot_part_location::propulsion})
- {
- parts_list[location] = std::vector<RobotPart>();
- }
- {
- std::vector <RobotPart> parts_list_creating;
- //ALL:
- parts_list_creating.push_back(RobotPart("Tiny Fist", robot_part_location::left_arm, SimulationStateFixed(0, robot_capability::pow)));
- parts_list_creating.push_back(RobotPart("Bug Zapper", robot_part_location::left_arm, SimulationStateFixed(1,robot_capability::zap)));
- parts_list_creating.push_back(RobotPart("Rodent Gun", robot_part_location::left_arm, SimulationStateFixed(0,robot_capability::blam)));
- parts_list_creating.push_back(RobotPart("Rivet Shocker", robot_part_location::left_arm, SimulationStateFixed(0,robot_capability::zap,robot_capability::pow)));
- parts_list_creating.push_back(RobotPart("Mega Vise", robot_part_location::left_arm, SimulationStateFixed(0,robot_capability::pow,robot_capability::pow)));
- parts_list_creating.push_back(RobotPart("Mobile Girder", robot_part_location::left_arm, SimulationStateFixed(3)));
- parts_list_creating.push_back(RobotPart("Swiss Arm", robot_part_location::left_arm, SimulationStateFixed(0, robot_capability::pow, robot_capability::blam, robot_capability::zap)));
- parts_list_creating.push_back(RobotPart("Data Analyzer", robot_part_location::left_arm, SimulationStateFixed(0, robot_capability::decode)));
- parts_list_creating.push_back(RobotPart("Maxi-Mag Light", robot_part_location::left_arm, SimulationStateFixed(0, robot_capability::light, robot_capability::light, robot_capability::pow)));
- parts_list_creating.push_back(RobotPart("Bit Masher", robot_part_location::left_arm, SimulationStateFixed(0, robot_capability::decode, robot_capability::pow)));
- parts_list_creating.push_back(RobotPart("Camera Claw", robot_part_location::left_arm, SimulationStateFixed(0, robot_capability::decode, robot_capability::pinch)));
- //ALL:
- parts_list_creating.push_back(RobotPart("Ball-Bearing Dispenser", robot_part_location::right_arm, SimulationStateFixed(0, robot_capability::blam)));
- parts_list_creating.push_back(RobotPart("Power Arm", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::zap)));
- parts_list_creating.push_back(RobotPart("Wrecking Ball", robot_part_location::right_arm, SimulationStateFixed(1,robot_capability::pow)));
- parts_list_creating.push_back(RobotPart("Ribbon Manipulator", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::pinch)));
- parts_list_creating.push_back(RobotPart("Power Stapler", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::zap, robot_capability::pinch)));
- parts_list_creating.push_back(RobotPart("Grease Gun", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::lube)));
- parts_list_creating.push_back(RobotPart("Grease / Regular Gun", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::lube,robot_capability::blam)));
- parts_list_creating.push_back(RobotPart("Snow Blower", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::freeze)));
- parts_list_creating.push_back(RobotPart("Candle Lighter", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::burn)));
- parts_list_creating.push_back(RobotPart("Cold Shoulder", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::freeze, robot_capability::pow)));
- parts_list_creating.push_back(RobotPart("Lamp Filler", robot_part_location::right_arm, SimulationStateFixed(0,robot_capability::burn, robot_capability::lube)));
- //ALL:
- parts_list_creating.push_back(RobotPart("Basic Head", robot_part_location::torso, SimulationStateFixed(3)));
- parts_list_creating.push_back(RobotPart("Gun Face", robot_part_location::torso, SimulationStateFixed(3,robot_capability::blam)));
- parts_list_creating.push_back(RobotPart("Big Head", robot_part_location::torso, SimulationStateFixed(4)));
- parts_list_creating.push_back(RobotPart("Security Chassis", robot_part_location::torso, SimulationStateFixed(3,robot_capability::light)));
- parts_list_creating.push_back(RobotPart("Military Chassis", robot_part_location::torso, SimulationStateFixed(3,robot_capability::light,robot_capability::blam)));
- parts_list_creating.push_back(RobotPart("Crab Core", robot_part_location::torso, SimulationStateFixed(4,robot_capability::pinch)));
- parts_list_creating.push_back(RobotPart("Dynamo Head", robot_part_location::torso, SimulationStateFixed(4,robot_capability::zap)));
- parts_list_creating.push_back(RobotPart("Cyclopean Torso", robot_part_location::torso, SimulationStateFixed(4,robot_capability::light)));
- parts_list_creating.push_back(RobotPart("Really Big Head", robot_part_location::torso, SimulationStateFixed(5)));
- parts_list_creating.push_back(RobotPart("Nerding Module", robot_part_location::torso, SimulationStateFixed(5, robot_capability::decode)));
- parts_list_creating.push_back(RobotPart("Refrigerator Chassis", robot_part_location::torso, SimulationStateFixed(5, robot_capability::freeze, robot_capability::light)));
- ///ALL:
- parts_list_creating.push_back(RobotPart("Regular Legs", robot_part_location::propulsion, SimulationStateFixed(0, robot_capability::run)));
- parts_list_creating.push_back(RobotPart("Heavy-Duty Legs", robot_part_location::propulsion, SimulationStateFixed(1, robot_capability::run)));
- parts_list_creating.push_back(RobotPart("Tripod Legs", robot_part_location::propulsion, SimulationStateFixed(0,robot_capability::run,robot_capability::run)));
- parts_list_creating.push_back(RobotPart("Rollerfeet", robot_part_location::propulsion, SimulationStateFixed(0,robot_capability::run,robot_capability::roll)));
- parts_list_creating.push_back(RobotPart("Sim-Simian Feet", robot_part_location::propulsion, SimulationStateFixed(0,robot_capability::run, robot_capability::pinch)));
- parts_list_creating.push_back(RobotPart("High-Speed Fan", robot_part_location::propulsion, SimulationStateFixed(1,robot_capability::hover)));
- parts_list_creating.push_back(RobotPart("Big Wheel", robot_part_location::propulsion, SimulationStateFixed(0, robot_capability::roll, robot_capability::roll)));
- parts_list_creating.push_back(RobotPart("Hoverjack", robot_part_location::propulsion, SimulationStateFixed(2,robot_capability::hover)));
- parts_list_creating.push_back(RobotPart("Gun Legs", robot_part_location::propulsion, SimulationStateFixed(0, robot_capability::run, robot_capability::run, robot_capability::blam)));
- parts_list_creating.push_back(RobotPart("Heavy Treads", robot_part_location::propulsion, SimulationStateFixed(2, robot_capability::roll, robot_capability::pow)));
- parts_list_creating.push_back(RobotPart("Rocket Skirt", robot_part_location::propulsion, SimulationStateFixed(2, robot_capability::hover, robot_capability::burn)));
- for (RobotPart part : parts_list_creating)
- {
- parts_list[part.location].push_back(part);
- }
- }
- //Note on item distribution:
- //Each parts reward adventure has a different distribution.
- //I've collected some of my data from session logs and found the average probability of credits gained for each choice.
- //Of course, an ideal simulation would actually generate the parts according to those distributions, but I don't think it'll affect the results much? Particularly since we're using exact simulation now.
- //It's still incomplete and approximate, especially for places I rarely visit. (floor 2, floor 3 hard)
- //The constants below are from my personal data set, and are not to be trusted.
- FactoryLayout factory_layout = FactoryLayout();
- {
- //First floor:
- RoomCollection collection_bot;
- RoomCollection collection_obstacle_t1;
- RoomCollection collection_obstacle_t2;
- RoomCollection collection_reward;
- collection_bot.potential_rooms.push_back(Room("Zippybot", {RoomOption(0, 0, 0, 0, robot_capability::zap), RoomOption(0, 0, 1, 1)}));
- collection_bot.potential_rooms.push_back(Room("Turretbot", {RoomOption(0, 0, 0, 0, robot_capability::blam), RoomOption(0, 0, 1, 1)}));
- collection_bot.potential_rooms.push_back(Room("Mookbot", {RoomOption(0, 0, 0, 0, robot_capability::blam), RoomOption(0, 0, 0, 0, robot_capability::pow), RoomOption(0, 0, 1, 1)}));
- collection_bot.potential_rooms.push_back(Room("Doorbot", {RoomOption(0, 0, 0, 0, robot_capability::pow), RoomOption(0, 0, 0, 0, robot_capability::zap), RoomOption(0, 0, 1, 1)}));
- collection_bot.potential_rooms.push_back(Room("Bulkybot", {RoomOption(0, 0, 0, 0, robot_capability::pow), RoomOption(0, 0, 1, 1)}));
- collection_bot.potential_rooms.push_back(Room("Security Drone", {RoomOption(0, 0, 0, 0, robot_capability::blam), RoomOption(0, 0, 0, 0, robot_capability::zap), RoomOption(0, 0, 1, 1)}));
- //FIXME which schematic?
- collection_reward.potential_rooms.push_back(Room("The Dilemma", {RoomOption(1, 0, 0, 0), RoomOption(0, 1.0 * 1.483871, 0, 0)}));
- collection_reward.potential_rooms.push_back(Room("Locker Room", {RoomOption(0, 1.0 * 1.462069, 0, 0)}));
- collection_reward.potential_rooms.push_back(Room("The Unhurt Locker", {RoomOption(0, 1.0 * 2.000000, 0, 0)}));
- collection_reward.potential_rooms.push_back(Room("Office Space", {RoomOption(0, 1.0 * 1.524904, 0, 0), RoomOption(1, 0, 0, 0, robot_capability::pow, robot_capability::pow)})); //office space
- collection_reward.potential_rooms.push_back(Room("The Dark Closet Returns", {RoomOption(0, 1.0 * 1.317073, 0, 0), RoomOption(0, 2.0 * 1.543814, 0, 0, robot_capability::light)}));
- collection_reward.potential_rooms.push_back(Room("Inadequate Copy Room Security", {RoomOption(1, 0, 0, 0)}));
- collection_reward.potential_rooms.push_back(Room("Paperchase", {RoomOption(1, 0, 0, 0)}));
- collection_obstacle_t1.potential_rooms.push_back(Room("Conveyor, Convey Thyself", {RoomOption(0, 0, 0, 0, robot_capability::blam, robot_capability::blam), RoomOption(0, 0, 1, 1)}));
- collection_obstacle_t1.potential_rooms.push_back(Room("The Monster Masher!", {RoomOption(0, 0, 0, 0, robot_capability::zap, robot_capability::zap), RoomOption(0, 0, 1, 1)}));
- collection_obstacle_t1.potential_rooms.push_back(Room("Some People Call It A Giant Slingblade", {RoomOption(0, 0, 0, 0, robot_capability::run, robot_capability::run), RoomOption(0, 0, 1, 1)}));
- collection_obstacle_t1.potential_rooms.push_back(Room("War of Gears", {RoomOption(0, 0, 0, 0, robot_capability::pow, robot_capability::pow), RoomOption(1, 0, 0, 0, robot_capability::hover), RoomOption(0, 0, 2, 2)}));
- collection_obstacle_t1.potential_rooms.push_back(Room("Crate Expectations", {RoomOption(0, 0, 0, 0, robot_capability::pow, robot_capability::pow), RoomOption(0, 0, 2, 2)}));
- collection_obstacle_t1.potential_rooms.push_back(Room("Tin Door. Rusted.", {RoomOption(0, 0, 0, 0, robot_capability::blam, robot_capability::blam), RoomOption(0, 2.0 * 1.459283, 0, 0, robot_capability::lube), RoomOption(0, 0, 2, 2)}));
- collection_obstacle_t2.potential_rooms.push_back(Room("Closing Time", {RoomOption(0, 0, 1, 1, robot_capability::run, robot_capability::run), RoomOption(0, 0, 2, 2)}));
- collection_obstacle_t2.potential_rooms.push_back(Room("Gone With the Wind", {RoomOption(0, 0, 1, 1, robot_capability::pow, robot_capability::pow), RoomOption(0, 0, 2, 2)}));
- collection_obstacle_t2.potential_rooms.push_back(Room("Getting Your Bearings", {RoomOption(0, 0, 1, 1, robot_capability::roll), RoomOption(0, 0, 2, 2)}));
- collection_obstacle_t2.potential_rooms.push_back(Room("Down In Flames", {RoomOption(0, 0, 1, 1, robot_capability::blam, robot_capability::blam), RoomOption(0, 0, 2, 2)}));
- for (int room_number = 2; room_number < 200; room_number += 4)
- {
- factory_layout.first_area_layout[room_number] = collection_bot;
- factory_layout.first_area_layout[room_number + 1] = collection_obstacle_t1;
- factory_layout.first_area_layout[room_number + 2] = collection_reward;
- factory_layout.first_area_layout[room_number + 3] = collection_obstacle_t2;
- }
- //more, but unlikely to reach
- }
- {
- //Second floor:
- RoomCollection collection_bot;
- RoomCollection collection_obstacle;
- RoomCollection collection_up_ladder;
- RoomCollection collection_down_ladder;
- RoomCollection collection_ladder;
- //Many data points for the bots:
- collection_bot.potential_rooms.push_back(Room("Bot Your Shield", {RoomOption(0, 0, 0, 0, robot_capability::blam, robot_capability::blam), RoomOption(0, 0, 2, 2)}));
- collection_bot.potential_rooms.push_back(Room("Whatcha Thinkin'?", {RoomOption(0, 0, 0, 0, robot_capability::zap, robot_capability::zap), RoomOption(0, 0, 2, 2)}));
- collection_bot.potential_rooms.push_back(Room("Festively Armed", {RoomOption(0, 0, 0, 0, robot_capability::lube), RoomOption(0, 0, 1, 1)}));
- collection_bot.potential_rooms.push_back(Room("Compugilist", {RoomOption(0, 0, 0, 0, robot_capability::pow, robot_capability::pow), RoomOption(0, 0, 2, 2)}));
- collection_bot.potential_rooms.push_back(Room("I See You", {RoomOption(0, 0, 0, 0, robot_capability::light), RoomOption(0, 0, 1, 1)}));
- collection_obstacle.potential_rooms.push_back(Room("A Vent Horizon", {RoomOption(0, 0, 2, 2, robot_capability::freeze), RoomOption(0, 0, 3, 4)}));
- collection_obstacle.potential_rooms.push_back(Room("Off The Rails", {RoomOption(0, 0, 2, 2, robot_capability::roll, robot_capability::roll), RoomOption(0, 0, 3, 4)}));
- collection_obstacle.potential_rooms.push_back(Room("The Floor is Like Lava", {RoomOption(0, 0, 2, 2, robot_capability::hover), RoomOption(0, 0, 3, 4)}));
- collection_obstacle.potential_rooms.push_back(Room("A Pressing Concern", {RoomOption(0, 0, 2, 2, robot_capability::run, robot_capability::run), RoomOption(0, 0, 3, 4)}));
- //FIXME rewards need more precise
- collection_up_ladder.potential_rooms.push_back(Room("Still Life With Despair", {RoomOption(0, 1.0 * 2.416667, 0, 0, robot_capability::pinch), RoomOption(1, 0, 0, 0, robot_capability::zap, robot_capability::zap)}));
- collection_up_ladder.potential_rooms.push_back(Room("Hope You Have A Beretta", {RoomOption(1, 0, 0, 0, robot_capability::pinch), RoomOption(0, 1.0 * 3.119048, 0, 0, robot_capability::blam, robot_capability::blam)}));
- collection_up_ladder.potential_rooms.push_back(Room("This Gym Is Much Nicer", {RoomOption(0, 1.0 * 2.409091, 0, 0, robot_capability::pinch), RoomOption(1, 0, 0, 0, robot_capability::pinch)}));
- //FIXME unsure about damage:
- collection_down_ladder.potential_rooms.push_back(Room("Pants in High Places", {RoomOption(1, 0, 0, 0, robot_capability::blam, robot_capability::blam), RoomOption(0, 0, 2, 3)}));
- collection_down_ladder.potential_rooms.push_back(Room("Humpster Dumpster", {RoomOption(0, 1.0 * 3.636364, 0, 0, robot_capability::lube), RoomOption(0, 0, 2, 3)}));
- collection_down_ladder.potential_rooms.push_back(Room("Cage Match", {RoomOption(1, 0, 0, 0, robot_capability::zap, robot_capability::zap), RoomOption(0, 0, 2, 3)}));
- collection_down_ladder.potential_rooms.push_back(Room("Birdbot is the Wordbot", {RoomOption(0, 1.0 * 2.909091, 0, 0, robot_capability::blam, robot_capability::blam), RoomOption(0, 0, 2, 3)}));
- collection_ladder.potential_rooms.push_back(Room("The Corporate Ladder", {RoomOption(0, 0, 0, 0), RoomOption(0, 0, 0, 0)}));
- for (int room_number = 2; room_number < 100; room_number += 4)
- {
- factory_layout.second_area_layout_up_path[room_number] = collection_bot;
- factory_layout.second_area_layout_up_path[room_number + 1] = collection_ladder;
- factory_layout.second_area_layout_up_path[room_number + 2] = collection_up_ladder;
- factory_layout.second_area_layout_up_path[room_number + 3] = collection_obstacle;
- factory_layout.second_area_layout_down_path[room_number] = collection_bot;
- factory_layout.second_area_layout_down_path[room_number + 1] = collection_ladder;
- factory_layout.second_area_layout_down_path[room_number + 2] = collection_down_ladder;
- factory_layout.second_area_layout_down_path[room_number + 3] = collection_obstacle;
- }
- }
- {
- //Third floor:
- RoomCollection collection_bot;
- RoomCollection collection_choice;
- RoomCollection collection_easy_reward;
- RoomCollection collection_hard_room_1;
- RoomCollection collection_hard_room_2;
- RoomCollection collection_obstacle;
- //FIXME this data is largely my personal assumptions, DO NOT RELY ON:
- //zap/zap range assumed
- collection_bot.potential_rooms.push_back(Room("Dorkbot 4000", {RoomOption(0, 0, 0, 0, robot_capability::decode, robot_capability::decode), RoomOption(0, 0, 1, 2, robot_capability::zap, robot_capability::zap), RoomOption(0, 0, 2, 3)}));
- collection_bot.potential_rooms.push_back(Room("Et Tu, Brutebot?", {RoomOption(0, 0, 0, 0, robot_capability::pow, robot_capability::pow, robot_capability::pow), RoomOption(0, 0, 1, 2, robot_capability::pow, robot_capability::pow), RoomOption(0, 0, 2, 3)}));
- //blam/blam/blam missing, blam/blam missing
- collection_bot.potential_rooms.push_back(Room("Gunception", {RoomOption(0, 0, 0, 0, robot_capability::blam, robot_capability::blam, robot_capability::blam), RoomOption(0, 0, 1, 2, robot_capability::blam, robot_capability::blam), RoomOption(0, 0, 2, 3)}));
- //pinch/pinch missing, FREE ASSUMED
- collection_bot.potential_rooms.push_back(Room("I See What You Saw", {RoomOption(0, 0, 0, 0, robot_capability::light, robot_capability::light), RoomOption(0, 0, 1, 2, robot_capability::pinch, robot_capability::pinch), RoomOption(0, 0, 2, 3)}));
- collection_bot.potential_rooms.push_back(Room("Unfinished Business", {RoomOption(0, 0, 0, 0, robot_capability::burn), RoomOption(0, 0, 1, 2, robot_capability::lube), RoomOption(0, 0, 2, 3)}));
- //collection_easy_reward - Too Few Cooks, Clear Cut Decision, Messy, Messy
- //Rewards measured from each choice:
- collection_easy_reward.potential_rooms.push_back(Room("Clear Cut Decision", {RoomOption(1, 0, 0, 0), RoomOption(0, 2.0 * 2.598985, 0, 0)}));
- collection_easy_reward.potential_rooms.push_back(Room("Too Few Cooks", {RoomOption(1, 0, 0, 0, robot_capability::freeze), RoomOption(0, 1.0 * 3.716981, 0, 0)}));
- collection_easy_reward.potential_rooms.push_back(Room("Messy, Messy", {RoomOption(1, 0, 0, 0), RoomOption(0, 1.0 * 3.767068, 0, 0, robot_capability::burn)}));
- //collection_hard_room_1
- //FIXME POW/POW/POW ASSUMED
- collection_hard_room_1.potential_rooms.push_back(Room("Ultrasecurity Megabot", {RoomOption(0, 0, 1, 2, robot_capability::decode, robot_capability::decode), RoomOption(0, 0, 3, 4, robot_capability::pow, robot_capability::pow, robot_capability::pow), RoomOption(0, 0, 5, 6)}));
- //FIXME LIGHT/LIGHT, PINCH/PINCH, FREE?
- collection_hard_room_1.potential_rooms.push_back(Room("The Big Guns", {RoomOption(0, 0, 1, 2, robot_capability::light, robot_capability::light), RoomOption(0, 0, 3, 4, robot_capability::pinch, robot_capability::pinch), RoomOption(0, 0, 5, 6)}));
- //FIXME freeze/freeze, zap/zap, free?
- collection_hard_room_1.potential_rooms.push_back(Room("Flameybot", {RoomOption(0, 0, 1, 2, robot_capability::freeze, robot_capability::freeze), RoomOption(0, 0, 3, 4, robot_capability::zap, robot_capability::zap), RoomOption(0, 0, 5, 6)}));
- //collection_hard_room_2 - Phony
- collection_hard_room_2.potential_rooms.push_back(Room("Phony", {RoomOption(1, 0, 0, 0), RoomOption(0, 5, 0, 0)}));
- //collection_obstacle - Fire! Fire! Fire!, Freeze!, What a Grind
- //FIXME DAMAGE RANGES NEED SPADING
- collection_obstacle.potential_rooms.push_back(Room("Fire! Fire! Fire!", {RoomOption(0, 0, 2, 3, robot_capability::run, robot_capability::run), RoomOption(0, 0, 3, 4, robot_capability::freeze, robot_capability::freeze), RoomOption(0, 0, 4, 5)}));
- //FIXME DAMAGE RANGES NEED SPADING
- collection_obstacle.potential_rooms.push_back(Room("Freeze!", {RoomOption(0, 0, 2, 3, robot_capability::roll, robot_capability::roll), RoomOption(0, 0, 3, 4, robot_capability::burn, robot_capability::burn), RoomOption(0, 0, 4, 5)}));
- //FIXME DAMAGE RANGES NEED SPADING
- collection_obstacle.potential_rooms.push_back(Room("What a Grind", {RoomOption(0, 0, 2, 3, robot_capability::hover), RoomOption(0, 0, 3, 4, robot_capability::lube), RoomOption(0, 0, 4, 5)}));
- collection_choice.potential_rooms.push_back(Room("Risk vs. Reward", {RoomOption(0, 0, 0, 0), RoomOption(0, 0, 0, 0)}));
- for (int room_number = 2; room_number < 100; room_number += 4)
- {
- factory_layout.third_area_layout_easy_path[room_number] = collection_bot;
- factory_layout.third_area_layout_easy_path[room_number + 1] = collection_choice;
- factory_layout.third_area_layout_easy_path[room_number + 2] = collection_easy_reward;
- factory_layout.third_area_layout_easy_path[room_number + 3] = collection_obstacle;
- }
- for (int room_number = 2; room_number < 100; room_number += 5)
- {
- factory_layout.third_area_layout_hard_path[room_number] = collection_bot;
- factory_layout.third_area_layout_hard_path[room_number + 1] = collection_choice;
- factory_layout.third_area_layout_hard_path[room_number + 2] = collection_hard_room_1;
- factory_layout.third_area_layout_hard_path[room_number + 3] = collection_hard_room_2;
- factory_layout.third_area_layout_hard_path[room_number + 4] = collection_obstacle;
- }
- factory_layout.third_area_layout_hard_then_easy_path[2] = collection_bot;
- factory_layout.third_area_layout_hard_then_easy_path[3] = collection_choice;
- factory_layout.third_area_layout_hard_then_easy_path[4] = collection_hard_room_1;
- factory_layout.third_area_layout_hard_then_easy_path[5] = collection_hard_room_2;
- factory_layout.third_area_layout_hard_then_easy_path[6] = collection_obstacle;
- for (int room_number = 7; room_number < 100; room_number += 4)
- {
- factory_layout.third_area_layout_hard_then_easy_path[room_number] = collection_bot;
- factory_layout.third_area_layout_hard_then_easy_path[room_number + 1] = collection_choice;
- factory_layout.third_area_layout_hard_then_easy_path[room_number + 2] = collection_easy_reward;
- factory_layout.third_area_layout_hard_then_easy_path[room_number + 3] = collection_obstacle;
- }
- }
- if (false) //Output part-giving rooms instead.
- {
- std::map <std::string, bool> seen_names;
- for (const auto & map : {factory_layout.first_area_layout, factory_layout.second_area_layout_up_path, factory_layout.second_area_layout_down_path, factory_layout.third_area_layout_easy_path, factory_layout.third_area_layout_hard_path, factory_layout.third_area_layout_hard_then_easy_path})
- {
- for (const auto & iterator : map)
- {
- const RoomCollection & collection = iterator.second;
- for (const Room & room : collection.potential_rooms)
- {
- for (const RoomOption & option : room.options)
- {
- if (option.parts_given > 0.0)
- //if ((option.parts_given > 0.0 || option.schematics_given > 0.0) && room.options.size() > 1)
- seen_names[room.name] = true;
- }
- }
- }
- }
- printf("Part-giving rooms:\n");
- for (const auto & iterator : seen_names)
- {
- const std::string & name = iterator.first;
- printf("%s\n", name.c_str());
- }
- return 0;
- }
- if (setting_use_exact_simulation)
- printf("Floor\tStrategy\tChoose parts or schematics?\tLeft arm\tRight arm\tTorso\tPropulsion\tAverage credits found\tAverage schematics found\n");
- else
- printf("Floor\tStrategy\tChoose parts or schematics?\tLeft arm\tRight arm\tTorso\tPropulsion\tAverage credits found\tAverage schematics found\tAverage rooms ended at\tFurthest room ended at\tLikelyhood of reaching that room\n");
- unsigned int simulation_count = 10000000;
- simulation_count = 1000000;
- //simulation_count = 100000000;
- if (false)
- {
- //Former debug:
- simulation_count = 10000000;
- //Camera Claw Cold Shoulder Nerding Module Rocket Skirt
- simulateAllAndOutput(factory_layout, simulation_count, parts_list[robot_part_location::left_arm][10], parts_list[robot_part_location::right_arm][9], parts_list[robot_part_location::torso][9], parts_list[robot_part_location::propulsion][10], 1, 1, true);
- return 0;
- }
- if (!setting_use_exact_simulation) //individualised threading, faster for monte carlo
- {
- unsigned int wanted_thread_count = std::thread::hardware_concurrency() + 8; //HACK to use full CPU because we're not using a work queue (and should)
- //essentially, a bunch of these executions terminate early and show up in our queue and count against our limit
- //doing this correctly requires a proper work queue, but honestly I am not familiar enough with C++ to implement that the correct way, and pthread's semaphores didn't work too well on OS X last I tried
- //so instead, we just spawn a bunch of extra threads we don't need to, to saturate the CPU. this will likely affect performance and is a bad decision
- std::queue <std::thread> active_threads;
- for (RobotPart part_left_arm : parts_list[robot_part_location::left_arm])
- {
- for (RobotPart part_right_arm : parts_list[robot_part_location::right_arm])
- {
- for (RobotPart part_torso : parts_list[robot_part_location::torso])
- {
- for (RobotPart part_propulsion : parts_list[robot_part_location::propulsion])
- {
- for (int floor = setting_simulate_floor_min; floor <= setting_simulate_floor_max; floor++)
- {
- int max_strategy = 1;
- if (floor == 2)
- max_strategy = 2;
- if (floor == 3)
- max_strategy = 3;
- for (int strategy = 1; strategy <= max_strategy; strategy++)
- {
- if (active_threads.size() >= wanted_thread_count)
- {
- active_threads.front().join();
- active_threads.pop();
- }
- if (setting_simulate_schematics_as_well)
- active_threads.push(std::thread(simulateAllAndOutput, factory_layout, simulation_count, part_left_arm, part_right_arm, part_torso, part_propulsion, floor, strategy, false));
- active_threads.push(std::thread(simulateAllAndOutput, factory_layout, simulation_count, part_left_arm, part_right_arm, part_torso, part_propulsion, floor, strategy, true));
- }
- }
- }
- }
- }
- }
- while (active_threads.size() > 0)
- {
- active_threads.front().join();
- active_threads.pop();
- }
- }
- else
- {
- for (RobotPart part_left_arm : parts_list[robot_part_location::left_arm])
- {
- for (RobotPart part_right_arm : parts_list[robot_part_location::right_arm])
- {
- for (RobotPart part_torso : parts_list[robot_part_location::torso])
- {
- for (RobotPart part_propulsion : parts_list[robot_part_location::propulsion])
- {
- for (int floor = setting_simulate_floor_min; floor <= setting_simulate_floor_max; floor++)
- {
- int max_strategy = 1;
- if (floor == 2)
- max_strategy = 2;
- if (floor == 3)
- max_strategy = 3;
- for (int strategy = 1; strategy <= max_strategy; strategy++)
- {
- if (setting_simulate_schematics_as_well)
- simulateAllAndOutput(factory_layout, simulation_count, part_left_arm, part_right_arm, part_torso, part_propulsion, floor, strategy, false);
- simulateAllAndOutput(factory_layout, simulation_count, part_left_arm, part_right_arm, part_torso, part_propulsion, floor, strategy, true);
- }
- }
- }
- }
- }
- }
- }
- auto end_time = std::chrono::high_resolution_clock::now();
- double computation_time = std::chrono::duration_cast<std::chrono::duration<double>>(end_time - start_time).count();
- printf("Computed in %f seconds.\n", computation_time);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement