C-cards Using paper and scissors to understand Computer Science Andrea Valente Aalborg University in...

Post on 29-Jan-2016

215 views 0 download

Tags:

Transcript of C-cards Using paper and scissors to understand Computer Science Andrea Valente Aalborg University in...

C-cardsUsing paper and scissors to understand Computer Science

Andrea Valente

Aalborg University in EsbjergDenmark

Home: www.cs.aue.auc.dk/~avEmail: av@cs.aue.auc.dk

The problem

Define an educational tool for teaching Computer Science to young children (8 to 12 years old) and students without a solid mathematical background.

1! = 1n! = n * (n-1)!

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

A solution: c-cards

● Peg-source● Peg-pit● Peg

● Cross● East turn● West turn● Confluence

● Switch

Behaviour and circuitsCards can be connected to build circuits.

Pegs move across cards, from port to port, one at the time: sequential execution model.

Behaviour and circuits (cont.)

This is a time-reversible boolean not gate!

position = value

change positions =

computation

Behaviour and circuits (cont.)

In the shape (on the left) the In source card is defined by the pattern(white.black)*

which means: a white peg, then a black and so on.The implemented circuit (right) separates white pegs from black ones.

- Implementation -- Specification -

Behaviour and circuits (cont.)

The 2 states of a switch card.

NOTE: All pegs are identical!

Semantics

...

A card circuit is a graph of ports, each one possibly containing one peg.

Graph-rewriting rules are simple to explain and support our visual and physical metaphor for computation.

All rules work up-to card rotation and are deterministic: they are triggered by the presence of pegs, and depend upon the current state of cards.

Exercise 1

Suppose now we want to make a more complex exercise, working with a source defined by

(white.slashed.black)*

The resulting circuit will have three pits, in which pegs of the same color will accumulate: the first (western) pit will receive all white pegs, the second all the slashed ones and the black pegs will stop at the third.

The (white.black) circuit could be a starting point for the definition of this one!

Exercise 1: a little help

switch

switch switch1. white 2. slash

3. black

4. white (2)

?

1.3.

2.4.

Exercise 1: solution

a MACRO card!

ResultWe can count modulo n.

Macro & custom cards

We can map the whole circuit it into a single large card, a macro-card, preserving the circuit's behaviour.Source cards became input ports, while pits are turned into output ports; arrows (and some informal annotations about actions to be performed) will express the high-level behaviour of the large card.

It is also possible to define new custom cards behaving as a whole circuit; the geometry of the original circuit is hard to preserve. Students can easily define their own cards.

Let's make a new card!The random card

An extension to the basic deck is the random card: a peg entering this card will be sent out from the left or the right, with {1/2,1/2} probability distribution.

This is the non-deterministic version of the switch card.

Exercise 2

It is easy to build a circuit that divides white markers from black ones, with 50% probability of making an error. It is the random equivalent of the white.black circuit discussed before.

Is it possible to have a probability distribution of { 1/4 , 3/4 } ?

Exercise 2: solution

Result

Using two or more of these cards in cascade, we can have a peg-source implementing almost every probability distribution needed.

rnd

rnd rnd1/4 1/41/4 1/4

1/4 3/4

Exercise 2: the circuitNew custom cards!

Channels, errors and redundancy

- Shannon's binary symmetric channel

- Perfect channel

Work in progress● what is the computational power of c-cards ?

● what about a parallel semantics ?

● Turing Machines / Cellular Automata ?

● c-cards in LOGO / StarLogo ?

● a 3D version ?

● more exercises ?

● work with a class of children ...

Conclusions

Related work and bibliography➔ Fredkin, E. and Toffoli, T. (1982). Conservative logic. International Journal of Theoretical Physics, 21(3/4): 219–53.➔ Milner, R. (1989). Concurrency and Communication. Prentice Hall.➔ Gardner, P. (1999). Graphical presentations of interactive systems. Submitted for publication.➔ Helen Sharp, Mary Lynn Manns, Phil McLaughlin, Maximo Prieto and Mahesh Dodani (1996). Pedagogical patterns – successes in teaching object technology. ACM SIGPLAN Notices, Vol. 31(12), December 1996, pp. 18-21.➔ McNerney, T. (2000). Tangible Programming Bricks: An Approach to Making Programming Accessible to Everyone. Ph.D. Thesis.

C-cards is a card game with formal rules, and also an educational tool for teaching computer science to young students.

Students can create and manipulate their own computing machines, reason about design and implementation of card circuits.

Probability and information can be discussed on a concrete basis using a simple extension of the standard card deck. Experiments can be set up to understand redundancy and transmission errors.

Extras!

● Gaussian distribution

- For teachers mostly! -

Gaussian distribution

rnd rnd

1/2

1/4

1/4 2/4 1/4

rnd

Gaussian distribution (cont.)

rnd

rnd rnd

rnd

rnd

1/2

1/4

1/8

1/8 3/8 3/8 1/8

rnd

Gaussian distribution (cont.)

rnd

rnd rnd

rnd

rnd

4/16 6/16 4/16 1/16

rnd

rnd rnd rnd rnd

1/16

Gaussian distribution (cont.)

rnd

rnd rnd

rnd

rnd

5/32 10/32 10/32 5/32

rnd

rnd

rnd rnd

rnd

rnd

rnd

rnd

rnd

rnd

1/32 1/32

Gaussian distribution (cont.)

/ 1 / 2 / 4 / 8 / 16 / 32 / 64

11 1

1 2 11 3 3 1

1 4 6 4 11 5 10 10 5 1

1 ... ... ... ... ... ... 1

...