Assignment. Example. is surrounded by exactly 3 coloured cells.

Vergelijkbare documenten
SAMPLE 11 = + 11 = + + Exploring Combinations of Ten + + = = + + = + = = + = = 11. Step Up. Step Ahead

The colour of a pixel in a bit map picture can be presented in different ways. For this assignment, we distinguish two categories:

After that, the digits are written after each other: first the row numbers, followed by the column numbers.

Calculator spelling. Assignment

(1) De hoofdfunctie van ons gezelschap is het aanbieden van onderwijs. (2) Ons gezelschap is er om kunsteducatie te verbeteren

MyDHL+ Van Non-Corporate naar Corporate

The genesis of the game is unclear. Possibly, dominoes originates from China and the stones were brought here by Marco Polo, but this is uncertain.

The first line of the input contains an integer $t \in \mathbb{n}$. This is followed by $t$ lines of text. This text consists of:

CHROMA STANDAARDREEKS

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE. Toets Inleiding Kansrekening 1 8 februari 2010

Add the standing fingers to get the tens and multiply the closed fingers to get the units.

Classification of triangles

L.Net s88sd16-n aansluitingen en programmering.

i(i + 1) = xy + y = x + 1, y(1) = 2.

Engels op Niveau A2 Workshops Woordkennis 1

Chromosomal crossover

Four-card problem. Input

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

L.Net s88sd16-n aansluitingen en programmering.

Christmas party. Preparation. Assignment

Preschool Kindergarten

ALGORITMIEK: answers exercise class 7

Daylight saving time. Assignment

Ontpopping. ORGACOM Thuis in het Museum

Genetic code. Assignment

Quality requirements concerning the packaging of oak lumber of Houthandel Wijers vof ( )

Chaos uit de automaat

z x 1 x 2 x 3 x 4 s 1 s 2 s 3 rij rij rij rij

Assignment. Example. >>> result(votes2008) (358, 180)

04/11/2013. Sluitersnelheid: 1/50 sec = 0.02 sec. Frameduur= 2 x sluitersnelheid= 2/50 = 1/25 = 0.04 sec. Framerate= 1/0.

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE. Toets Inleiding Kansrekening 1 7 februari 2011

Hidato. Assignment. A hidato (left) and its solution (right).

Opgave 2 Geef een korte uitleg van elk van de volgende concepten: De Yield-to-Maturity of a coupon bond.

Example. >>> rowkey('u') 1 >>> rowkey('a') 2 >>> rowkey('z') 3 >>> rowkey('?')

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

Speleology. Assignment

B1 Woordkennis: Spelling

Travel Survey Questionnaires

Introductie in flowcharts

Settings for the C100BRS4 MAC Address Spoofing with cable Internet.

Solar system. Assignment

Understanding and being understood begins with speaking Dutch

8+ 60 MIN Alleen te spelen in combinatie met het RIFUGIO basisspel. Only to be played in combination with the RIFUGIO basicgame.

ANGSTSTOORNISSEN EN HYPOCHONDRIE: DIAGNOSTIEK EN BEHANDELING (DUTCH EDITION) FROM BOHN STAFLEU VAN LOGHUM

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

Chess board distance $\max( x_0-x_1, y_0-y_1 )$

Country recognition. Assignment

Meetkunde en Lineaire Algebra

Group work to study a new subject.

The 15 puzzle invented by Noyes Chapman consisted of a $4 \times 4$ grid of which the field are numbered from 1 to 15.

MyDHL+ ProView activeren in MyDHL+

Demultiplexing reads FASTA format genome sequencing reads run

General info on using shopping carts with Ingenico epayments

VOORSTEL TOT STATUTENWIJZIGING UNIQURE NV. Voorgesteld wordt om de artikelen 7.7.1, 8.6.1, en te wijzigen als volgt: Toelichting:

Chapter 4 Understanding Families. In this chapter, you will learn

My Inspiration I got my inspiration from a lamp that I already had made 2 years ago. The lamp is the you can see on the right.

2019 SUNEXCHANGE USER GUIDE LAST UPDATED

Esther Lee-Varisco Matt Zhang

Firewall van de Speedtouch 789wl volledig uitschakelen?

AN URBAN PLAYGROUND AFSTUDEERPROJECT

20 twenty. test. This is a list of things that you can find in a house. Circle the things that you can find in the tree house in the text.

Academisch schrijven Inleiding

Find Neighbor Polygons in a Layer

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Luister alsjeblieft naar een opname als je de vragen beantwoordt of speel de stukken zelf!

Zo werkt het in de apotheek (Basiswerk AG) (Dutch Edition)

Meetkunde en Lineaire Algebra

Davide's Crown Caps Forum

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

The mitochondrial genome has bases and codes for 37 genes: 13 polypeptides, 22 trnas and 2 ribosomal RNAs.

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

DALISOFT. 33. Configuring DALI ballasts with the TDS20620V2 DALI Tool. Connect the TDS20620V2. Start DALISOFT

Reading comprehension: The Tropical Rainforest

Functioneel Ontwerp / Wireframes:

