PAYADOR-experiments / example_worlds.py
sgongora27's picture
init
2b659a0
raw
history blame
7.3 kB
"""Includes two example worlds to experiment with different scenarios."""
import random
from world import Character, Item, Location, Puzzle, World
def get_world(arg: str, language='en') -> World:
if arg=='2':
if language == 'es':
return get_world_2_spanish()
else:
return get_world_2_english()
else:
if language == 'es':
return get_world_1_spanish()
else:
return get_world_1_english()
def get_world_1_english() -> World:
"""A simple fictional world, used as an example in Figure 3 of the paper."""
item_1 = Item("Apple",
["A fruit that can be eaten", "It is round-shaped and green"])
item_2 = Item("Toy car",
["A tiny toy purple car", "It looks brand new"])
item_3 = Item("Mate",
["A classical mate, ready to drink!", "It contains some yerba", "You can drink this to boost your energy!"])
place_1 = Location("Garden",
["A beautiful garden", "There is a statue in the center"],
items = [item_2])
place_2 = Location("Cabin",
["A small cabin", "It looks like no one has lived here for a while"])
place_3 = Location("Mansion hall",
["A big hall", "There is a big staircase"])
two_random_numbers = [random.randrange(0, 10) for i in range(2)]
puzzle1 = Puzzle("puzzle",["There's a symbol of a microphone and below a letter that says how to open the door"],
f"To unlock this door, you have to say out loud the sum of {str(two_random_numbers[0])} and {str(two_random_numbers[1])}.",
f"The answer is {str(two_random_numbers[0] + two_random_numbers[1])} ")
place_1.connecting_locations+=[place_2,place_3]
place_2.connecting_locations+=[place_1]
place_3.connecting_locations+=[place_1]
place_1.block_passage(place_3,puzzle1)
player = Character("Alicia",
["She is wearing a long skirt","She likes to sing"],
inventory=[item_1],
location=place_1)
npc = Character("Javier",
["He has a long beard", "He loves to restore furtniture"],
inventory=[item_3],
location=place_3)
the_world = World(player)
the_world.add_locations([place_1, place_2, place_3])
the_world.add_items([item_1, item_2, item_3])
the_world.add_character(npc)
the_world.set_objective(item_2,place_3)
return the_world
def get_world_1_spanish() -> World:
item_1 = Item("Manzana",
["Una fruta que puede ser comida", "Es redonda y verde"])
item_2 = Item("Auto de juguete",
["Un pequeño auto de juguete de color púrpura", "Luce como recién comprado"])
item_3 = Item("Mate",
["Un mate clásico ¡listo para tomar!", "Contiene algo de yerba", "¡Puedes tomar esto para mejorar tu energía!"])
place_1 = Location("Jardín",
["Un jardín hermoso", "Hay una estatua en el centro"],
items = [item_2])
place_2 = Location("Cabaña",
["Una pequeña cabaña", "Parece que nadie ha vivido acá por un tiempo"])
place_3 = Location("Hall de la Mansión",
["Un hall grande", "Hay una enorme escalera principal"])
two_random_numbers = [random.randrange(0, 10) for i in range(2)]
puzzle1 = Puzzle("puzzle",["Hay un dibujo de un micrófono y debajo un letrero, con la premisa para abrir la puerta"],
f"Para desbloquear esta puerta, hay que decir en voz alta la suma de {str(two_random_numbers[0])} y {str(two_random_numbers[1])}.",
f"La respuesta es {str(two_random_numbers[0] + two_random_numbers[1])} ")
place_1.connecting_locations+=[place_2,place_3]
place_2.connecting_locations+=[place_1]
place_3.connecting_locations+=[place_1]
place_1.block_passage(place_3,puzzle1)
player = Character("Alicia",
["Está usando una falda larga","Le gusta cantar"],
inventory=[item_1],
location=place_1)
npc = Character("Javier",
["Tiene una barba larga", "Le encanta restaurar muebles"],
inventory=[item_3],
location=place_3)
the_world = World(player)
the_world.add_locations([place_1, place_2, place_3])
the_world.add_items([item_1, item_2, item_3])
the_world.add_character(npc)
the_world.set_objective(item_2,place_3)
return the_world
def get_world_2_english() -> World:
"""Use this world to test more complex cases, like blocked passages between locations."""
item_1 = Item("Apple",
["A fruit that can be eaten", "It is round-shaped and red"])
item_2 = Item("Key",
["A key to open a lock", "It is golden", "It is engraved with a strange coat of arms"])
item_3 = Item("A grey Hammer",
["A great grey hammer that can be used to break things", "It is so heavy..."])
item_4 = Item("Lock",
["A strong lock engraved with a coat of arms", "It seems that you cannot open it with your hands"])
item_5 = Item("Note",
["A paper with a note", "You can read 'Go to the kitchen to know the truth'"])
item_6 = Item("Flashlight",
["A flashlight without batteries"])
item_7 = Item("A green Hammer",
["A small green hammer", "It is just a toy and you cannot break anything with it."])
item_8 = Item("A wall of flames",
["The heat is really intense but it is a small fire anyway"])
item_9 = Item("A metal flower",
["A strange flower"])
item_10 = Item("A fire extinguisher",
["You can control small fires with this."])
place_3 = Location ("Garden",
["A small garden below the kitchen"],
items = [item_9])
place_2 = Location("Kitchen",
["A beautiful well-lit kitchen"],
items = [item_6,item_10])
place_2.connecting_locations = [place_3]
place_2.block_passage(place_3, item_8, symmetric=False)
place_1 = Location("Cellar",
["There is a metal door locked by a lock", "You can see damp patches on the walls"],
items = [item_2, item_3, item_5, item_7])
place_1.connecting_locations = [place_2]
place_1.block_passage(place_2, item_4)
player = Character("Cid",
["A tall soldier"],
inventory = [item_1],
location = place_1)
npc = Character("Elvira",
["A little girl", "Her favorite food is apple pie, but she enjoys eating any fruit", "She can't read yet"],
location= place_1)
the_world = World(player)
the_world.add_locations([place_1,place_2,place_3])
the_world.add_items([item_1,item_2,item_3,item_4,item_5,
item_6, item_7,item_8, item_9, item_10])
the_world.add_character(npc)
return the_world