Ready, SET, go! By Melissa Dalis Professor Susan Rodger Duke University July 2011

Similar documents
Let's Race! Typing on the Home Row

Princess & Dragon Version 2

By Maggie Bashford Professor Susan Rodger Duke University July

Creating a Historical Tour in Alice

Demo. Getting Started with Alice Demo

How Tall Are You? Introducing Functions

Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008

How Tall Are You? Introducing Func6ons

Princess & Dragon Part 2: Teaching a Dragon to Fly Methods & Proper:es

Alice. our characters it would be nice to be able to. This can simplify the story and sometimes add. Zoom in on our first character when she talks

Begin at the beginning," the King said, very gravely, "and go on till you come to the end

Once you have chosen the water world this is how your screen should look.

Objects in Alice: Positioning and. Moving Them July 2008

Learning to Program: Part 2 Wri0ng Methods and Events

Princess & Dragon Part 3: A Knight Comes Riding In Cameras & Events

Overview. Scene Changes. Camera Markers in Alice 3. Open a new Alice world

Alice and Daisies: Posi/oning and Moving Objects in Alice. By Jenna Hayes under the direc/on of Professor Susan Rodger Duke University July 2008

Tutorial on Bunny visi/ng his animal friends - parameters, events for Alice 3

In this project you ll learn how to code your own musical instruments!

pla<orm-style game which you can later add your own levels, powers and characters to. Feel free to improve on my art

COMPUTING CURRICULUM TOOLKIT

Excel 2003: Discos. 1. Open Excel. 2. Create Choose a new worksheet and save the file to your area calling it: Disco.xls

Challenge 1: Tami s World

This Photoshop Tutorial 2012 Steve Patterson, Photoshop Essentials.com. Not To Be Reproduced Or Redistributed Without Permission.

Scratch Coding And Geometry

Before displaying an image, the game should wait for a random amount of time.

Canoe Mirroring Lofts

Part II Coding the Animation

C# Tutorial Fighter Jet Shooting Game

Basics Pictures Media Bar

The editor was built upon.net, which means you need the.net Framework for it to work. You can download that here:

ChatBot. Introduction. Scratch. You are going to learn how to program your own talking robot! Activity Checklist. Test your Project.

Kismet Interface Overview

Quintic Software Tutorial 3

Create a Simple Game in Scratch

Gaia is a system that enables rapid and precise creation of gorgeous looking Unity terrains. Version March 2016 GAIA. By Procedural Worlds

Converting a solid to a sheet metal part tutorial

Creating multicolored wiring diagrams in Visio 2013

Getting Started. with Easy Blue Print

3rd Grade. Fractions. Slide 1 / 215. Slide 2 / 215. Slide 3 / 215. Table of Contents Click title to go to that section

3rd Grade. Fractions. Equal Parts. Slide 1 / 215 Slide 2 / 215. Slide 4 / 215. Slide 3 / 215. Slide 5 / 215. Slide 6 / 215.

UNDERSTANDING LAYER MASKS IN PHOTOSHOP

Pong! The oldest commercially available game in history

Using Adobe Photoshop

Alibre Design Tutorial - Simple Extrude Step-Pyramid-1

Addendum 18: The Bezier Tool in Art and Stitch

Name: Date Completed: Basic Inventor Skills I

CONCEPTS EXPLAINED CONCEPTS (IN ORDER)

CAD Tutorial. CAD Detail Windows. In this tutorial you ll learn about: CAD Detail Windows Exploding and Modifying a CAD Block

Copyright 2017 MakeUseOf. All Rights Reserved.

Memory. Introduction. Scratch. In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

Adding in 3D Models and Animations

Four Leaf Clover Box. Making the box. step 1. Erin Bassett. projects

A quick overview of the basics of my workflow in. Those gaps in Photoshop s Histogram indicate missing information.

COLORIZING IMAGES WITH GRADIENT MAPS

How to Make Games in MakeCode Arcade Created by Isaac Wellish. Last updated on :10:15 PM UTC

iphoto Getting Started Get to know iphoto and learn how to import and organize your photos, and create a photo slideshow and book.

In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

