Pseudocode key to writing Algorithms for the Parrot drone Movement Tynker Swift Playground Pseudocode Takeoff takeOff() takeoff Land land() land Wait wait() wait Gaz (up or up for ? sec down) down for ? sec Roll (left or left ? sec right) right ? sec Stop Moving stopmoving initiate function Function Name (forward forward ? sec or backwards) backward ? sec Yaw (rotate rotate left ? right or left) rotate right ? speed ? Flip (front, flip ? back, left and right) Combination list moves.. Move Conditional if let name = optionalName { if condition T/F then greeting = "Hello, \(name)" initiate command or } series of commands Conditional if score > 50 { if condition T/F then Loop teamScore += 3 initiate command or } else { series of commands teamScore += 1 or else } initiate command or series of commands While while condition T/F Condition } initiate command or Loop series of commands Loop x times For i in 1 . . . 4 { repeat ? Move(direction: MoveDirection.forward, command or series of duration: 2) commands turn(direction: TurnDirection.left, angle: 90) } Loop forever loop forever: command or series of commands Refining your Algorithm Most of the time, this will be about using loops. For example, Move(direction: MoveDirection.forward, duration: 2) For i in 1 . . . 4 { turn(direction: TurnDirection.left, 90) Move(direction: MoveDirection.forward, duration: 2) Move(direction: MoveDirection.forward, duration: 2) turn(direction: TurnDirection.left, angle: 90) turn(direction: TurnDirection.left, angle: 90) } Move(direction: MoveDirection.forward, duration: 2) turn(direction: TurnDirection.left, angle: 90)
Pseudocode key to writing Algorithms for the Parrot drone Movement Tynker Swift Playground Pseudocode Takeoff takeOff() takeoff Land land() land Wait wait() wait Gaz (up or down) up for ? sec down for ? sec Roll (left or right) left ? sec right ? sec Stop Moving stopmoving Function initiate function Name (forward or backwards) forward ? sec backward ? sec Yaw (rotate right or left) rotate left ? rotate right ? speed ? Flip (front, back, left and right) flip ? Combination Move list moves.. Conditional if let name = optionalName { greeting = "Hello, \(name)" } if condition T/F then initiate command or series of commands Conditional Loop if score > 50 { teamScore += 3 } else { teamScore += 1 } if condition T/F then initiate command or series of commands or else initiate command or series of commands While Condition Loop } while condition T/F initiate command or series of commands Loop x times For i in 1 . . . 4 { Move(direction: MoveDirection.forward, duration: 2) turn(direction: TurnDirection.left, angle: 90) } repeat ? command or series of commands Loop forever loop forever: command or series of commands Refining your Algorithm Most of the time, this will be about using loops. For example, Move(direction: MoveDirection.forward, duration: 2) turn(direction: TurnDirection.left, 90) Move(direction: MoveDirection.forward, duration: 2) turn(direction: TurnDirection.left, angle: 90) Move(direction: MoveDirection.forward, duration: 2) turn(direction: TurnDirection.left, angle: 90) For i in 1 . . . 4 { Move(direction: MoveDirection.forward, duration: 2) turn(direction: TurnDirection.left, angle: 90) }
drone-pseudocode.docx