February 21, 2018

- Decomposition
- breaking down a complex problem or
*system*into smaller parts - Pattern Recognition
- looking for similarities among and within problems
- Abstraction
- focusing on the important parts only, ignoring irrelevant detail
- Algorithms
- developing a step-by-step solution to the problem

You can install *TurtleGraphics* in R with this command

install.packages("TurtleGraphics")

Then you load into the session using

library(TurtleGraphics)

Now you start a new “terrarium” with

turtle_init()

Set Up a New, Shiny Terrarium

turtle_init(width = 100, height = 100, mode = c("error", "clip", "cycle"))

- width
- numeric; plot width.
- height
- numeric; plot height.
- mode
- character string; one of “error”, “clip”, or “cycle”.

We will explore these options later

- Move the Turtle Forward or Backward
`turtle_move(10)`

`move (10) steps`

- Turn (Rotate) the Turtle
`turtle_right(15)`

`turn cw (15) degrees`

`turtle_left(15)`

`turn ccw (15) degrees`

- Set the Turtle’s Position and Direction
`turtle_setangle(90)`

`point in direction (90 v)`

`turtle_goto(0,0)`

`go to x:(0) y:(0)`

- Pen commands
`turtle_up()`

`pen up`

`turtle_down()`

`pen down`

- Display Options
`turtle_col(0)`

`set pen color to (0)`

`turtle_lwd(1)`

`set pen size to (1)`

`turtle_lty(1)`

Change line type- Show or Hide the Turtle
`turtle_hide()`

`hide`

`turtle_show()`

`show`

- Get the Turtle’s Current Position and Direction
`turtle_getangle()`

`(direction)`

`turtle_getpos()`

`(x position)`

`(y position)`

Evaluate a Larger Portion of Turtle Drawing Code

`turtle_do({`

code here`})`

turtle_init()

turtle_getangle()

angle 0

turtle_getpos()

x y 50 50

So we have to adapt our code (how?)

turtle_move(80)

Error in .turtle_draw_error(distance, curX, curY, curAng, curGp, curDraw, : The Turtle escaped from the terrarium. :-(

turtle_init(mode = "clip")

Please write in paper what we do on Rstudio

What happens when the turtle gets out?

Since the turtle is at (50,50),

How do we change our code?

Separating a complex problem into smaller, more manageable parts

Here we separate a complex figure into many smaller parts

**Homework:** Draw a stick man using R Turtle Graphics

Is this problem *similar* to another?

Are there parts of this problem that are similar to each other?

**
Please answer this question**

Computers can be used to help us solve problems. However, before a problem can be tackled, the problem itself and the ways in which it could be solved need to be understood.

Computational thinking allows us to do this.

Computational thinking allows us to take a complex problem, understand what the problem is and develop possible solutions. We can then present these solutions in a way that a computer, a human, or both, can understand.

- decomposition
- breaking down a complex problem or system into smaller, more manageable parts
- pattern recognition
- looking for similarities among and within problems
- abstraction
- focusing on the important information only, ignoring irrelevant detail
- algorithms
- developing a step-by-step solution to the problem, or the rules to follow to solve the problem

They are like legs on a table

- if one leg is missing, the table will probably collapse

Correctly applying all four techniques will help when programming a computer.

A complex problem is one that, at first glance, we don’t know how to solve easily.

Computational thinking involves taking that complex problem and breaking it down into a series of small, more manageable problems (**decomposition**). Each of these smaller problems can then be looked at individually, considering how similar problems have been solved previously (**pattern recognition**) and focusing only on the important details, while ignoring irrelevant information (**abstraction**). Next, simple steps or rules to solve each of the smaller problems can be designed (**algorithms**).

Finally, these simple steps or rules are used to program a computer to help solve the complex problem in the best way.