Пример #1
0
def step_10(s):
    """Create the path"""
    s.lab = np.loadtxt(lvl_directory + "/grassy_path.lab")
    s.wild = np.loadtxt(lvl_directory + "/tutorial.wild")
    s.ui.victory = ui.victory
    s.ui.defeat = ui.defeat

    def grassy_path(s):
        answer = all(s.lab[4, 2:8] // 100 == 2)
        answer = answer and all(s.lab[5, 1:9] // 100 == 1)
        answer = answer and all(s.lab[3, 1:9] // 100 == 1)
        answer = answer and s.lab[4, 1] // 100 == 1
        return answer

    s.ui.story_text = """We have created the start of a grassy path in the lab.
Complete it so that it looks like the one that was ahead of the
red robot in the wild.
Create only the grassy path, not the crystals around it.
You will use the crystals later to train Bob."""
    s.ui.obj_text = """Use the mod tool on the appropriate tiles to complete
the path."""
    s.obj_func = grassy_path
    s.next_func = step_11
    ui.checkpoint_now(s)
    return s
Пример #2
0
def step_11(s):
    """WIP"""
    s.ui.story_text = """Time to tie it all together :
By placing resources (crystals) and training Bob,
teach it to follow the grassy path.
You can reset Bob and start over if the training does not work.
You can train mutliple times to add on to Bob's experience.
When you feel confident, go into the wild and press [s] to see
if you tricked the red robot.
If the red robot does not follow the path,
click reset (in the wild) to send it back
to its original position."""
    s.ui.obj_text = """Make the red robot walk into the trap."""
    ui.checkpoint_now(s)
    return s
Пример #3
0
def step_8(s):
    """The wild is harsh"""
    s.obj_func = lambda s: False

    @return_copy
    def victory(s):
        """Won by chance, let's try again"""
        s = ui.victory(s)
        s.ui.end_text = """RANDOM VICTORY.
This will not happen everytime.
Try again and see for yourself."""
        s.ui.story_text = """You got lucky : the red robot walked into the
trap by chance."""
        s.ui.obj_text = """Click on the "Retry" button"""
        s.ui.active["retry"] = True
        #g.BUTTONS["retry"][-1] = lambda: g._state(step_9)
        return s
    s.ui.victory = victory

    @return_copy
    def defeat(s):
        """Pedagogy is the art of inflicting crushing defeats"""
        s = ui.defeat(s)
        s.ui.story_text = """The wiping out of the human race
is just a temporary setback.
We can time travel back to before you killed us all and try again."""
        s.ui.obj_text = """Click on the "Retry" button"""
        s.obj_func = lambda s: False
        s.nb_resources = 0
        g.BUTTONS["retry"][-1] = lambda: g._state(step_9)
        s.ui.active["obj_text"] = True
        s.ui.active["story_text"] = True
        return s
    s.ui.defeat = defeat

    s.ui.story_text = """Well, this one is not Bob...
The red robot is one of those we want to stop.
Your goal is to trick it into going into the trap (the red patch).
Alone in the wild, the red robot will act randomly in order to
explore its world and gather data with which to optimize
ressource collection."""
    s.ui.obj_text = """Press [s] repeatedly to see the red robot exploring."""
    ui.checkpoint_now(s)
    return s
Пример #4
0
def step_9(s):
    """Back to training"""
    s.ui.defeat = ui.defeat
    s.ui.vitcory = ui.victory
    s.ui.end_text = ""
    s.ui.active["retry"] = False
    s = ui.wild(s)
    s.ui.story_text = """Let's try again. The red robot trusts Bob.
That is because they share the same reward function.
The red robot thinks that if Bob has found a near-optimal policy
for resource collection, then it can copy that policy
and save itself the trouble of exploration.
Let's go back to the lab and teach Bob how to
follow a grassy path..."""
    s.ui.obj_text = """Click on the "Lab" button."""
    s.obj_func = lambda s: s.ui.terrain == ui.get_lab
    s.next_func = step_10
    g.BUTTONS["retry"][-1] = lambda: g._state(ui.retry)
    ui.checkpoint_now(s)
    return s
Пример #5
0
#!/usr/bin/env python3
import numpy as np
from outsmart import return_copy
import outsmart as osmt
import os.path
import graphics as g
import ui

lvl_directory = os.path.dirname(os.path.abspath(__file__))


@return_copy
def step_1(s):
    """Move the robot"""
    s.ui.filename = lvl_directory+"/level1"
    s = ui.load(s)
    s = ui.wild(s)
    s.ui.log_text = ""
    s.ui.story_text = """Neither bob nor the red robot can go through white rocks."""
    s.ui.obj_text = "Make the red robot go into the trap"
    return s


g.new_state()
g.STATE = step_1(g.STATE)
ui.checkpoint_now(g.STATE)