Skip to content

Commit

Permalink
Merge branch 'panel_hunt_r' into apworld_variety_panelhunt_2
Browse files Browse the repository at this point in the history
  • Loading branch information
NewSoupVi committed Jun 22, 2024
2 parents 7177ebc + 3baca53 commit ae16e64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
4 changes: 3 additions & 1 deletion worlds/witness/entity_hunt.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ def _get_eligible_panels(self) -> Tuple[List[str], Dict[str, Set[str]]]:
return all_eligible_panels, eligible_panels_by_area

def _get_percentage_of_hunt_entities_by_area(self):
hunt_entities_picked_so_far_prevent_div_0 = max(len(self.HUNT_ENTITIES), 1)

contributing_percentage_per_area = dict()
for area, eligible_entities in self.ELIGIBLE_ENTITIES_PER_AREA.items():
amount_of_already_chosen_entities = len(self.ELIGIBLE_ENTITIES_PER_AREA[area] & self.HUNT_ENTITIES)
current_percentage = amount_of_already_chosen_entities / len(self.HUNT_ENTITIES)
current_percentage = amount_of_already_chosen_entities / hunt_entities_picked_so_far_prevent_div_0
contributing_percentage_per_area[area] = current_percentage

return contributing_percentage_per_area
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
from collections import defaultdict

from data import static_logic as static_witness_logic

if __name__ == "__main__":
with open("APWitnessData.h", "w") as datafile:
with open("data/APWitnessData.h", "w") as datafile:
datafile.write("""# pragma once
# include <map>
# include <set>
# include <string>
""")

area_to_location_ids = defaultdict(list)
area_to_entity_ids = defaultdict(list)

with open("WitnessLogic.txt") as w:
current_area = ""

for line in w.readlines():
line = line.strip()
if not line:
continue
for entity_id, entity_object in static_witness_logic.ENTITIES_BY_HEX.items():
location_id = entity_object["id"]

if line.startswith("=="):
current_area = line[2:-2]
continue
area = entity_object["area"]["name"]
area_to_entity_ids[area].append(entity_id)

if line.endswith(":"):
continue
if location_id is None:
continue

line_split = line.split(" - ")
location_id = line_split[0]
if location_id.isnumeric():
area_to_location_ids[current_area].append(location_id)

entity_id = line_split[1].split(" ", 1)[0]

area_to_entity_ids[current_area].append(entity_id)
area_to_location_ids[area].append(str(location_id))

datafile.write("inline std::map<std::string, std::set<int64_t>> areaNameToLocationIDs = {\n")
datafile.write(
Expand All @@ -52,4 +42,4 @@
for area, entity_ids in area_to_entity_ids.items()
)
)
datafile.write("\n};\n")
datafile.write("\n};\n\n")

0 comments on commit ae16e64

Please sign in to comment.