forked from udacity/AIPND-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3136091
commit 2987e4b
Showing
2 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.ipynb_checkpoints | ||
*/.ipynb_checkpoints/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## 机器人控制器\n", | ||
"\n", | ||
"在这个项目中,你将使用刚刚学到的知识,尝试根据要求,编写代码,来控制一个机器人,在模拟环境中行走,并找到目标宝藏。\n", | ||
"\n", | ||
"机器人所在的模拟环境中,会包这样几个因素:机器人的起点、障碍物、宝藏箱。你的任务包括:\n", | ||
"\n", | ||
"1. 分析模拟环境的数据\n", | ||
"2. 控制机器人随机行动\n", | ||
"3. 控制机器人走到终点" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"---\n", | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"## 第一节 分析模拟环境的数据\n", | ||
"\n", | ||
"首先,只有足够了解机器人所在的环境,我们的机器人才能成功找到目标宝藏,因此首先我们来对机器人所在环境的数据进行分析。在这个部分,会考察你对数据结构、控制流的了解。\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.1 理解模拟环境数据的储存格式\n", | ||
"\n", | ||
"首先我们思考这样的问题:如何存储模拟环境的数据呢?\n", | ||
"\n", | ||
"我们将我们的模拟环境抽象成一个格子世界,每个格子按照坐标编号进行标记;每个格子中会有四个情况,分别为普通格子(可通行)、机器人的起点(可通行)、障碍物(不可通行)、宝藏箱(目标点)。例如,一个模拟环境就可以抽象成3行4列的格子世界,并按这按这样的方法进行存储:\n", | ||
"```\n", | ||
"environment = [[0,0,0,2], \n", | ||
" [1,2,0,0],\n", | ||
" [0,2,3,2]]\n", | ||
"```\n", | ||
"我们用了一个列表来保存虚拟世界的数据。外层列表中的每一个元素依然是一个列表,它代表模拟环境中每行的数据。而对于这个列表中的每个元素都是一个数,它们的含义是:\n", | ||
"- 0: 普通格子(可通行)\n", | ||
"- 1: 机器人的起点(可通行)\n", | ||
"- 2: 障碍物(不可通行)\n", | ||
"- 3: 宝藏箱(目标点)\n", | ||
"\n", | ||
"如下的代码,使用了辅助函数,读取了模拟环境的数据,并保存在了 `env_data` 变量中。\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"---\n", | ||
"\n", | ||
"\n", | ||
"**任务1:**在如下代码中,请写代码获得这些值:\n", | ||
"\n", | ||
"1. 模拟环境的长和宽\n", | ||
"2. 模拟环境中第3行第6列元素" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"rows = None #TODO 1模拟环境的行数\n", | ||
"\n", | ||
"columns = None #TODO 2模拟环境的行数\n", | ||
"\n", | ||
"row_3_col_6 = None #TODO 3取出模拟环境第三行第六列的元素" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"source": [ | ||
"---\n", | ||
"\n", | ||
"## 1.2 分析模拟环境数据\n", | ||
"\n", | ||
"接着我们需要对模拟环境的中的数据进行分析。请根据如下的指示,计算相应的值。\n", | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"**任务2:**在如下代码中,请计算模拟环境中,第一行和第三列的障碍物个数。*提示,可以用循环完成。*" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"number_of_barriers_row1 = None #TODO 4计算模拟环境中,第一行的的障碍物个数。\n", | ||
"\n", | ||
"number_of_barriers_col3 = None #TODO 5计算模拟环境中,第三行的的障碍物个数。" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"---\n", | ||
"\n", | ||
"**任务3:**在如下代码中:\n", | ||
"\n", | ||
"1. 创建一个名为 `loc_map` 的字典,它有两个键值,分别为 `start` 和 `dest`,对应的值分别为起点和目标点的坐标,它们以如 `(1,1)` 的形式保存为元组。\n", | ||
"2. 从字典中取出 `start` 对应的值,保存在 `car_current_loc` 对应的变量中,这个变量表示小车现在的位置。" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"loc_map = {} #TODO 5按照上述要求创建字典\n", | ||
"\n", | ||
"car_current_loc = None #TODO 6保存小车当前的位置" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"## 第二节 控制机器人随机漫步\n", | ||
"\n", | ||
"在这一步中,你需发出指令,控制机器人在环境中随机行动。它会考察你对控制流、调用函数的知识。" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n", | ||
"\n", | ||
"## 2.1 \n", | ||
"\n", | ||
"首先我们需要创建一些变量,来保存机器人相关的数据。\n", | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"**任务4:**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## 第三节 控制机器人走到终点\n", | ||
"\n", | ||
"在这里,你将综合上述的知识,编码控制机器人走到终点。" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |