Kids, Code, and Computer Science Inventing Desserts with Python
Code Like an Egyptian
The Story of The Rosetta Stone A Real-Life Treasure Hunt
TIC-80 Retro Games with Imaginary Computers August 2018
$6.00 $6.00 USD
beanz magazine August 2018 : Volume 6 Issue 1 Issue 37 (online) & 22 (print) ISSN: 2573-3966 (online) ISSN: 2573-3958 (print) beanz Magazine© is published bi-monthly, six times a year, online at http://beanzmag.com and in print. A print + online magazine subscription includes online access to all articles, with links to let you explore topics in more detail. SUBSCRIBE: visit http://beanzmag. com/subscribe or email us for checks/ invoices. We’re also available through EBSCO, Discount Magazine, WT Cox, Magazine PTP, and many other subscription services. ONLINE MAGAZINE ACCESS: send your email address to hello@beanzmag.com and we’ll set you up. Published by Owl Hill Media, LLC 378 Eastwood Rd, Woodmere, NY 11598 Email: hello@beanzmag.com Phone: (646) 553-3390 POSTMASTER: Send address changes to Owl Hill Media, LLC, 378 Eastwood Rd, Woodmere, NY 11598. Periodicals postage paid at Woodmere, NY and other mailing offices Copyright Owl Hill Media, LLC with all rights reserved except as noted. Flickr images are copyright their creators, as noted with each story both online and in print. Publisher/Editor/Webmaster: Tim Slavin Staff Writers: Amy S. Hansen, Simon Batt, Patricia Foster, Bonnie Roskes, Clarissa Littler, Jennifer Newell, Les Pounder, Paul Seal, Erin Winnick, Tim Slavin Contributors: David Dodge, Jay Silver, Jeremy Kubica, Colleen Graves, Daniel Fenjves, Ali Hagen, Emeline Swanson, Jean-Francois Nguyen, Madeleine Slavin, Tim McGuigan Back Office Magic: Wendy Garrison Copy Editors: Derek Lanuto Art Director: Kelley Lanuto Webmistress: Patricia Foster COVER IMAGE: PETE SHEFFIELD, FLICKR
Publisher’s Note You might think, with the start of a new school year, that all the summer fun is over. This issue shows how coding and computer science can be fun as you learn, as well as in the real world. If you’re interested to code but don’t know where to begin, our Play! article shows how to adapt a simple bit of Python code to play around and learn. Coding is addictive when you type code then see it in action. Tim McGuigan’s classroom project is a great example. And you don’t need Python on your computer if you use the Repl.it website to play. Another Python project demonstrates boring concepts like arrays in a fun, easy-to-understand way, by making desserts. Well, how to make digital desserts. Real cupcakes take more effort. But there’s lots more than cupcakes and code in this issue. The Project SNOWstorm article describes how software code helps track snowy owls for years using phone networks and solar powered backpacks. Another article explores how Egyptian hieroglyphics work as secret codes. We also have a profile of Michelle Barboza-Ramirez, a student paleontologist who uses podcast technology to share her experiences. And definitely check out our articles about Scratch and Minecraft, how to turn 2D drawings into 3D objects, the Ames illusion, and other topics. Parents and teachers definitely should check out the geocaching article as a fun way to learn about technology on a real life treasure hunt. Hope you enjoy this issue!
Tim Slavin Publisher beanz Magazine beanz magazine (as Kids, Code, and Computer Science magazine, our earlier title) is a winner
Our Mission
of Parents’ Choice, Tillywig, and Academics’ Choice awards: http://beanzmag.com/awards
beanz magazine is a bi-monthly online and print magazine about learning to code, computer science, and how we use technology in our daily lives. The magazine includes hard-to-find information, for example, a list of 40+ programming languages for education, coding schools, summer tech camps, and more. While the magazine is written to help kids ages 8 and older learn about programming and computer science, many readers and subscribers are parents, teachers, and librarians who use the articles to learn alongside their young kids, students, or library patrons. The magazine strives to provide easy to understand how-to information, with a bit of quirky fun. Subscribers support the magazine. There is no advertising to distract readers. The magazine explores these topics: Basics of programming and where to learn more, Problem solving and collaboration, Mathematical foundations of computing and computer science, Computational thinking, Recognizing and selecting computer devices, and the Community, global, and ethical impacts of technology.
August 2018
2 6 4 8 10 12 15
Secret Codes The Oldest Cipher
Cover Story
Coding Coding for a Sweet Tooth
Cover Story
Languages Lua: The Glue Holding Games Together
16
Scratch Cronch the Cat: A Rogue-Like-Like
Concepts Put a Filter On It!
17 18 19 20
Minecraft Stay Safe Out There!
Robotics Get Your Motor Running SketchUp It's an Illusion Show and Tell Catch a Wave, Dude
22
Profile Michelle BarbozaRamierez
tidbitz
27 Scroll For More Info 27 Pure Francine 27 From Jupiter to Juno
24
Cover Story
Projects Fun with Retro
26
Notebook What Are YOU Looking At?
Make It! 2D to 3D Notebook CLI II: A Console Bash Coding Bridging the Gap
28
From the Archives Geocaching: A Real-Life Treasure Hunt Cover Story
29
ParentTeacher Corner Play! My Best Computer Science Lesson
contents
advanced
intermediate
beginner
scribe b u s / m ag.co m z n a e b http://
2
Secret Codes
BY SIMON BATT
t s e d l O e Th The
PAUL WEVER, FLICKR
There is a replica of the Rosetta Stone in The British Museum, London, UK.
We’ve covered a lot of codes and ciphers in past issues, but none of them are as old as one of the more fascinating languages ever made; the Egyptian hieroglyphs. Created thousands of years ago, hieroglyphs can still be seen today adorning tablets and structures all around Egypt’s historical sites. It’s very important to realize the Egyptians didn’t write in hieroglyphs to confuse other people! It was their base alphabet, very much like our own ABCs. The problem was, they didn’t use letters like we did; instead, they communicated via small pictures, not unlike the emoji we use today. Historians couldn't crack this mysterious picture alphabet for quite some time, making it a kind of code in spirit! For a very long time, it was hard to decipher what hieroglyphs were. People didn't know if the symbols were words, or letters, or if each one had a special, individual meaning. No one got very far, until a soldier in Napoleon Bonaparte's army discovered a stone in the town of Rosetta in 1799. This stone had writing on it in three languages; hieroglyphs, Demotic (an ancient Egyptian script), and Ancient Greek. Scholars
tone S a t set o R e f th o y r o St
couldn’t crack what the first two languages were, but Ancient Greek was well-known and could be translated. The idea was, if this one stone had three different languages on it, it was probably saying the same thing in each passage, just in a different language. If you've ever been to an airport and seen signs in various languages, you'll know of this first hand. Therefore, once the Greek was translated, they would know what the other two scripts were saying and could work backward from there. Two men used the stone to try to become the first to decipher this ancient language: Thomas Young and Jean-François Champollion. Young made some progress. He noticed the Pharaoh name “Ptolemaios” reoccuring often on the Rosetta stone, and could identify the hieroglyphs that would make up the name. This tipped him off on how some hieroglyphs were pronounced. He used this new knowledge to translate some cartouches, which were bands with people’s names written on them in hieroglyphs. However, he became stuck and had to give up. Champollion continued Young's work by trying to translate a specific cartouche. The name was four letters long, and he knew the last two letters were two S’s.
The first symbol looked like a sun, and his previous knowledge of an ancient Egyptian language called Coptic meant he knew the word for sun was ‘Ra’. If the first symbol was the sun, it would be pronounced ‘Ra’, followed by the second symbol, followed by two S’s. “Ra - s s” sounded very similar to a very famous Egyptian Pharaoh named Ramses. When Champollion realized he had cracked the code, he promptly fainted! So what does this have to do with actual secret codes? The key is not the hieroglyphs themselves, but how they were cracked. Using the Ancient Greek portion of the Rosetta Stone, the scholars could relate the translation to the hieroglyphs and find patterns that told them how specific symbols were pronounced. This is known as "reverse engineering". It involves someone working out how something was made by seeing an end result, then working backward to see how it was constructed. This is why ciphers are kept as top secret as possible. If the enemy gets their hands on the cipher’s key, deciphering messages becomes very easy. But even finding a proper translation of a code means the enemy can make major strides in breaking the code by working backward from that point. Keep this in mind when making your own ciphers! b
C
r e iph
CHRIS NORTHWOOD, FLICKR
3
Languages
4
Lua: The Glue Holding BY CLARISSA LITTLER
Hey everyone! Welcome back to our series highlighting different programming languages. In this issue we're going to discuss a language that's useful in a lot of different gaming contexts: Lua. Lua has been around for over twenty years but is still going strong. It's the scripting language for Roblox Studio and for most of the
"fantasy computers" on the market right now, like the TIC-80 system described elsewhere in this issue. Lua is a language that's designed to be easy to use. Lua can also integrate into projects written in C/ C++. That's why it's so commonly seen as a scripting language in things like Roblox, TIC-80, or even something as nerdy as a typesetting system for books. If I were to compare Lua to any other language, I'd probably say it's closest to JavaScript, but with Ruby and Python's aesthetic. For example, a simple loop through an array that doubles each element looks like arr = {2,4,6,8} for k,v in ipairs(arr) do arr[k] = 2*v end There are some unique parts to Lua. Most of them have to do with how you use collections of data.
There's only one real type of data in Lua beyond the basic numbers, strings, and booleans: tables. Tables in Lua are arrays, dictionaries, and lists. They're like JavaScript's objects but pull even harder double-duty. So if you want to use a table as an array, you can just put items into it as in the previous code sample, and they'll automatically be numbered just like in C or JavaScript arrays. There's one weird little quirk, though: tables as arrays or lists start being numbered at 1, not 0. You could argue that this is the right thing to do because, well, who other than longtime programmers actually points at the first object in a line and calls it "zeroth"? Tables as dictionaries or JavaScript objects are made with the following syntax arr = {x="stuff", y="things"} for k,v in pairs(arr) do print("The key: "..k.." The value: "..v) end Which, when run, prints out the following: The key: y The value: things The key: x The value: stuff
The only real difference is how we iterate over something that's like a dictionary or something that's like a list. If it's a list or array with numeric indices, then you want to use the function ipairs to get the elements in order. If it's an object or dictionary, you want to use the function pairs to get all of the key/value pairs but they won't necessarily be in a reliable order. Otherwise, tables in Lua deliberately have a familiar syntax. If you're using them like arrays or lists you use the tab[3] syntax to access the third item in the list, and if you're using them like objects or dictionaries then you can use the "dot" syntax like tab.x = "chicken". Functions in Lua are most similar to functions
5
Games Together in JavaScript: they're declared with the function keyword and can either have names or not. This means you can either declare a function as either function (x,y) return x*y end OR function add(x,y) return x+y end Functions in Lua are more flexible than most programming languages because you can both take an arbitrary number of arguments into a function and you can get multiple values out of a function.
function returnsMultiple(x,y,z) return 2*x,3*y,4*z end local a,b,c=returnsMultiple(10,20,30) --this should print out 20 60 120 print(a.." "..b.." "..c) -- This function will multiply all the arguments it's given function multMany(...) local prod = 1 -- We use the syntax {...} to make a list out of all the arguments
for _, v in ipairs{...} do prod = v * prod end return prod end -- should print 120 print(multMany(1,2,3,4,5)) The last thing that's a little unusual to Lua is the local keyword you can see above. In Lua, you declare variables by assigning them a value for the first time. But what if in our function above we just wrote prod = 1. Should prod = 1 try to assign a value to a global variable that’s visible to the whole program? Or should it create a new local variable that’s only visible inside the function?
Putting local in front of the variable when you first assign it resolves the ambiguity and tells Lua that you really do want to create a new variable and not that you meant to reference an already existing global one. That's pretty much it for our little overview of Lua. If you want a ton of examples to work with and play with you can either dig into Roblox Studio or read the article in this very issue on the TIC-80 fantasy computer for making retro games. b
SAM-CAT, FLICKR
Coding
6
Coding for a
BY PATRICIA FOSTER
Whether it’s a gooey fudgebrownie or a rainbow popsicle with a thousand fruity flavors, I think we can all agree that sugary foods are awesome! To honor the sweet tooth, this activity is all about inventing new desserts. Using some simple Python code, we’re going to create a program that mashes flavors together into unexpected deliciousness. STEP 1: SETUP
Navigate to www.replt.it and select ‘Python3’ from the ‘Search for a language’ bar(cupcake A): STEP 2: CREATE LISTS
Now it’s time to put on your chef’s hat and get creative! Start by brainstorming three lists of words: one for flavors (chocolate, mint, watermelon), one for textures and bonus add-ons (sprinkles, cream, jelly), and one for desserts themselves (cake, brownies, parfait). Think up at least three words per category. When you’re done, code them up like so in the left-hand editor: flavor = ["cherry", "chocolate",
"vanilla", "caramel"] bonus = ["swirl", "volcano", "mousse", "sprinkles"] dessert = ["ice cream", "doughnut", "pie", "cookies"] In this example (cupcake B), the words “flavor”, “bonus”, and “dessert” are all variables. A variable is the most basic building block in a program. Each one can be used to store a number, a word (also known as a “string”), or a list. Lists are coding tools used to organize groups of similar elements. They’re the digital equivalent of clearing out a special shelf in the pantry so that you can store all your spices or baking items together. Each element inside the list must be separated by a comma, and the list itself starts and ends with a square bracket. Since we’re creating lists of words we also surround each of our elements with air quotes. STEP 3: IMPORT
Above the code that creates your three lists, add the following line: from random import choice
Your program should now look like this (cupcake C): This line of code allows us to access the “choice” function from the “random” module. Modules are special pre-written files of code that contain groups of similar functions. You can picture a function as a specialized worker: it can do one task, and one task only, but it’s an expert at performing that task! The “choice” function, for example, is a master at picking a random element out of a list. While you could write your own code to do the same thing, chances are the results wouldn’t be as slick and professional. Some functions need the programmer to provide them with tools in order to do their job. For instance, the choice function needs to know what list it’s picking from. We call these user-provided tools “parameters”. They’re passed to the function inside of round brackets. STEP 4: CREATING THE NEW DESSERT
Code-wise, creating our new dessert is going to feel a bit like
B A
Sweet Tooth How tasty is this?! Check out the link on the back cover of this issue for more info!
stringing beads on a necklace. We take a single variable—in this case, “new_dessert”—and add the “flavor” word. Next, we string on a blank space so that the words don’t all stick together. Then comes the “bonus”, then another space, and finally the “dessert”. The code for creating this “necklace” looks like this: new_dessert = choice(flavour) + " " + choice(bonus) + " " + choice(dessert) Using the “choice” function means that each word is picked randomly from its list. We have no idea which flavors will be mashed together! STEP 5: DISPLAY
A zany new dessert has been whipped up in our digital kitchen. Time to show it off to the world! We’re going to use the “print” function, which displays text in code editors and text-based consoles. Add the following line of code to the left-hand editor: print(new_dessert) Your program is complete (cupcake D).
FULL CODE LISTING
from random import choice flavour = ["cherry", "chocolate", "vanilla", "caramel"] bonus = ["swirl", "volcano", "mousse", "sprinkles"] dessert = ["ice cream", "doughnut", "pie", "cookies"] new_dessert = choice(flavour) + " " + choice(bonus) + " " + choice(dessert) print(new_dessert) CODING CHECKLIST
1. Did you remember to import the choice function? 2. Is “dessert” spelled with 2 “s” every time? 3. Do all your round brackets “(“ have a closing “)”, and each square bracket “[“ a “]”? 4. Are all your flavors, bonuses, and desserts contained inside quotation marks and separated by commas? When you’re ready, hit the “run” button at the top of the screen to start the program.
A THOUSAND SWEET SURPRISES!
You can run the Random Dessert Generator as often as you want! You can also keep adding new words to your lists in order to generate ever more extravagant combinations of flavors! There’s no limit to the lengths of the lists, other than your imagination. Do any of the generated combinations sound extra delicious? Think you can try making them in a real-life, non-digital kitchen? To take the Random Dessert Generator even further, try adding another list to the program. Fill this one with dessert-appropriate adjectives like “giant”, “exploding”, “fizzy”, or “fruity”. Another option to step up your game is to use two flavors in the creation of each dessert. In both cases you need to add a new “bead” to your necklace, plus that extra space so that the words don’t stick together. Play around with it and see if you can fire up this Deluxe Random Dessert Generator all by yourself! b
D C
7
Concepts
8
Put a Filter On It! BY PATRICIA FOSTER
Try the following values: • (R: 150, G:0, B: 150) • (R: 200, G:0, B: 150) • (R: 200, G:50, B: 150) So if we take this 15x15 picture of a snail and extract the first, middle, and last columns of its pixels’ RGB values, we get something like this:
It's so easy to pop a filter on a photo that we sometimes forget how remarkable this technology is. Let’s take a look at some image filters more closely: brightness, saturation, and blur filters. Breaking Down a Digital Photo
Every digital image is divided into a grid of tiny squares called pixels. Open any picture and zoom in really close. Sooner or later, even the smoothest of lines become blocky and chunk-like.
In a black and white (grayscale) photo, computers represent each pixel with a single number between 0 and 255 (“0” is pure black, “255” is pure white, and every other number is a shade in between). Take a look at the values extracted from this black & white picture of a kitty, downsized to be 15x15 pixels:
Storing color pixels is trickier. In pure numbers, what’s the difference between red-purple, fuchsia, and pink? The most common system is RGB, or “Red Green Blue”. Essentially, each digital pixel is represented by three numbers between 0 and 255, each one corresponding to a different base color (or “channel”). If a pixel has equal parts red and blue, but no green, the result is a shade of pure purple. If you slowly increase the value of the red channel, the pixel becomes more and more fuchsia. Throw some green into the mix and the color becomes less bright. To get a good feel for how this works, spend a few minutes playing around with an online digital RGB slider: https://www.w3schools. com/colors/colors_rgb.asp
With a bit of investigation, can you match the middle column of numbers to the exact column of pixels in the picture? How would you check that your guess is right?
Brightness and Saturation
“Brightness” (sometimes called “exposure”) controls how dark or light an image is. Let’s see what happens to pixel values when we boost the brightness of our snail.
color pixel is represented using three numbers. Hue runs from 0 to 360 and controls the actual color: red, yellow, pink, salmon, green, chartreuse, or otherwise. Picture a wheel that starts with red and passes through all the colors of the rainbow as you go around. Saturation controls
From a programming perspective, all we’re doing is increasing the R, G, and B values of each pixel by a fixed amount. Each color is being brightened equally, with the exception of pure black. Not all brightness filters behave this way; some would transform the black into a shade of smoky gray. What about saturation filters?
the intensity of the color, i.e. how much “gray” it contains: 0%, 100%. Brightness controls how dark a color is or how much “black” it contains. Converting a color in the RGB system into that same color stored with the HSB system makes it simple to increase or decrease saturation a specific amount.
Saturation controls how “colorful” an image is. To make a color more intense, you increase the values in one or two channels towards 255 while the leftover channel is decreased towards 0. This contrast, where the values of different colors are drawn towards opposite extremes, is what makes colors extra vivid. The most elegant way of coding a saturation filter involves a color system called HSB or HSV, which stands for “Hue, Saturation, Brightness / Value”. Like RGB, each
To see the process in action, you can check out colorizer.org. This website features color sliders for multiple systems—RGB and HSV, plus others like CMYK (used for printers) and LAB. Changing the values in one system automatically shifts the sliders of the others. You can see exactly how the different color systems relate to each other. Blurs
While photographers and Instagram users might love making their pictures pop with extra
brightness and saturation, computer scientists know that the best filter is the blur.
When you blur a picture, you erase small details and reduce a picture to its biggest, most obvious features. In other words, you’ll be able to distinguish a person’s silhouette, but the wrinkles in their shirt and the freckles on their skin are going to be smoothed over. Getting rid of tiny details makes it easier for computers to detect lines and extract features, which in turn make it possible to recognize shapes and interpret them. Blurs are the basis for computer vision. Code-wise, a blur is done by making each pixel more like its neighbors. What’s special about this filter is that each pixel isn’t modified in isolation; its final value depends on the pixels around it. In a Mean Blur, you might sum the value of a pixel with the values of the pixels above, beside, and underneath it, then take the average. There are several types of blurs, like Gaussian Blurs, Radial Blurs, and Motion Blurs. They follow the same principle, but they all place a slightly different emphasis on which neighboring pixels are selected and how much importance is placed on their value. Image filters are both simple and tricky. The basic concept is to access raw pixel values and fiddle with their intensity in order to tweak a picture’s appearance. In practice, there’s a lot of math. Decades of research in image processing has helped us discover filtering methods that are efficient and effective—so efficient that they can be done in seconds on a computer that fits in your pocket! b
9
Robotics
10
r u o g Y n t i n Ge n u R r o t o M
BY JENNIFER NEWELL
The term robot is derived from a term meaning “forced labor” and was used to describe an artificial person. Not all roboticists agree on what exactly makes a robot, a robot. However most would agree that robots are made of the following main components: a control system (such as the CPU of a computer), sensors (such as infra-red, sound, pressure), actuators (usually a motor), a power supply (such as batteries) and end effectors (such as a gripper or a tool). These parts work together so that the robot can take in information and respond appropriately. Learning how each component works individually and together in order to build a functioning robot is a many-stepped project. It's helpful to learn about the main components separately. Let's look at actuators commonly used in basic robots. An actuator is the part of a machine that is responsible for its motion. Most robots use motors as actuators. There are many motors available for beginning projects. Three of the most common lowprice motors are simple DC motors, stepper motors, and servos. These three groups of motors themselves encompass several subgroups. How can we know what motor to use for what purpose?
voltage. This is done by increasing or decreasing the number of batteries (within a range of about 3-6 volts), or connecting the motor to a potentiometer in order to alter the voltage. To reverse the direction of the spin, reverse the connection to the positive and negative ends of the batteries. Try either of the projects below to get a feel for these motors. 1. Cut a circle out of a sheet of white paper. Make a colorful design on the circle and attach it to the shaft of the motor. Connect the motor to a power supply (3-6 volts) and watch the colors blend.
Stepper Motors
2. Find a small cardboard box or a strawberry crate to use as the “chassis”. Glue or zip tie a marker to each corner, with the ink tips pointing down. Attach a small weight, ideally off center, to the motor’s shaft (a piece of unmelted hot glue stick works well). Connect the motor to a power supply and place the bot on a large piece of paper. Turn it on and watch the bot “draw”.
Simple DC and TT Motors
Hobby motors are cheap and come in many kits. The shaft spins at a high speed which can only be directly controlled by changing the
motors. Their speed is also controlled through voltage, and they only spin in one direction until the circuit is rewired as well. However, they spin much more slowly than the DC motors described above. As such, TT motors are better suited for making wheels spin at a reasonable rate, or making simple robots walk. Interested in connecting your motors to an Arduino and controlling them with code? It is not wise to connect motors directly to a microcontroller. However, it is not particularly difficult to wire the motors to a motor controller, or an H bridge, that can then be connected to an Arduino. Doing so makes the speed and direction of these simple DC motors controllable through a few lines of code, enabling them to be used in a more functional robot.
Similar to these fast spinning hobby motors are slower spinning TT
Check out the links on the back cover of this issue for more info!
Stepper motors have an interesting feature not found in the DC motors. The shaft moves in “steps”. Stepper motors differ in the number of steps required to make one full rotation, however once you figure this number out for a particular motor, you can tell the motor to rotate a certain number of steps and then stop or reverse direction. This is done by using the stepper together with an Arduino and writing a few lines of code. As long as it remains connected to a power source, it will hold its position until it's told to move. This feature comes in handy in both computer printers and 3D printers, as well as in the autofocus of many camera lenses. The speed at which the shaft rotates a given number of steps can also be controlled. As such, when building part of a robot that needs to rotate through a certain
Once it reaches the desired height, we programmed it to wait five seconds, delay(5000), and then rotate 32 steps in the reverse direction, back to the ground. This code is in a loop so it will repeat until the power is switched off. Due to the nature of Arduino, there is not a great way to avoid this.
11
The servo may be the most commonly used in robotics projects. Servo motors have a small circuit board within them. Attached to that circuit board is a positional sensor that tells the circuit board how far the shaft has rotated. Servos can be controlled with a program written for an Arduino that tells them exactly how far to rotate. This may sound similar to programming a stepper motor, however the stepper motor doesn’t actually know how much it has rotated at any time. It only knows how many pulses have been sent. By comparison, the servo motor keeps track of its location at all times. Some servo motors only have a range of 180 degrees; after they have rotated through half a circle, they rotate back in the other direction. One common application is to control robotic hands. Continuously rotating servos rotate 360 degrees and can be used to control the wheels of a rolling bot. These creations are actually electronics projects as they lack sensors to take in information. However, it would be difficult to build a fully functional robot without first completing a few electronics projects. By familiarizing yourself with several basic motors, you are well on your way to creating your own robot!
DANIEL CORTES, FLICKR
Servo Motors
MicroServo DC Hobby Motor
SPARK FUN, FLICKR
angle at a given speed, consider a stepper motor. One idea for a beginner project is to make a motorized “elevator” system. Through some trial and error, figure out the number of steps required by the motor to pull the elevator to a desired height. For example in the treehouse shown below, we found that it takes approximately 32 steps for the elevator to reach the platform of the treehouse.
Stepper Motor
b
MIKE METTS, FLICKR
Complete Homemade Robot
The code for this project PAURIC OCALLAGHAN, FLICKR
SketchUp
12
n a s n ' It usio l l I
BY BONNIE ROSKES
The Ames room is one of the most famous optical illusions. When a real Ames room is built, it has distorted walls and floor, and only allows the viewer to see inside the room through a small pinhole. This limited view makes it impossible to tell that the room is distorted. And when the viewer sees a person walk from one corner to the other, the person appears to grow or shrink. If you can’t build the actual room, the next best thing is to show it as a 3D model. SketchUp is a free and fun program for 3D modeling. You can use SketchUp to design just about anything, from furniture, to a dream bedroom, to an entire city. There is a downloadable version called SketchUp Make, which you can get at https://www.sketchup. com/download/all. But there is also a web-based version which works right in your Internet browser, called my.sketchup, and to use it just go to www.my.sketchup.com. When you open SketchUp, you’ll see Josh standing on the ground.
He isn’t yet needed in this model, so press E for the eraser, and click on any of Josh’s edges. We’ll bring Josh back later to test the illusion. Now we can start the room. To make the room a reasonable size, we want to start in Plan view (also known as top view or bird’s eye view). Click the Views icon on the right side. In the Views window, click the Top view icon. Now we’re looking straight down at the “ground.” To draw the floor, press R for the Rectangle tool. Click one corner to start, and keep an eye on the dimensions which are listed in the lower right corner. The room should be a normal size for a person—in this example, about 15’ wide and 22’ long. Be sure to orient your rectangle so that the longer side is along the green direction. Orbit (drag the mouse while pressing the middle mouse button) to get to a view like this.
Press P for Push/Pull. Click the rectangle, move the mouse to pull it up, and click again when your room is about 8’ or 9’ tall.
To make it possible to see inside the room, press E again for the Eraser, and click the top edge closest to you.
Now the top and front walls are gone.
To distort the room for the illusion, we have to adjust the walls and floor. Press M for the Move tool, and place your mouse on the edge shown below. Click to start the move.
What Is the Ames Illusion?
13
IAN STANNARD, FLICKR
Move this edge straight back, sticking to the green direction. Click again when finished. Now the left wall is longer than the right.
Now orbit to a view like this, looking straight into the room and facing the back wall. The front of the room should be outside the view - it should seem as if you’re entirely in the room.
Some of the room’s edges need to be adjusted, to make the room look normal. Press the Spacebar to activate the Select tool, and select the edge shown below.
Move this edge straight up, sticking to the blue direction. Finish the move when the bottom of the back wall looks perfectly horizontal.
Do the same for the top edge of the same wall: select it first, then move it so that the top of the back wall appears horizontal. CONTINUED ON PAGE 14
Back in 1946, American opthamologist Adelbert Ames had a clever idea for an optical illusion. He had a room built, which instead of being shaped like a box, was actually more like a trapezoid. The floor was sloped, and the back wall was uneven - one edge went further back than the other. For this illusion to work, your brain needs to think it’s looking at a regular room. Therefore, you need to look into an Ames room through a pinhole or small window. This prevents other objects in your view from telling your brain the truth. Then, as you watch, a person walks along the back wall, and seems to grow (or shrink) before your eyes. Today, you can see Ames rooms in several museums. The illusion is so convincing that Ames rooms have even been used in Hollywood, to make short actors look tall!
Top: A real-life example of the Ames illusion. Right: A diagram of the true and apparent position of a person in an Ames room, and the shape of that room. WIKIMEDIA COMMONS, PUBLIC DOMAIN
14
CONTINUED FROM PAGE 13
Here’s how your rectangles should look after adjusting:
This is a very important step: saving this view. If you were to zoom out or orbit away, you could easily tell that the room is distorted. But for the illusion, the viewer has to be seeing the room in this exact view. Go back to the Views window and click the + icon to create a new scene. The new scene is created, with the default name of “Scene 1.” The scene thumbnail (small picture) is what you click when you want to return to this view. Try it out - zoom out or orbit, then click the scene thumbnail. To enhance the illusion, this room should have something on the walls - windows or hanging pictures. Use the Rectangle tool to draw two or three rectangles along the back wall. Of course, these rectangles look distorted, though it’s actually the room that’s distorted.
We can “fix” these rectangles the same way we fixed the walls and floor. Press M for move, and be sure that nothing is already selected. Click a rectangle corner that you want to move, and move it to a new spot so that the rectangles edges look correct. Click again to finish.
To give the room some color, open the Materials window. Click the Browse icon, and open one of the material categories, such as “Colors” shown below. Choose some colors and paint the rectangles. Add a few rectangles along the side walls as well. These look a bit distorted as well if you look closely, but not enough that anyone will notice. Paint these as well, and add some material to the floor.
Now we can test the illusion. Even though we erased Josh at the beginning of this project, he’s still in the model. Open the Components window. Click the House icon which displays all components in the model. Which should include only Josh. Click Josh’s thumbnail to attach the
component to your cursor. Place Josh in one back corner of the room - it’s easiest to do this when looking down into the room.
Then place another Josh in the other back corner.
Go back to Scene 1 in the Views window. Now it appears once again that you’re standing in the room, and the two Joshes look quite different.
This makes sense - the smaller Josh is actually standing farther away from the viewer. But because the room appears normal, Josh appears much smaller than he actually is. If you want to prove to a viewer (or yourself!) that these components are the same size, select one and move it toward the other. As long as you’re moving the selected Josh along the floor (look for the “On Face” popup), you’ll see how he appears to grow or shrink. b
Catch a Wave, Dude! What do you get if two gigantic black holes crash into each other? Perhaps a bigger black hole, and huge waves of energy! To test this theory, scientists built an observatory. Most observatories use telescopes to look out at things or to listen to radio frequencies. But the Laser Interferometer Gravitational-Wave Observatory (LIGO) just feels the waves. The theory of gravitational waves (proposed by Albert Einstein in 1916) says that all of space acts like a piece of fabric. When objects move, the fabric ripples. If something collides with something else, there should be waves. While the theory is logical and has been tested, no one had actually seen a gravitational wave. Could it be photographed and heard? LIGO works on the "clean sand approach". Ecologists sometimes use a clean patch of sand to look for animal footprints. LIGO scientists use this to see “waveprints.” LIGO looks like a bunch of pipes arranged in an L-shape, with a concrete structure at the center of the L. The pipes are vacuum tubes. Each tube runs four kilometers (2.5 miles) away from the concrete center. Lasers light up these tubes. Following a predictable path, the light races down to the concrete area, hits a mirror and splits in two. One part goes back on the original side of the L, while the other goes down the second. If a gravitational wave hits Earth, it would slow down the beam of light at one end of the L, while speeding up the light at the other end. But they realized other things could change a laser’s path. A heavy truck or an earthquake could shake the vacuum tubes. Since scientists didn’t want these things to affect the measurements, they built two detectors. They put one in Washington state and another 3,000 kilometers (about 1,900 miles) away in Louisiana. The scientists only pay attention to disturbances that are recorded by both detectors. LIGO kept going for 13 years. Then on September 14, 2015, LIGO detected something. Scientists looking at the computer output thought they knew what it meant. The disturbance looked like what would happen if two giant black holes collided over a billion light years away. They had finally found a gravitational wave. Except none of the team believed it. Neil Gehrels was one of the scientists on the LIGO team. The computer system is set up with blind injections,” Gehrels explained, which is sort of like a fire drill. This means that the computer inserts random signals so that physicists learn to respond and to filter the noise. Only this wasn’t a drill!. “When I learned it wasn’t an injection, it just knocked my socks off.” Gehrels and all the other scientists kept the discovery secret so they could check and recheck the data. They had proof! Einstein’s gravitational waves were real. On February 11, 2016, they finally held a press conference. In 2017, the three founders of the project won the Nobel Prize in physics. Since then, a new LIGO observatory opened in Italy and scientists across the globe have seen waves from more black hole collisions. Gehrels said the next step is to find the source of these waves—where in the universe the collisions happened. That will come with more systems and more instruments. But for a while, Gehrels and his colleagues were happy to just ride the wave of success. b
Top image shows a view of the vacuum tubes inside the control room. The bottom image shows an artist's representation of the merger of two black holes and the gravitational waves that ripple outward. The background is a section of an illustration that shows the spacetime distortion near the collision. LICO.CALTECH.EDU
LIGO,T.PYLE
KARAN JANI, GEORGIA TECH
Show and Tell
15
BY AMY S. HANSEN
Scratch
16
BY CLARISSA LITTLER
For info on Scratch go to https://scratch.mit.edu
Cronch the Cats: A Rogue-Like-Like Rogue-likes are a genre that's defined by things including difficulty, having to start the whole game over when you die once, and random generation of levels and items. This includes games like Slay the Spire. The idea of Slay the Spire is that you proceed through a series of randomly generated turnbased battles to face the final boss. On each turn you draw a hand of cards from your deck. It's a fun but difficult game, and we'll be using it as inspiration for our own game: Cronch the Cats. https://scratch. mit.edu/projects/229878165/ Let's call our game a (rogue-like)-like, because it's a little simpler. The ideas for structuring the code in this game are: 1. Using user-defined blocks with arguments to organize our code 2. Using generic templates for writing all the basic code for both our cards and our enemies When the game starts we create a list that represents all the battles you'll fight before the boss, and we'll load the starter-deck for the player. We then run through each of the pre-determined battles. For each battle we create the enemy, start the combat loop, and after combat, we give the player cards to choose as a reward. If the player has won all the battles, then they fight the boss! The combat loop looks like this
and is fairly simple. We draw cards for the player to choose from and then wait until two cards have been played. Then the enemy gets their turn. We synchronize the player and the current enemy by using a message telling the enemy that it's time to attack. If the player dies then the game is over. If they win, we finish the Handle combat block and move on in the main loop again. There are a lot of custom blocks. This helps us show the core logic of the game loop and combat loop. It also helped with writing the game, because first I figured out what the structure of the game needed to be, and then filled in code as I went. Writing it in a modular way was useful in not losing the plot. Next: the generic templates for the enemies and cards. I chose to write almost all the code for the enemies and the cards only once, on a sprite I call a template. For example, here's the template for the generic card:
All the code, except for the parts that have comments, stays the same between every card the player can use. The code for the "Heavy attack" card is barely any different at all. The same story goes for the
enemies. Our generic enemy template is below. We only need to
change the parts labeled every time we make a new enemy. Other things that we'll need to change as we add enemies and cards: the functions on the player sprite that choose new cards or create the enemies. Those are also labeled and require only a few lines of code with each one. Look at my example cards and enemies for some ideas! Some things you can do: • Add new card types. • Add new enemies. • Add attack animations. • Add new effects and status ailments. (Right now we have weakened status, buffed status, and poisoned.) • Re-factor the code so that we can have multiple enemies. • Add equipment to the game that changes the player's stats. Enemies can have a chance of dropping weapons or armor in addition to cards to choose from. Hopefully this game ends up being a fun launching point for some of your own rogue-likes. Feel free to remix it and let me know! b
For info on Minecraft go to https://minecraft.net
Stay Safe Out There! As you've learned in previous issues, Minecraft has the capacity to be played online. This brings a new dimension to the game; you can explore the world with your friends rather than just by yourself! In general, playing online is great if you’re only playing with friends you’ve met in the real world, because you know that they’ll be nice to you. When it comes to meeting strangers online, however, there are dangers you have to watch out for. The problem here is that people tend to be more negative online than in the real world. It may seem confusing at first, but it comes down to how people interact online versus in real life. When talking to someone face-to-face, there is a ‘human element’ to the conversation. If you insulted the person in front of you, you may feel ashamed or embarrassed because of it. When people are reduced to an avatar and text chat, some people lose that ‘human element’ and think it’s okay to be rude online, saying things like “it’s just a game” or “it’s only text on the screen”, while disregarding the fact that the people playing the game and
USACE, FLICKR
reading the text are very much real. While not all strangers online will be rude, you’ll find people act badly more often online, so you should take extra care when playing on public servers. In some public servers, people are allowed to say whatever they like in the text chat. This means they can insult others without consequence, and the moderators of the server may not even care about what’s happening. If you’re concerned about what people say in the chat, you can join a familyfriendly public server which is set up to block bad words and ban people who don’t behave. You can also turn off multiplayer chat by going to the options, clicking “multiplayer settings”, then “chat”, then turning the chat off. People can also misbehave using in-game actions. Because of the ‘building block’ nature of Minecraft, some people have fun destroying the works of others. If you want to be creative, it’s best to join a server that protects what people build and prevents others from tinkering with it. Some servers allow for free building, but put everyone on a ‘trial run’ where they have to prove that they’re good in
order to gain access to the main server. No matter how friendly people may seem, never give out personal information about yourself in a game server. This includes your name, age, and real life address. Giving away this information may give complete strangers the means to harass you in real life, which is far worse than being griefed in-game! Separate your username from yourself; for example, don't use your real name in your username. If you feel upset or threatened by something or someone online, talk it through with your parents or a trusted adult as soon as possible. They will be more well-versed in these kind of events and can help guide you through what you should do next. Don’t feel as if you have to go through it alone! And as always, if playing online sounds fun but tagging along with strangers is too scary, see if you can play with friends you met in real life instead. You can trust them and not have to worry about griefing or abuse. b Check out the link on the back cover of this issue for more info on family-friendly public servers and other Minecraft stuff!
17
Minecraft
BY SIMON BATT
2D to 3D BY ERIN WINNICK
Turning a 2D drawing into a 3D creation is a great way to enter the world of computer models. You can take these models and 3D print them to bring your 2D drawing to life in a new dimension. Even if you're not planning on 3D printing it, it's fun to experiment with the software and see how you can take your drawing to the next level with 3D modeling. There are a few different ways to go about this. All involve some special software, but most are free online or on your computer. Tinkercad
This free software is great if you are new to 3D modeling and 3D printing. Hosted completely online, you can access it with a free account from any computer. One of the coolest aspects is the ability to turn your "scribbles" into models. It is literally as easy as drawing on paper. I'd recommend using a touch screen compatible stylus, your finger, or pen with a touchscreen end on it to be able to get closer to an actual drawing experience, but you can also create lines with your mouse. By combining this scribble feature with some of Tinkercad's other modeling tools, you're sure to be able to create some fun new things. Try to recreate some of the items around your house or drawings you've made before in Tinkercad and give them new life. Shapeways
OSAMU IWASAKI, FLICKR
The website known for offering 3D printing services also has some very cool apps that will allow you to easily
CREATIVE TOOLS, FLICKR
Make It!
18
turn your ideas into art. Some of the apps will automatically generate ornaments, bracelets, cookie cutters, etc, but the one below will allow you to turn your 2D drawings directly into pendants. First, create a black and white image in Paint or any other simple photo creator. Then upload it to the website and edit a few things like thickness. Or add on a ring to transform it into a pendant. It's easy as long as you have welldefined lines in your drawing. After completing your model you can then order a 3D version from Shapeways so you don't have to 3D print it yourself. Just make sure your drawing's details are not too small to show up in a print. 3D Builder
This program is found on most new Windows computers, but you can also download it yourself. It requires a little bit more 3D modeling know-how, but it's still manageable for a beginner. The software acts similar to Shapeways's, which requires you to upload a black and white image and choose whether you want the model to be created from the black or the white space. You can then adjust the size and edit your design. Although it will work best if you create the image on the computer, you can also try scanning an image that you have already drawn. As long as the contrast is high enough between the colors, the software will see it. b
CLI II: A Console Bash
In the last issue we reviewed the command line and using a terminal. Here, we'll be learning how to use the command line interface to control your computer. To start, first open up a terminal on your computer. Now type nano and hit enter. You're now in a tiny text editor and it should look like:
Scroll up and down with the arrow keys. This is the best way to look at all the files in a large directory from the command line. It's also our first example of what's called a pipe in command line programming. Pipes take the text that would be produced by the program, its output, and feed it to another program just like you would a file. Here's another example of pipes with the find command this time: find . -name "*.py" | less
Go ahead and type a little bit of text and hit Ctrl-X to exit and save. You'll be prompted to give it a filename. I'll call it test.txt. Nano is a convenient little program for doing quick edits on the command line, especially if you're remotely controlling another computer over SSH; more on that in a future article. Now, type less test.txt, where test.txt should be replaced by whatever you called this file, and you should see the text you just typed. Go ahead and hit q to exit. Less is a program for viewing files, not editing them. It doesn't just work with files, as you'll see if you type ls | less which in my default, or home, directory looks like:
which you can read as call find in the current directory (.), and look for files that end in "py" (-name "*.py", remembering that the * stands for anything), and then send the output to less. This will find all python source code files visible from the directory you're in, or any of its subdirectories. You'll probably get a lot of files back that you can scroll through. How many files, though? Well, first notice that the output of find puts each result on a different line. There's a command called wc, which stands for word count, that can count the number of lines in the input it receives. So if we type find . -name "*.py" | wc -l and hit enter then a second or so later you should see the number of files that end in .py. The find command can do a lot of cool things. On the back cover there's a link to an article that lists a lot of its tricks. Now, let's say that we want to run our special find command over and over again but don't really want to type it in full every time. We can write a bash script that will run this
command. Bash is the underlying program that takes in the input we type into the terminal and then executes it. So to start, type nano findPy.sh and type the following before you hit Ctrl-X to exit: #!/bin/bash find . -name "*.py" From here, you need to tell the command line that this file is a program it should run, which you can do by typing chmod +x findPy.sh. This tells the computer that the file findPy. sh is "eXecutable". Finally, if you type ./findPy.sh your bash script should run. The one catch is that you'll only be able to run this file by referencing its exactly location. You want to run it from anywhere without thinking about where it lives. That means you need to add the file to the path that bash uses to find commands to run. In your home directory, which you can always get to by just typing cd and hitting enter, there should be a file called .bashrc. Open it up in nano. At the bottom of the file you'll want to add the line PATH="$HOME/scripts":$PATH Every time you type something on the command line, bash looks up the first word to see if it’s a command or program it can find in its path. Here, we just told bash to first look in the scripts subdirectory of your home directory for a program with that name. If it doesn't find it, it goes on to look in the rest of the path. Now, just move your findPy.sh file into the scripts directory and then open a new terminal. If you type find and hit TAB you should see findPy.sh as an option. With all the tools you have so far, you should be able to write a script that backs up a directory you’re working on when it’s run. Just be sure to use cp and not rm so that you don’t erase the original files! b
To learn more, check out the link on the back cover of this issue.
19
Notebook
BY CLARISSA LITTLER
Coding
20
Bridging the Gap
BY LES POUNDER
You'll Need:
• A micro:bit • Micro USB lead to connect micro:bit to computer • A computer connected to the Internet Intro:
Joshua Lowe lives in the United Kingdom and he has a passion for helping children to make the move from Scratch to Python. It's a big jump because Scratch is a block language, but Python is text-based. The logic is essentially the same, but how we write the code looks very different. This is where Edublocks comes into play. Edublocks is a block-based language that enables children to write real Python code using blocks. The Python code is Python 3 compliant, so we are using the latest version of the language, but we can easily build and take apart the code enabling us to quickly debug issues. Joshua Lowe (who is 14 years old!) designed this application. It has already attracted interest from the Python community and from the creator of Python himself, Guido van Rossum. There are 9000 users of Edublocks in 72 countries around the globe. Edublocks works with the Raspberry Pi (http://edublocks. org/) and there is a special web version for the BBC micro:bit which you'll use in this project. You'll Learn: • How to code with Edublocks
• How to import libraries of code • How to use blocks to write Python 3 code • How a loop works • How a conditional statement works • How to use random choice in a game
Getting Started
Use the micro:bit version of Edublocks, accessible online at https://microbit.edublocks.org/. Edublocks has three main areas. The top of the screen allows you to change the look (theme) of Edublocks, create new files, open old files, and save your work. You can also download the code as a Python .py file or as a .hex file (which is code written specifically for the micro:bit to understand.) On the left you can see the different groups of blocks that you use to write your projects. These are broken up based on their functionality. For example: buttons, pins, and basic coding blocks. Click on a group and drag the blocks in to the final area, the large coding area. Project 1
Keep it simple: scroll a message across the LED matrix of the micro:bit when you press a button.
Start by importing the micro:bit library, found in the Basic section. Drag it into the coding area. This will enable us to write code for the micro:bit. Again from the Basic section, drag the while True: loop that will contain the code for this
project and join it to the previous block.
Use a conditional test (found in the Basic section) to detect if the button has been pressed. Place the If block inside the while True: block. So the test is to see if button was pressed and the block for this is located in the Buttons section. Drag this block and place it in the identically shaped slot found in the If block.
Now go to the Display section, find the display.scroll block, and place that inside the If block. Here you can also change the text inside that block by double clicking on “Hello World” ! The last block you need, called sleep, is found in Basic. Drag sleep inside the If block and underneath display.scroll. The sleep block is used to pause the code for a set duration. In this case enter 1000 milliseconds, which is 1 second. The code is completed. Click on Download Hex to download the micro:bit compatible code to your computer. Then, connect your
To learn more, check out the link on the back cover of this issue.
For info on Micro:bit go to https://microbit.org/resellers
micro:bit to the computer using the USB lead. Your micro:bit will pop up as if it were a flash drive. Now copy the downloaded Hex file to the micro:bit flash drive, which will start flashing the code (writing the code to the micro:bit). You'll see an orange LED on the back of the micro:bit flash. Once it stops flashing, the micro:bit will eject and then you're ready to test the code. Press Button A and you'll see the message scroll across the display! Well done! Project 2
Let's create a magic 8-ball that will answer any “Yes or No” question. How shall you control it? With a shake! Start with a new project. The first two blocks you'll use are from the Basic section: import random and from microbit import *. These blocks will import libraries of code.
The next block is 0 = 0, from Basic. Use it to create an object in which you'll store the 8-ball's responses. This object is called a list and you'll use it to store multiple items, in this case the words “Yes”, “No”, and “Possibly”. Lists are powerful objects that use indexes. You find items in a list based on their position. For example, “Yes” is the first item in our list called choices, at position 0. “No” is at position 1, and “Possibly” is at position 2. Using the 0 = 0 block,
change the first 0 to say choices, then change the second 0 so that it contains the responses (wrapped in square brackets). That's the Python way to identify a list.
In the Basic section, drag the while True: and the If block into the project. The while True: block connects to the previous block. Place the If block inside the while True: This means that the code will constantly check to see if something happens. But what triggers the code? In the Accelerometer section there's a block called accelerometer.was_ gesture. Drag that block into the empty slot for our If block. In the blank space, type the word “shake” along with the quotation marks.
In the Display section, take the display.scroll() block (but not the block with quotation marks!) and
VALENTINO FUNGHI, UNSPLASH
place it inside the If block. Make sure you choose the right one. Inside this block type in a little Python code. This code will use the random library that you imported at the start. It will also use the choice function to choose a response from our choices list. When you shake the micro:bit, it will choose a random response from the list.
Now click on Download Hex to download the micro:bit compatible code to your computer. Connect your micro:bit to the computer using the USB lead. Your micro:bit will pop up as if it were a flash drive. Now copy the downloaded Hex file to the micro:bit flash drive, which will start flashing the code. You'll see an orange LED on the back of the micro:bit flash. Once it stops, the micro:bit will eject and you can test the code. Ask a Yes or No question out loud, and then shake the micro:bit to reveal the answer! Congratulations, you've learned how to take your first steps with Python! b
21
Profile
22
BY ERIN WINICK
Michelle Barboza Meet Michelle Barboza-Ramierez! Currently working on her MSc in paleontology, she is a grad student and Research Assistant at the Florida Museum of Natural History. We sat down with Michelle to ask about her work and field of study. 1. How did you originally get interested in paleontology? I grew up visiting museums with my family nearly every weekend, and my favorite was the Los Angeles Museum of Natural History. The museum's halls were filled with amazing objects from around the world, and I was fascinated by their stories, but it never occurred to me that there was a career behind each of those objects. When I went to college, I started my studies in business administration, but happened to take a GE geology class. Once I learned you could get paid to go hiking and look at rocks, I was sold! I switched my major that same semester, and one of the next classes I took was paleontology, where I learned that you could get paid to go hiking and look at fossils — sweet! 2. What is your typical day like? A typical day working in the museum can range pretty widely, but mostly my job concerns the curation of fossils. Curation is the process of incorporating specimens into a museum's collection, from sorting fossils from expeditions and donations, to cleaning and preparing them, to making them available for scientists to research. In addition to my work in curation, I also help with the excavation of our newest dig site, which has fossils that are 5 million years old! 3. What job do you hope to get after graduation?
-Ramierez Eventually, I would like to return to grad school and get a PhD, but first I’m going to take some time off. I have a few projects that have to stay on the back burner while I finish my masters, but I’m really excited to get them going after graduation! 4. What is the most common misconception about paleontology? People often confuse paleontology for archaeology, and vice versa! It’s an understandable mistake, as our jobs are very similar and often overlap — we both study prehistory, and often use fossils to do so. However, the big difference is what section of time we study. Basically, archaeologists study everything after humans first appear in the fossil record, and paleontologists study everything before that! 5. What is the coolest thing your science studies have allowed you to do? Travel! I’ve had the opportunity to visit five different countries in the past five years, more often than not fully funded, in order to do geology and paleontology field work. Among the expeditions have been mapping volcanic rocks in the Andes mountains of Argentina and digging up Miocene fossils along the banks of the Panama Canal. 6. Where can kids go that want to learn more about your field? Books, museums, and social media! If you have access to a local natural history museum, you have access to not just paleontology but a whole range of cool science (that often intertwines!). Museums often host summer camps and special events where you can learn more about a particular field and get the opportunity to meet real scientists who study these fields. The museum gift shop would be a good place to start looking for books! A few paleontology books I would recommend are Dinosaur Empire by Abby Howard, any book from the Cartoon Prehistory of Life series by Hannah Bonner, and Daring to Dig: Adventures of Women in American Paleontology by Beth Stricker and Alana McGillis of the Paleontology Research Institute. And finally, lots of paleontologists are actively sharing their work and research on social media; with the help and permission of a parent, you can see what paleontologists are up to on a day to day basis, and even get in contact with them! I recommend following Kallie Moore (https://www.instagram. com/fossil_librarian/), collections manager of the University of Montana Paleontology Center, and Amy Atwater (https://www.instagram.com/mary_ annings_revenge), who is the new curator at the Museum of the Rockies. 7. Can you also tell us a little about your podcast project and what inspired your to start it? The Femmes of STEM podcast is a show that explores the history of women in STEM fields, recent to ancient times. Every episode, we feature the story of a new woman in science, and are joined by a modern woman in science to discuss their story. I love learning about history and I’m a podcast junkie, so I had been searching for a podcast like this for a while — when I couldn’t find it, I decided to make it myself! What I really love about having these stories of women, especially women of color, in STEM, is that it dispels the false narrative that we’re not a part of STEM. We’ve always been a part of the past, we just haven’t always been a part of history — Femmes of STEM is about changing that history. b PHOTOS: KRISTEN GRACE OF THE FLORIDA MUSEUM OF NATURAL HISTORY
23
Fun with
BY CLARISSA LITTLER
Projects
24
ICKR ARRA, FL CLIVE D
BLAKE PATTERSON, FLICKR
Retro gaming is big! 8-and-16-bit style pixel art, chiptune music, and old-school gaming styles like platformers are back in vogue, and so is the experience of working with the computers of the late 70s and early 80s. Computers like the VIC-20 and Commodore 64 were really popular during this time. They ran on operating systems and hardware that were so simple you could control almost everything about the computer—including directly programming graphics, sound, and manipulating system memory—with a version of Basic. Now we have fantasy computers, which are programs that act like a piece of hardware with its own memory, storage, and operating system. These are an easy way to get started with games programming because you do everything in the fantasy computer itself: draw sprites, write the code, make the music, and create the sound effects. The first version of the puzzle-platformer Celeste started out as a fantasy computer game, and it’s been released on every major gaming system. The most well-known fantasy computer is PICO-8, but it costs $15 and is not open-source. Instead, let's talk about TIC-80: it's free, it's opensource, and it's a fantasy computer I love. Download TIC-80 or use the in-browser version by going to https://tic.computer/create. The first thing you'll notice about TIC-80 is that you're dropped into a text prompt called a command line. If you've been following the CLI articles in both this issue and the previous one you should be pretty comfortable here. Some of the commands you're already familiar with, such as mkdir, cp, cd, and ls, are built-in and behave just like they do in OSX or Linux. If you haven't, we'll talk about all the things you need to do to get started. The first thing to do is type demo in the command line and hit enter. This will put a bunch of cartridges, or complete TIC-80 programs with graphics and sound, in your home directory. Type ls and hit enter to see them all. Now type load fire and hit enter. Has anything happened? Yes, but not obviously so. It's loaded the cartridge into memory, but you need to type run and hit enter in order for it to run. Go ahead and try that and, if everything's working correctly, you'll see something like the FIRE! graphic to the left. Now hit ESC once to end the program and ESC again to enter the editor. This is where all the magic happens! Here you can edit the program that's loaded into memory, as well as change the color palette, the sprites that are in memory, the background map, sound effects, and music. Switch between the different tabs by clicking on the icons in the upper-left corner or by pressing f1 through f5 on your keyboard. TIC-80 programs are written in a language called Lua, which we cover in more detail in a separate article this issue. Exit the assets editor by hitting ESC and try playing with some of the different demos. As of now there's an implementation of Tetris (though without music added yet), a little top-down adventure game called quest, and both the music and sfx
Retro!
25
TIC-80 Retro Games with Imaginary Computers
demos show off the sound features. On a keyboard you'll notice the keys that work by default are z, x, s, a, and the arrow keys. That's because TIC-80 is by default optimized for using a controller connected to your computer! Learn more about the keymap by going to this page of the TIC-80 documentation: https://github.com/nesbox/TIC-80/wiki/key-map. There's a lot to cover, but here's a tiny complete example of the Lua code for a simple program that acts as an interactive bubble sort. Hold down the up key to watch the sorting happen! local arr = {10, 3, 2, 8, 4, 5} local index = 1 function TIC() cls() for k,v in ipairs(arr) do rect(20+ 10*k,80 - 5*v, 10, 5*v, 2) end if btnp(0,20,20) then if arr[index] > arr[index+1] then local temp = arr[index+1] arr[index+1] = arr[index] arr[index] = temp end index = index + 1 if index == #arr then index = 1 end end end
ď ? FRANCIS MARTINEZ, FLICKR
NICK H IGGIN S. FLIC KR
Here's what's happening, step-by-step: 1. Creating variables for both the array we're sorting and the index to keep track of where we are. 2. We then declare the TIC function, which must be in every TIC-80 program. It functions as the main loop and it runs exactly 60 X per second. 3. We clear the screen with the cls function so that we're starting with a fresh canvas every frame drawn. 4. Then we draw rectangles representing the entries in the array using the rect function. We give it the x-position and y-position of the upper-left corner of the rectangle and then the width, height, and color. The color is just an index into the palette. The palette is set on the same screen as where you draw the sprites. You can even import new palettes from a hex-string. 5. Test to see if the up button is being pressed and, if it is, perform a single step of sorting. You can read more about all the functions that make up TIC-80 here: https://github.com/nesbox/TIC-80/wiki. If you click on any of the entries under "API" you'll get a description of what all the core functions in TIC-80 do. There's only a couple dozen needed to make whatever game you want! For more on how to save, export, or import your games, check out the link for this article on the back cover of this issue. And look for more on retro games in upcoming issues. b
JACK C. FLICKR
SURIAN SOOSAY, FLICKR
Show and Tell
26
BY TIM SLAVIN
What Are YOU Looking At?
Snowy owls are beautiful and mysterious with white feathers that blend into snow. A few lucky Snowy owls that fly between Canada and the United States can get a shiny small backpack if they can find Project SNOWstorm. Project SNOWstorm tracks owls as they migrate. Their goal is to learn more about these mysterious birds, what they need to thrive, and where they migrate. Tiny backpacks with solar powered transmitters are attached to snowy owls to track them in four dimensions—longitude (east to west), latitude (north to south), altitude, and flight speed—at intervals that can be set to any time length. Data can be stored for years if needed. Project SNOWstorm
uses the GSM network used for cell phones. When a snowy owl flies near a cell phone tower, data flows back and forth between the owl and the Project SNOWstorm team the same way our internet traffic flows back and forth between our phones, cell towers, and the internet. (Until now, interactive tracking has not been possible. Birds have been tracked by satellite and VHF, or Very High Frequency, a radio standard.) Early in the winter in 2018, for example, Project SNOWstorm switched on the backpack carried by a young female snowy owl along the New Jersey coastline. They sent a software command to switch tracking her longitude, latitude,
altitude, and flight speed from every hour to every six seconds. The snowy owl’s solar panel on the backpack, however, could not keep up with the energy demands of recording this data. So another software command was sent a week later to return to tracking the owl’s data every hour Software updates also can be sent to the bird’s backpack, for example, to change tracking based on where the owl flies. When owls are near the Arctic Circle where sunlight lasts twenty four hours, tracking can happen more frequently. And if there are no cell towers that far north, data is stored until the owl flies back south near a cell phone tower. b TONY HISGETT, FLICKR
tidbitz Scroll For More Info
WIKIMEDIA COMMONS
Scientists are using high-energy x-rays and software to read ancient scrolls burned and buried by the eruption of Mount Vesuvius in N ONIA ITHS M 79 AD. The x-rays S , EN UDS K KN IC R travel through the HEN scrolls while software reads the slightest delays and changes caused by the x-rays to create a layer by layer image of ancient text on papyrus. The high-energy x-rays are a stream of photons ten billion times brighter than the sun. b
27
Pure Francine
Diana Smith, a user interface designer and coder, has created an amazing portrait using only HTML and CSS coded by hand. Viewed in a Chrome web browser, right mouse-click and select View Page Source to see her amazing achievement. Right mouse-click over parts of her portrait and select Inspect to see how code creates parts of the image. http://dianaadrianne.com/purecss-francine/ b
—Adapted from a Smithsonian article by Jo Marchant, July 2018
From Jupiter to Juno
Data collected by NASA’s Juno mission to Jupiter indicate that the atmospheric winds of the gas-giant planet run deep into its atmosphere and last longer than similar atmospheric processes found here on Earth. The findings will improve understanding of Jupiter’s interior structure, core mass and, eventually, its origin. b NASA/JPL-CALTECH/SWRI/ASI/INAF/JIRAM
From the Archives
28
BY TIM SLAVIN
Geocaching: A Real-Life Treasure Hunt Someone described geocaching as, “Using billions of dollars in military hardware [GPS] to find Tupperware in the woods.” In reality, it’s a fun way to use technology AND get outdoors with family, friends, and classmates. It’s a real-life treasure hunt, often in your own community. It’s also a way to teach map reading and mapping technology. Here's What You Need:
• A GPS device, likely a smartphone, but maybe a GPS receiver • A free account at Geocaching. com to find caches near you • If you use a smartphone, a free Android or iOS Geocaching app • If you’re in the woods or open fields, wear long pants, long shirts, hats, and sturdy shoes. Bring bug spray and sunscreen. • Snacks (it might take a while) • Pen or pencil and paper • Small trinkets to leave or swap in the caches you find How Geocaching Works
The fun part of geocaching is that caches are literally everywhere, including Wall Street in New York City. There’s a good chance caches are in your town or city, too. It’s an alternate universe where people have hidden small boxes (or Tupperware) for other people to find. First, set up a free account at Geocaching.com and decide on a GPS device, either your smartphone or a dedicated receiver. A smartphone might work best because you’ll use it to find maps, look up caches while outside, and other tasks. For a phone, download
the Android or iOS app. If you’ll be out in nature, dress appropriately and check the weather. If you’re with kids, get them involved in every step of the process. The next step is to find your first cache. Keeping caches secret is a key part of geocaching. You don’t want to encourage someone to move or destroy a cache. So be sure no one else is looking when you think you might have found one. Once you find a cache, open it. Inside you’ll likely find a piece of paper with names on it. Add your name with the pen or pencil you brought along. You also might find small trinkets, often plastic charms or similar stuff. If you’ve brought trinkets, feel free to trade with what’s in the cache. Use Geocaching.com to announce your find. And sign up to receive emails when others find the cache. If you find a trackable in the cache (a kind of game piece with a unique ID number on it), don’t take it unless you plan to move it to another cache and use Geocaching.com to let everyone know it's been moved. What Could Go Wrong?
In some ways, caches in the countryside work better for kids than city caches. There’s less risk a child will run into traffic if you’re on a trail in the woods. There’s always the possibility that a cache has been disturbed or it's difficult to find. It’s a great idea to identify three or four possible caches to look for. If your first cache can’t be found, you can try the next one. (Not finding a cache
HEIPEI, FLICKR
could be a teachable moment.) Adding geocaching as a side activity for a day trip is another way to minimize the risk. What’s Next?
Geocaching is a fun activity to try at least once. There’s a community of over a million people around the world who love to find and hide caches. If you really enjoy it, join the community and contribute. If geocaching is fun at first but interest wanes, you can still look for caches as part of future day trips and vacations, or as class projects if you’re a teacher. I still get emails for two caches I looked for on a trip to New Hampshire a few years ago. It’s fun to get an email saying someone else found the caches and learning that the caches are still there. Did You Know?
You might be interested to know the use of digital maps has a negative impact on our biological sense of direction! Moving around in physical space uses different parts of the brain than checking a map does. Because digital technologies are so new, as a species humans have not figured out how to adapt our innate sense of direction. b
TREVOR MANTERNACH, FLICKR
(My Best Computer Science Lesson)
I am not prone to strong statements, however in my classroom I have come to see one lesson stand above all others for a certain type of learner. Coding can be off-putting for some, and it can be hard to sway students who are content being end-users of technology. Others see themselves as less than capable with technology, and many coding challenges can end up reinforcing this belief. However, I have found that this simple Python lesson on iterations and turtle graphics can transform even the most skeptical students into believers. Originally developed by Seymour Papert, Cynthia Solomon, and Wally Feurzeig in 1969, the turtle was a turtle-shaped mechanical robot that roamed about the floor drawing shapes with an attached pen. The user programmed the turtle using a language called LOGO, one of the first languages built specifically for teaching technology. As an homage, many modern languages today, like Java and Python, have classes and libraries that allow users to draw graphics with the turtle. I've been using the turtle as a part of my Python unit to teach about basic programming fundamentals like variables, looping, and functions. After a brief introduction on importing libraries in Python and how to use the turtle’s functions, the lesson asks the programmer to
move the turtle forward 100 pixels and turn right. The code to complete this is rather simple: from turtle import * Turtle = new turtle() Turtle.forward(100) Turtle.right(90) Even very hesitant and new learners can accomplish this task easily. So far the lesson is very accessible, but it is also still sort of bland. That skeptical student most likely will still be skeptical. The next challenge for the programmer is to make a square using a for loop— another accessible challenge. Once students learn the syntax of the for loop and how indentation works in Python, the task is fairly easy: from turtle import * Turtle = new turtle() for count in range(0,4): Turtle.forward(100) Turtle.right(90) After this, I prompt the students with their first real challenge: how can we change the code in this loop to not draw a square, but a decreasing spiral? At this point, brows can get furrowed or agile programmers can get determined. They are going to have to work to complete this one. Very often I assist by prompting them. As they work I ask, “What happens to the length of the sides in a spiral?,” and “What variable in a loop is getting larger
each time the loop iterates?” At this point, some of the students figure out that increasing the range of the loop and moving the turtle forward 100-count is the solution they are looking for. The first “whoa”s begin to come from different parts of the room as the students see Moire patterns (interference patterns) visible when the turtle makes a spiral. However, the real magic comes next. I point out to them that a spiral is a simple repeating pattern and changing the angle in the loop can have some interesting effects. I tell them that 71 and 137 are some of my favorite angles. This is usually where the classroom really explodes with excitement. All around the room, students are testing out different angles and seeing unique repeating patterns spill across their screens. Students even get possessive over the spiraling shapes they create, covering their code with their hands. From here as we move on to cover color and randomization, the class has a different feel. Students have forgotten, even for a class period, about their struggles and have engaged with technology in a playful, childlike way. As they file out of the class, many of them smiling or talking about their creations, again I am reminded about that important lesson for educators—that play really is a powerful teacher. b
VILSON VIERA, FLICKR
Editor Note: Try this code on the Repl.it website (select Python with Turtle) if your computer doesn’t have Python. NEONBRAND UNSPLASH You may have to useON Repl.it examples and tweak code.
29
Parents and Teachers
Play!
BY TIM McGUIGAN
“To change something, build a new model that makes the existing model obsolete.” —R. Buckminster Fuller Thank you for reading this issue of beanz ! Check out the links below to read stories from this issue online with links to learn more. The Oldest Cipher http://beanzmag.com/ hieroglyphs-reverseengineering
Cronch the Cat: A RogueLike-Like http://beanzmag.com/ cronch-the-cats
Lua: The Glue Holding Games Together http://beanzmag.com/ lua-games
Stay Safe Out There! http://beanzmag.com/ minecraft-stay-safe
Coding for a Sweet Tooth http://beanzmag.com/ random-dessert-generator Put a Filter On It! http://beanzmag.com/ pixels-image-filters Get Your Motor Running http://beanzmag.com/ /robot-moto It's an Illusion http://beanzmag.com/ sketchup-ames-illusion Catch a Wave, Dude http://beanzmag.com/ catch-liod-wave
2D to 3D http://beanzmag.com/ drawing-to-3d-object CLI II: A Console Bash http://beanzmag.com/ cli-console-bash Bridging the Gap http://beanzmag.com/edublocks Michelle Barboza-Ramierez http://beanzmag.com/ michelle-barboza-ramirez Fun with Retro http://beanzmag.com/tic80retro-games
What Are YOU Looking At? http://beanzmag.com/ project-snowstorm Scroll For More Info http://beanzmag.com/ tidbitz-august-2018 Pure Francine http://beanzmag.com/ tidbitz-august-2018 From Jupiter to Juno http://beanzmag.com/ tidbitz-august-2018 Geocaching: A Real-Life Treasure Hunt http://beanzmag.com/ geocaching Play! My Best Computer Science Lesson http://beanzmag.com/ best-cs-lesson ribe! Subsc
http://beanzmag.com/subscribe