Skip to content

Commit

Permalink
Fix colab (#487)
Browse files Browse the repository at this point in the history
* fix colab

* clear output
  • Loading branch information
QuanyiLi committed Aug 22, 2023
1 parent 902186d commit 206f575
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions metadrive/examples/Basic_MetaDrive_Usages.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@
"\n",
"# Set the envrionment config\n",
"config = {\"start_seed\": 1000, \n",
" \"environment_num\":1,\n",
" \"num_scenarios\":1,\n",
" \"traffic_density\":0.1,\n",
" \"render_mode\": \"top_down\", \n",
" }\n",
"\n",
"env = MetaDriveEnv(config)\n",
Expand All @@ -140,7 +139,7 @@
"for i in range(1000):\n",
" obs, reward, terminated, truncated, info = env.step(expert(env.vehicle))\n",
" ep_reward += reward\n",
" frame = env.render(film_size=(800, 800), track_target_vehicle=True, screen_size=(500, 500))\n",
" frame = env.render(mode=\"top_down\", film_size=(800, 800), track_target_vehicle=True, screen_size=(500, 500))\n",
" frames.append(frame)\n",
" if terminated or truncated:\n",
" print(\"Arriving Destination: {}\".format(info[\"arrive_dest\"]))\n",
Expand Down Expand Up @@ -182,10 +181,9 @@
"\n",
"# Set the environment config\n",
"config = {\"start_seed\": 0, \n",
" \"environment_num\":1,\n",
" \"num_scenarios\":1,\n",
" \"accident_prob\":1.0,\n",
" \"traffic_density\":0.25,\n",
" \"render_mode\": \"top_down\"\n",
" }\n",
"\n",
"env = SafeMetaDriveEnv(config)\n",
Expand All @@ -200,7 +198,7 @@
" obs, reward, terminated, truncated, info = env.step(expert(env.vehicle))\n",
" ep_reward += reward\n",
" ep_cost += info[\"cost\"]\n",
" frame = env.render(film_size=(1500, 1500), track_target_vehicle=True, screen_size=(500, 500))\n",
" frame = env.render(mode=\"top_down\", film_size=(1500, 1500), track_target_vehicle=True, screen_size=(500, 500))\n",
" frames.append(frame)\n",
" if terminated or truncated:\n",
" print(\"Arriving Destination: {}\".format(info[\"arrive_dest\"]))\n",
Expand Down Expand Up @@ -247,7 +245,7 @@
"\n",
"frames = []\n",
"for env_class in env_classes:\n",
" env = env_class({\"render_mode\": \"top_down\"})\n",
" env = env_class()\n",
" print(\"Starting the environment {}\\n\".format(env))\n",
" env.reset()\n",
" tm={\"__all__\":False}\n",
Expand All @@ -259,7 +257,7 @@
" for a in action.values(): \n",
" a[-1] = 1.0\n",
" o,r,tm,tc,i = env.step(action)\n",
" frame = env.render(film_size=(500, 500), track_target_vehicle=False, screen_size=(500, 500))\n",
" frame = env.render(mode=\"top_down\", film_size=(500, 500), track_target_vehicle=False, screen_size=(500, 500))\n",
" frames.append(frame)\n",
" env.close()\n",
"\n",
Expand Down Expand Up @@ -394,9 +392,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.13"
"version": "3.9.17"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}

0 comments on commit 206f575

Please sign in to comment.