The Essen(als of Alice (Bunny) By Jenna Hayes under the direc(on of Professor Susan Rodger Duke University July 2008

GAME:IT Junior Bouncing Ball

The Beauty and Joy of Computing Lab Exercise 10: Shall we play a game? Objectives. Background (Pre-Lab Reading)

Make It: Bottle Light. Making Bottle Lights with the Westmont Library Makery

Excel 2016 Cell referencing and AutoFill

QUICK-START FOR UNIVERSAL VLS 4.6 LASER! FRESH 21 SEPTEMBER 2017

A. creating clones. Skills Training 5

Name the layer you rotated in step 3 Stripe and lower the opacity to 43%.

Materials Tutorial. Setting Materials Defaults

Creating a Maze Game in Tynker

EG1003 Help and How To s: Revit Tutorial

Unit 6.5 Text Adventures

PHOTOSHOP PUZZLE EFFECT

Unit 5: What s in a List

The original image. Let s get started! The final rainbow effect. The photo sits on the Background layer in the Layers panel.

Lesson 2 Game Basics

Landscaping Tutorial. Chapter 5:

Game Design Curriculum Multimedia Fusion 2. Created by Rahul Khurana. Copyright, VisionTech Camps & Classes

Drawing the Red Christmas Bell

QUICK-START FOR UNIVERSAL VLS 4.6 LASER!

An Introduction to Alice

Open the Tech Toys Scratch project. Your club leader will give you a copy of this project, or you can open it online at jumpto.cc/toys-go.

An Introduction to ScratchJr

University Libraries ScanPro 3000 Microfilm Scanner

SAVING, LOADING AND REUSING LAYER STYLES

COLORIZE A PHOTO WITH MULTIPLE COLORS

A Day in the Life CTE Enrichment Grades 3-5 mblock Robotics - Simple Programs

Project 2 - Blackjack Due 7/1/12 by Midnight

Materials Tutorial. Chapter 6: Setting Materials Defaults

Ok, we need the computer to generate random numbers. Just add this code inside your main method so you have this:

How to Create Your Own Rubik s Cube Mosaic

AutoDesk Inventor: Creating Working Drawings

A User s Guide to the Robot Virtual Worlds App RVW APP. ROBOTC Graphical Programming. Virtual Programming Challenges to Foster Computational Thinking

New Jersey Center for Teaching and Learning. Progressive Mathematics Initiative

The original image. Let s get started! The final light rays effect. Photoshop adds a new layer named Layer 1 above the Background layer.

3rd Grade. Fractions

Colorizing A Photo With Multiple Colors In Photoshop

Resize images for either 1400 or 1050 dpi for competitions.

AIM OF THE GAME GLACIER RACE. Glacier Race. Ben Gems: 20. Laura Gems: 13

LESSON ACTIVITY TOOLKIT 2.0

Add in a new ghost sprite, and a suitable stage backdrop.

DESIGN A SHOOTING STYLE GAME IN FLASH 8

Transcription:

Ready, SET, go! By Melissa Dalis Professor Susan Rodger Duke University July 2011

Overview This tutorial will teach you how to build SET, a card game whose objechve is to idenhfy as many groupings (sets) of three cards as possible. SET can be used as an early introduchon to set theory, combinatorics, randomness, probability, and other areas of higher level math. Programming concepts reinforced are events, loops, dealing with several methods, and parallel arrays (a intro to a higher- level concept called maps).

Understanding the game In our game of SET, we will have 27 cards, each with 3 features: color (red, blue or green), number (1, 2 or 3), and shape (oval, squiggle or rectangle). The goal of the game is to find as many sets as possible. A set is a collechon of 3 cards, where, in each category, all of the cards are the same or all of the cards are different.

SET Not a SET All different colors, same shape, and different numbers. Not all same or different colors. All same color, different shapes, and same number. Not all same or different shapes. All different colors, different shapes, and different numbers. Not all same or different colors.

Understanding the starhng world Click on the + sign next to cards in the object tree, and you ll see in that folder all 27 of the cards used in the game. Click on the + sign next to squares in the object tree, and you ll see in that folder the 12 spots on the table where we will put the dealt cards.

The arrays Click on world in the object tree, and go to its properhes tab. There are several lists already created. NoHce that allcards contains all 27 of the cards, and allcolors, allshapes, and allnumbers contain the 27 colors, shapes, and numbers, respechvely, that correspond to the object in the allcards array. For example, item2 in allcards is redsquig1, item2 in allcolors is red, item2 in allshapes is squig, and item2 in allnumbers is 1.

Understanding the events In the Events sechon in the top right corner, there are 27 events already set up for you, one for each card. When a player clicks on a card, we need to be able to recognize which card, color, number, shape, it is, and if this is the first, second, or third card of the set they are trying to create. Each of these events calls a helper method, which we will write to respond to the card they click.

Responding to the click Click on world in the object tree, and go to its methods tab. Click on edit next to the method called helper. NoHce that helper has 2 parameters: card and index. Since the allcolors, allshapes, and allnumbers array correspond to one another, index refers to the correct item in each of the arrays that describes card. When a player clicks on a card, we want it to turn yellow, and if he has already clicked on it, we want it to turn back to white.

Drag in an If/Else statement, and select true. Click on one of the cards in the object tree (I chose greenoval1, but it doesn t ma_er), and go to its properhes tab. Drag color onto the true, and select!= (not equal to), yellow. Drag card from the top of the method onto greenoval1. Drag card into the first Do Nothing, and select set color to, yellow.

Keeping track of the cards Since a SET contains 3 cards, we want arrays to keep track of the 3 chosen cards. Click on world in the object tree, and go to the properhes tab. Click create new variable, and name it 3Cards, make it type Object, check make a List and change List to Array. Click new item three Hmes so that you have items 0-2, and click OK. We ll add values for these later.

Create three more arrays: 3Numbers (type Number), 3Colors (type String), and 3Shapes (type String) the same way. Each should have 3 items, and you can keep the default values of 1. Create one last Number array called 3Indices that will keep track of the indices of the chosen cards in the 27- item array. Create a Number variable (not an array) named numchosen that will keep track of the number of cards the player has so far chosen for his set (will be 0, 1 or 2), and set the inihal value to 0.

Back to helper Go back to your helper method. First we want to set the numchosenth item in 3Cards to card, the actual card object we passed into the method. Drag 3Cards into the If, below the card set color line, and select set item <index> to <item>, expressions, world.numchosen, expressions, card. Now drag 3Indices below that line, and select set item <index> to <item>, expressions, world.numchosen, expressions, index.

Drag 3Numbers below that line, and select set item <index> to <item>, expressions, numchosen, and 0. Drag allnumbers (also in world s properhes) onto the 0, and select ith item from the array, expressions, index. Now drag 3Colors below that line, and select set item <index> to <item>, expressions, numchosen, default string, for now. Drag allcolors onto default string, and select ith item from the array, expressions, index. Do 3Shapes the same way.

Now since the player has chosen the card and we have accounted for it, we want to increment numchosen. Drag numchosen below the 3Shapes line, and select increment by 1. Now, if the card is already yellow, a player clicking on that card is trying to unclick it. Drag card into the Else, and select set color to, no color.

Finishing helper Since the player has unclicked the card, now we want to decrement numchosen. Drag numchosen below the no color line, and select decrement by 1. This is important: make sure the durahon of every single line in this method is 0. To do this, click more at the end of each line, durahon, 0 seconds.

Finished helper

Dealing the cards Click on world (object tree), and go to its methods. Click create new method, and name it deal. This method will deal the 12 cards at the beginning of the hand, and also refill the cards with 3 more afer a player has found a SET. Create 3 parameters for the method: index (Number) which will refer to the index of the card being dealt, refill (Boolean) which will refer to whether or not we are dealing a new hand or just refilling, and replacing (Object) which will refer to the card we re replacing in the refill case.

Choosing a random card Create a new Number variable in the method named rand. Drag rand into the method, and select set value, 0, for now. From world s funchons tab, drag random number onto the 0. Click on the purple more 3 Hmes to change the minimum to 0, maximum to 27, and integeronly to true.

If the random card has already been dealt, we need to deal another one instead. Drag a While into the method, and select true. Drag greenoval1 onto the true, and select greenoval1.isshowing. From world s properhes, drag allcards onto greenoval1, and select item item from the array, expressions, rand. Drag the rand set value line onto the clipboard to make a copy, and paste it into the While.

Moving the card to the correct spot Create a new Object variable in the method named card. Drag card to the bo_om of the method, and select set value, camera, for now. Drag allcards onto camera, and select ith item from the array, expressions, rand. Now, if the card is replacing another card, we want it to move to that card, but otherwise we want to move it to the next open square. So drag in an If/Else, and select true. Click true, and select expressions, refill.

Drag card into the first Do Nothing, and select move to, expressions, replacing. Drag card into the second Do Nothing, and select move to, camera, for now. From world s properhes, drag allsquares onto camera, and select ith item from the array, expressions, index. This is important: make sure the durahon of every single line in this method is 0 (or false). From greenoval1 s properhes tab, drag isshowing into the very end of the method, select true, and change greenoval1 to card.

Finished deal

Fixing the cards The cards begin in a weird posihon. Go to world.my first method, add a Loop, and select 27. Drag a Do together into the Loop. Drag greenoval1 into the Do together, and select 3 Hmes so that it: (1) rolls right ¼ revoluhon, (2) turns to face the camera, and (3) resizes by a factor of 0.7, and change the durahons to 0. Drag allcards onto each of the greenovals, and select ith item from array, expressions, index.

Dealing the first 12 cards Drag a Loop into the method, and select 12. From world s methods, drag deal into the Loop, and select expressions, index, false, <None> (since we re not refilling). Click play to see your random 12 cards dealt (yours will be different than mine)!

Judging the SET In world s methods, click create new method, and name it judgeset. Remember that a SET needs to have all the same or all different numbers, all the same or all different colors, and all the same or all different shapes. Create 6 new Boolean variables in the method: numberssame, numbersdiff, colorssame, colorsdiff, shapessame, and shapesdiff.

EvaluaHng the Booleans Drag in a Do together. For the numbers to be the same, the 0 th number needs to equal the 1 st number and the 2 nd number (and, by the transihve property, that would mean that the (1 st =2 nd ). Drag numberssame into the Do together, and select set value, true. Click on true, and select logic, and, true. From world s funchons, drag a==b onto the first true, and select 1, 1, and do the same for the second, for now.

From world s properhes, drag 3Numbers onto the first 1, and select ith item from the array, 0. Drag item 0 from world.3numbers onto the clipboard to make a copy, and paste it onto the other three 1 s. Change the second 0 to 1, and the last 0 to 2 so that it basically says item 0==item 1 or item 0==item 2. For all the numbers to be different we need to make sure of 3 things: item 0 doesn t equal item 1 or 2, and item 1 does not equal item 2. Now drag numbersdiff into the Do together, and select set value, true. Click on the true, and select logic, and, true. Click on the second true, and select logic, and, true.

Drag a!=b onto each of the true s, and select 1, 1. Drag 3Numbers onto the first 1, and select ith item from the array, 0. Drag item 0 from world.3numbers onto the clipboard to make a copy, and paste it onto the other five 1 s. Change the second 0 to 1, the fourth 0 to 2, the fifh 0 to 1, and the sixth 0 to 2, so it basically says item 0!= item 1 and item 0!= item 2 and item 1!= item 2.

Drag colorssame into the Do together, select true, then click on the true and select logic, and, true. Create a new String variable in the method called temp, so we can use this as a placeholder (instead of the 1) since we re working with Strings now. Drag temp onto the first true, and select ==, expressions, temp, and do the same for the second. Drag 3Colors onto the first temp, and select ith item from the array, 0. Drag that to the clipboard and paste it on the other 3 temps. Change the second 0 to 1 and the fourth 0 to 2.

Try finishing colorssame yourself (code on this slide). Try wrihng colorsdiff yourself. Write shapessame and shapesdiff the exact same way that you wrote colorssame and colorsdiff.

If it is a set That was the hardest part, good job! Now drag an If/Else into the very bo_om of the method, and select true. Click on the true, and select logic, and, true, and do this again for the second true. Drag numberssame onto the first true, and select logic, or, expressions, numbersdiff. Change the second true to colorssame or colorsdiff, and the third true to shapessame or shapesdiff.

CounHng the number of SETs Click Add Objects, and create a 3D Text object that says Sets: 0. In the object tree, rename 3D Text setstext. Make it smaller, and move it to the top lef corner. Change its color to black if you want to in its properhes tab. In the properhes tab, click create new variable, name it numsets, and set its type to Number and inihal value to 0. Click Done.

Back to judging Go back to your judgeset method. Drag the numsets variable you just made into the If/ Else s first Do Nothing, and select increment by 1. From settext s properhes, drag text below the increment line, select other, and type Sets:. From world s funchons, drag a joined with b onto Sets:, and select default string. Also from world s funchons, drag what as a string onto default string, and select camera. Also from world s funchons, drag int a as a string onto camera, and select expressions, numsets. Change the durahon to 0.

If it s a set, we want the 3 cards to disappear and to replace them with 3 new ones. Drag a Loop below the setstext line, and select 3. From settext s properhes tab, drag isshowing into the Loop, and select false. Drag settext s color property into the Loop, and select no color. From world s properhes, drag 3Cards onto both settext lines, and select ith item from array, expressions, index, and change durahon to 0. From world s methods, drag deal into the Loop, and select expressions, index, true, <None>. Drag 3Cards onto the <None>, and select ith item from array, expressions, index.

If not a set Drag a Loop into the Else, and select 3. From the object tree, drag setstext into the Loop, and select set color to, no color. Drag 3Cards onto setstext, and select ith item from array, index, and change the durahon to 0. From world s properhes, drag numchosen into the very bo_om of the method, and select set value, 0.

Create a 3D text object, and type Not a SET! Change the color to black, and move and resize it to the middle of the screen. Move it forward so it will definitely be in front of the cards. In the object tree, rename the 3D text to nosettext. We only want this to show up when the 3 cards aren t a SET, so in nosettext s properhes, change isshowing to false. Now drag isshowing into judgeset, right before and right afer the Loop you just made. The first isshowing should be true and the second should be false.

When to judge the set When numchosen is 3, we want to run judgeset to evaluate whether or not the 3 selected cards form a set. In the Events sechon in the top right corner, click create new event and select While something is true (your event will show up at the bo_om). From world s properhes, drag numchosen onto the <None>, and select ==, 3. From world s methods, drag judgeset into Begin.

Extensions Create a billboard with instruchons to display at the beginning of the game. Create a Hmer that counts down from 100 (and pauses for the instruchons if you do add instruchons). Create different levels where the player has less and less Hme to find a set.