prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  sim_policy not working
  Hi, 
  I just found that sim_policy.py cannot work. 
  data that read from "params.pkl" does not include the key of "policy"
  
  </issue>
  <code>
  [start of examples/sim_policy.py]
  1 #!/usr/bin/env python3
  2 
  3 import argparse
  4 
  5 import joblib
  6 import tensorflow as tf
  7 
  8 from garage.misc.console import query_yes_no
  9 from garage.sampler.utils import rollout
  10 
  11 if __name__ == "__main__":
  12 
  13     parser = argparse.ArgumentParser()
  14     parser.add_argument('file', type=str, help='path to the snapshot file')
  15     parser.add_argument(
  16         '--max_path_length',
  17         type=int,
  18         default=1000,
  19         help='Max length of rollout')
  20     parser.add_argument('--speedup', type=float, default=1, help='Speedup')
  21     args = parser.parse_args()
  22 
  23     # If the snapshot file use tensorflow, do:
  24     # import tensorflow as tf
  25     # with tf.Session():
  26     #     [rest of the code]
  27     with tf.Session() as sess:
  28         data = joblib.load(args.file)
  29         policy = data['policy']
  30         env = data['env']
  31         while True:
  32             path = rollout(
  33                 env,
  34                 policy,
  35                 max_path_length=args.max_path_length,
  36                 animated=True,
  37                 speedup=args.speedup)
  38             if not query_yes_no('Continue simulation?'):
  39                 break
  40
  [end of examples/sim_policy.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/examples/sim_policy.py b/examples/sim_policy.py
  --- a/examples/sim_policy.py
  +++ b/examples/sim_policy.py
  @@ -8,7 +8,7 @@
   from garage.misc.console import query_yes_no
   from garage.sampler.utils import rollout
   
  -if __name__ == "__main__":
  +if __name__ == '__main__':
   
       parser = argparse.ArgumentParser()
       parser.add_argument('file', type=str, help='path to the snapshot file')
  @@ -26,7 +26,7 @@
       #     [rest of the code]
       with tf.Session() as sess:
           data = joblib.load(args.file)
  -        policy = data['policy']
  +        policy = data['algo'].policy
           env = data['env']
           while True:
               path = rollout(
  
verification_info: {"golden_diff": "diff --git a/examples/sim_policy.py b/examples/sim_policy.py\n--- a/examples/sim_policy.py\n+++ b/examples/sim_policy.py\n@@ -8,7 +8,7 @@\n from garage.misc.console import query_yes_no\n from garage.sampler.utils import rollout\n \n-if __name__ == \"__main__\":\n+if __name__ == '__main__':\n \n     parser = argparse.ArgumentParser()\n     parser.add_argument('file', type=str, help='path to the snapshot file')\n@@ -26,7 +26,7 @@\n     #     [rest of the code]\n     with tf.Session() as sess:\n         data = joblib.load(args.file)\n-        policy = data['policy']\n+        policy = data['algo'].policy\n         env = data['env']\n         while True:\n             path = rollout(\n", "issue": "sim_policy not working\nHi, \r\nI just found that sim_policy.py cannot work. \r\ndata that read from \"params.pkl\" does not include the key of \"policy\"\n", "before_files": [{"content": "#!/usr/bin/env python3\n\nimport argparse\n\nimport joblib\nimport tensorflow as tf\n\nfrom garage.misc.console import query_yes_no\nfrom garage.sampler.utils import rollout\n\nif __name__ == \"__main__\":\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument('file', type=str, help='path to the snapshot file')\n    parser.add_argument(\n        '--max_path_length',\n        type=int,\n        default=1000,\n        help='Max length of rollout')\n    parser.add_argument('--speedup', type=float, default=1, help='Speedup')\n    args = parser.parse_args()\n\n    # If the snapshot file use tensorflow, do:\n    # import tensorflow as tf\n    # with tf.Session():\n    #     [rest of the code]\n    with tf.Session() as sess:\n        data = joblib.load(args.file)\n        policy = data['policy']\n        env = data['env']\n        while True:\n            path = rollout(\n                env,\n                policy,\n                max_path_length=args.max_path_length,\n                animated=True,\n                speedup=args.speedup)\n            if not query_yes_no('Continue simulation?'):\n                break\n", "path": "examples/sim_policy.py"}]}