Chapter1. Introduction 1. 六大概念 six concepts
① Data
② Algorithm: Precise sequence of steps carrying out a task
(执行任务的精确步骤)
③ Programming: A program/software implements the algorithm that will operate on our data.(执行管理数据的计算程式) ④ Abstraction: When designing one part of a program, we can ignore the inessential details of other parts of the program as long as we have a high level understanding of what they do. (提取) ★作用/重要性:一个人不必关注所有事物,仅替换一个
因素就可更新,有条理的检测软件
⑤ Problem solving and Creative 2. State (状态) : Internal information that describes what a computer is doing.
Picobot执行的移动路线:初始state永远为0,到达state 为0-99. “x”表示该方向没有障碍物,NEWS指北东西南有障碍物。 书写形式:0 xxWx → E 1 表示Picbot在西面有障碍物的情况下向东走到的区域是1。 0 xxxx → W 0 表示Picbot在四面都没障碍物时,向西接着走到的区域是0。 1 xxxx → E 1 表示在走的过程中走到1时,四面都没障碍物,则向东面接着走到的区域仍为1。 1 xExx → W 0 表示在走的过程中走到1时,当东面有障碍物,则向西走到的区域为0。0 Nxxx → X 1 表示从0出发,当北面有障碍物时,原地不动,但该位置变成1。
★ 当只考虑一个方向有无障碍物时,其他方向可用未知数代替,如**W*,指不论其他方向如何,只要满足西面有障碍物即可。
3. Right-hand-rule
走迷宫时,想象自己处于迷宫里,让右手摸着墙走,注意不论初始地点是哪里,都是state 0。
如何让Picobot遵守右手原则:
1st’rule:当面对一个方向(北)时右手边有墙,则向面对的方向走,没墙则向右手边走。 2ndrule:当面对上述方向(北)时,面对方向有墙右边也有墙,设计转方向。3rd rule:similar sets of rules for the other three facing directions.
需要满足的客观条件:不能在意起点,所有靠墙的cell都连着外墙, 所有空cell都挨着wall。
How to think like a computer scientist 1. Python is a high-level language.
Low-level language can be called machine or assembly language.(encoding in binary计算机运行的二进制). 电脑只能直接执行low-level language编写的program,high-level have to be processed before run.
2.High-Level 的好处
①easier to program;take less time to write; shorter and easier to read; more likely to be correct.
②high-level languages are portable, can run on different kinds of computers with few or no modifications.
3.terpreters & compilers: high-level into low-level.
★ High-level program: source code Translated program: