February 21, 2018
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"))
We will explore these options later
turtle_move(10)
move (10) steps
turtle_right(15)
turn cw (15) degrees
turtle_left(15)
turn ccw (15) degrees
turtle_setangle(90)
point in direction (90 v)
turtle_goto(0,0)
go to x:(0) y:(0)
turtle_up()
pen up
turtle_down()
pen down
turtle_col(0)
set pen color to (0)
turtle_lwd(1)
set pen size to (1)
turtle_lty(1)
Change line typeturtle_hide()
hide
turtle_show()
show
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.
They are like legs on a table
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.