Untitled
unknown
plain_text
2 years ago
1.1 kB
23
Indexable
class Game:
def __init__(self):
self.current_planet = None
class Planet:
def __init__(self, name, terrain, climate):
self.name = name
self.terrain = terrain
self.climate = climate
class AI:
def __init__(self):
self.planets = []
def generate_planet(self, name, terrain, climate):
new_planet = Planet(name, terrain, climate)
self.planets.append(new_planet)
def travel_to_planet(self, planet_name):
for planet in self.planets:
if planet.name == planet_name:
game.current_planet = planet
print(f"Travelling to {planet_name}...")
break
else:
print("Planet not found.")
# Creating the game instance
game = Game()
# Creating the AI instance
ai = AI()
# Generating AI planets
ai.generate_planet("Planet A", "Mountainous", "Temperate")
ai.generate_planet("Planet B", "Desert", "Hot")
ai.generate_planet("Planet C", "Oceanic", "Tropical")
# Traveling to a planet
ai.travel_to_planet("Planet B")
print(f"Current Planet: {game.current_planet.name}")
Editor is loading...
Leave a Comment