You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.7 KiB
38 lines
1.7 KiB
from typing import List, Set
|
|
import networkx as nx
|
|
|
|
class GameWorld:
|
|
def __init__(self, graph: nx.Graph, start: str, end: str, goals: Set[str], must_visit: Set[str], initial_conditions: frozenset, towns_and_cities: Set[str]):
|
|
self.graph = graph
|
|
self.start = start
|
|
self.end = end
|
|
self.goals = goals
|
|
self.must_visit = must_visit
|
|
self.initial_conditions = initial_conditions
|
|
self.towns_and_cities = towns_and_cities
|
|
|
|
class RouteStage:
|
|
def __init__(self, name: str, graph: nx.Graph, start: str, end: str, goals: Set[str], must_visit: Set[str], towns_and_cities: Set[str]):
|
|
self.name: str = name
|
|
self.graph: nx.Graph = graph # A function or class that returns a subgraph for this stage
|
|
self.start: str = start
|
|
self.end: str = end
|
|
self.goals: Set[str] = goals
|
|
self.must_visit: Set[str] = must_visit
|
|
self.towns_and_cities: Set[str] = towns_and_cities
|
|
|
|
def create_world(self, previous_conditions=None):
|
|
# Combine initial_conditions with previous_conditions if needed
|
|
# previous_conditions are those acquired from the last stage.
|
|
#final_goals = self.goals.union(previous_conditions.get('badges', set())) if previous_conditions else self.goals
|
|
# Construct a GameWorld for this stage
|
|
world = GameWorld(
|
|
graph=self.graph,
|
|
start=self.start,
|
|
end=self.end,
|
|
goals=self.goals,
|
|
must_visit=self.must_visit,
|
|
initial_conditions=previous_conditions.get('conditions', frozenset()) if previous_conditions else frozenset(),
|
|
towns_and_cities = self.towns_and_cities
|
|
)
|
|
return world
|