TECHNISCHE UNIVERSITEIT EINDHOVEN Faculteit Wiskunde en Informatica. Examination 2DL04 Friday 16 november 2007, hours.

DBMS. DataBase Management System. Op dit moment gebruiken bijna alle DBMS'en het relationele model. Deze worden RDBMS'en genoemd.

Tentamen Objectgeorienteerd Programmeren

Example. >>> airmap = Map() >>> airmap.eruption(0, 0) >>> airmap.ashcloud {(0, 0)} >>> airmap.spread()

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE. Toets Inleiding Kansrekening 1 22 februari 2013

Exercise P672 Lightweight Structures. A.P.H.W. Habraken. Report

APPROACHING THE FAMILY

Buzzword bingo Buzzword bingo bul shit bingo

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Homework assignment 7 (Intensionality)

Online Resource 1. Title: Implementing the flipped classroom: An exploration of study behaviour and student performance

Handleiding Zuludesk Parent

!!!! Wild!Peacock!Omslagdoek!! Vertaling!door!Eerlijke!Wol.!! Het!garen!voor!dit!patroon!is!te!verkrijgen!op! Benodigdheden:!!

RECEPTEERKUNDE: PRODUCTZORG EN BEREIDING VAN GENEESMIDDELEN (DUTCH EDITION) FROM BOHN STAFLEU VAN LOGHUM

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Het beheren van mijn Tungsten Network Portal account NL 1 Manage my Tungsten Network Portal account EN 14

Illustrator Tutorial - How to Create a Watch

Fischer Random (

Meetkunde en Lineaire Algebra

Earth Similarity Index

Global TV Canada s Pulse 2011

Eye Feature Detection Towards Automatic Strabismus Screening

Nieuwsbrief NRGD. Editie 11 Newsletter NRGD. Edition 11. pagina 1 van 5.

CBSOData Documentation

1a. We werken het geval voor het tandenpoetsen uit. De concepten zijn (we gebruiken Engelse termen en afkortingen):

Transcriptie:

Game of Life The Game of Life, is a game devised by the British mathematician John Horton Conway in 1970. The game made its first public appearance in the October 1970 issue of Scientific American, in Martin Gardner's "Mathematical Games" column. This type of game is an example of a cellular automaton, and differs from other games like Monopoly, Risk or chess, in the sense that there are no players and that one cannot win or lose. The game board consists of a rectangular grid, and can thus be represented by a list of lists in a computer program. After a number of cells of the grid are colored, the game begins. Game of Life goes through several "generations". In order to determine whether a cell is colored in the next generation or not, a number of rules are applied on the basis of the status (alive or dead) of the neighbours. Each cell in the grid has up to 8 neighbours, except the cells at the edge of the grid that have less than 8 neighbours. Conway has experimented with a lot with different sets of rules to find a good balance. With the wrong rules more squares (in Game of Life called "cells")would be coloured ('born') than white ("dead ") so the whole board ('grid') would be coloured. Or vice versa: there are so many fields death that the whole area goes white. The rules most commonly used are the following: Any live cell with two or three live neighbours lives on to the next generation, like the middle cell in the image below. In this example, the center cell remains coloured, because the cell is surrounded by two other coloured cells. Any live cell with more than three live neighbours dies, as if by overcrowding (that means the cel goes white). Any live cell with fewer than two live neighbours diesas well, as if caused by under-population. This is illustrated in the figure below. In this example, the center cell dies, because the cell is surrounded by more than 3 or less than 2 coloured cells. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction, as shown in the figure below. In this example, the center cell is coloured, because the cell

is surrounded by exactly 3 coloured cells. All of these transformations are carried out simultaneously for all the cells. The art of the game is to imagine patterns that exhibit particular behaviour. There are stable patterns (simplest example: a block of four). There are patterns that go back and forth between two or more states. There are patterns that eventually disappear or change into a stable pattern. Interesting the patterns are those that move, such as the glider and the glider gun. Assignment 1. Write a function showgeneration that prints the state of a given generation. This function has one required argument: a list of lists that represents a rectangular grid. The nested lists each have the same length and only contain Boolean values. A generation is thus represented by a list of rows, and each row itself is represented through a list. At position $n$ there is True if the cell in column $n$ in that row is alive. Otherwise there is False. The living cells are represented by the letter X when printing, and the dead cells are represented by the letter O (not the number zero!!). 2. Write a function numberofneighbours that returns the number of live neighbours of a cell for a given generation and a given cell. This function has three mandatory arguments: the first argument is the given generation, the second argument the row and the third argument the column of the cell of which the neighbours are sought. 3. Use the numberofneighbours function to write nextgeneration, a function that returns the next generation of a given generation. This new generation is presented in the same way as the given generation, namely, as a list of lists. The given generation is passed as an argument to the function, and is not changed by the function. The example below illustrates how this function should be used. Example >>> generation = [[True] + [False] * 7 for _ in range(6)] >>> showgeneration(generation) >>> numberofneighbours(generation, 0, 0) 1 >>> numberofneighbours(generation, 1, 1) 3 >>> numberofneighbours(generation, 2, 2) 0 >>> next = nextgeneration(generation)

>>> next = nextgeneration(next) >>> next = nextgeneration(next) >>> next = nextgeneration(next) Game of Life is een spel dat in 1970 werd uitgevonden door de Britse wiskundige John Conway. Het werd gepubliceerd in Scientific American onder de rubriek Mathematical Games van Martin Gardner. Deze spelvorm is een voorbeeld van een cellulaire automaat en wijkt af van andere spelletjes zoals monopoly, risk of schaken, in die zin dat er geen spelers zijn en dat men niet echt kan winnen of verliezen. Het spelbord bestaat uit een rechthoekig rooster, en kan dus in een computerprogramma worden voorgesteld door een lijst van lijsten. Nadat een aantal cellen van het rooster is ingekleurd, begint het spel. Game of Life doorloopt verschillende 'generaties'. Om te bepalen of een cel in de volgende generatie gekleurd is of juist niet, wordt er een aantal regels toegepast aan de hand van de status (levend of dood) die de buurcellen hebben. Hierbij heeft elke cel in het rooster maximaal 8 buurcellen, behalve de cellen op de rand van het rooster die minder dan 8 buren hebben. Conway heeft veel geëxperimenteerd met verschillende reeksen regels om een goede balans te vinden. Met de verkeerde regels zouden namelijk meer velden (in Game of Life 'cellen'

genoemd) gekleurd ('geboren') dan wit ('dood') worden, waardoor het hele hokjesveld ('rooster') gekleurd wordt. Of andersom: er gaan zoveel velden dood dat het hele gebied wit wordt. De meest gebruikte regels zijn de volgende: Als een levende cel door 2 of 3 levende buurcellen omgeven wordt, blijft deze cel ook in de volgende generatie levend, zoals de middelste cel in de onderstaande afbeelding. In dit voorbeeld blijft de middelste cel gekleurd, want de cel wordt omgeven door 2 andere gekleurde cellen. Als een levende cel door 4 of meer levende buurcellen omgeven wordt, dan gaat deze cel dood door overbevolking (dat wil zeggen, de cel wordt wit). Als een levende cel door minder dan twee levende buurcellen omgeven wordt, gaat deze cel ook dood, maar dan door eenzaamheid. Dit wordt geïllustreerd in de onderstaande afbeelding. In dit voorbeeld gaat de middelste cel dood, want de cel wordt door meer dan 3 of minder dan 2 gekleurde cellen omgeven. Als een dode cel wordt omgeven door precies 3 levende buurcellen, dan wordt deze dode cel in de volgende generatie levend ('geboren'), zoals aangegeven in de afbeelding hieronder. In dit voorbeeld wordt de middelste cel gekleurd, want de cel wordt door exact 3 gekleurde cellen omgeven. Al deze transformaties geschieden gelijktijdig voor alle cellen. De kunst van het spel is patronen te bedenken die bijzonder gedrag vertonen. Er zijn stabiele patronen (eenvoudigste voorbeeld: een blokje van vier). Er zijn patronen die heen en weer gaan tussen twee of meer standen. Er zijn patronen die op den duur verdwijnen of veranderen in een stabiel patroon. Interessant zijn de patronen die zich verplaatsen, zoals de glider en de glider gun. Opgave 1. Schrijf een functie toongeneratie die de toestand van een gegeven generatie afdrukt. Deze functie heeft één verplicht argument: een lijst van lijsten die een rechthoekig rooster voorstelt. De geneste lijsten hebben allemaal dezelfde lengte en bevatten enkel Booleaanse waarden. Een generatie wordt dus voorgesteld door een lijst van rijen, waarbij elke rij zelf ook door een lijst wordt voorgesteld. Op positie $n$ staat er True als de cel op kolom $n$ in die rij leeft. Anders staat er False. De levende cellen worden bij het afdrukken voorgesteld door de letter X en de dode cellen worden voorgesteld door de letter O (niet het cijfer nul!!).

2. Schrijf een functie aantalburen die voor een gegeven generatie en een gegeven cel teruggeeft hoeveel levende buren die cel heeft. Deze functie heeft drie verplichte argumenten: het eerste argument is de gegeven generatie, het tweede argument de rij en het derde argument de kolom van de cel waarvan de buren worden opgevraagd. 3. Gebruik de functie aantalburen om een functie volgendegeneratie te schrijven, dat de volgende generatie teruggeeft voor een gegeven generatie. Deze nieuwe generatie wordt op dezelfde manier voorgesteld als de gegeven generatie, namelijk als een lijst van lijsten. De gegeven generatie wordt als argument aan de functie doorgegeven, en wordt door de functie ook niet gewijzigd. Onderstaand voorbeeld illustreert hoe deze functie moeten kunnen gebruikt worden. Voorbeeld >>> generatie = [[True] + [False] * 7 for _ in range(6)] >>> toongeneratie(generatie) >>> aantalburen(generatie, 0, 0) 1 >>> aantalburen(generatie, 1, 1) 3 >>> aantalburen(generatie, 2, 2) 0 >>> volgende = volgendegeneratie(generatie) >>> volgende = volgendegeneratie(volgende) >>> volgende = volgendegeneratie(volgende) >>> volgende = volgendegeneratie(volgende)