Review Recursion Call Stack. Two-dimensional Arrays Visualized as a grid int[][] grays = {{0, 20, 40}, {60, 80, 100}, {120, 140, 160}, {180, 200, 220}};

Slides:



Advertisements
Similar presentations
EXAMPLES (Arrays). Example Many engineering and scientific applications represent data as a 2-dimensional grid of values; say brightness of pixels in.
Advertisements

Two-Dimensional Arrays Chapter What is a two-dimensional array? A two-dimensional array has “rows” and “columns,” and can be thought of as a series.
Image Processing … computing with and about data, … where "data" includes the values and relative locations of the colors that make up an image.
Game of Life Rules and Games Linh Tran ECE 573. What is Life? Life is just one example of a cellular automaton, which is any system in which rules are.
1 The Game of Life Supplement 2. 2 Background The Game of Life was devised by the British mathematician John Horton Conway in More sophisticated.
Cellular Automata (Reading: Chapter 10, Complexity: A Guided Tour)
1 Chapter 13 Artificial Life: Learning through Emergent Behavior.
CELLULAR AUTOMATA Derek Karssenberg, Utrecht University, the Netherlands LIFE (Conway)
CS Summer 2005 Final class - July 1st Assorted fun topics in computability and complexity.
1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 8 focuses on: array declaration and use passing arrays and array.
CS305j Introduction to Computing Two Dimensional Arrays 1 Topic 22 Two Dimensional Arrays "Computer Science is a science of abstraction -creating the right.
© The McGraw-Hill Companies, 2006 Chapter 16 Two-dimensional arrays.
Cellular Automata and Game Design By Pete Strader.
Parallelization: Conway’s Game of Life. Cellular automata: Important for science Biology – Mapping brain tumor growth Ecology – Interactions of species.
Introduction Computational Challenges Serial Solutions Distributed Memory Solution Shared Memory Solution Parallel Analysis Conclusion Introduction: 
ARRAYS EXAMPLE: THE GAME OF LIFE CITS Scope of this lecture The Game of Life Implementation Performance Issues References:
Great Video Game Crash of Napoleon’s Russian Campaign,
Lecture 8 – Stencil Pattern Stencil Pattern Parallel Computing CIS 410/510 Department of Computer and Information Science.
CS 484 – Artificial Intelligence1 Announcements Lab 4 due today, November 8 Homework 8 due Tuesday, November 13 ½ to 1 page description of final project.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
CELLULAR AUTOMATA RULES GENERATOR FOR MICROBIAL COMMUNITIES CALIFORNIA STATE UNIVERSITY, SAN BERNARDINO SCHOOL OF COMPUTER SCIENCE & ENGINEERING By Melissa.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
2D-Arrays Quratulain. Learning Objectives Two-dimensional arrays Declaration Initialization Applications.
Introduction  Per the project description: “Conway's Game of Life is a cellular automaton operating on a grid of rectangles, infinite in both directions.”
1 Chapter 13 Artificial Life: Learning through Emergent Behavior.
CHAPTER: 12. Array is a collection of variables of the same data type that are referenced by a common name. An Array of 10 Elements of type double.
The Game of Life A simulation of "life". From simple rules, complex behavior arises Rules –A cell that is alive and has fewer than two live neighbors dies.
Introduction to Lattice Simulations. Cellular Automata What are Cellular Automata or CA? A cellular automata is a discrete model used to study a range.
Topic 26 Two Dimensional Arrays "Computer Science is a science of abstraction -creating the right model for a problem and devising the appropriate mechanizable.
Cellular Automata Spatio-Temporal Information for Society Münster, 2014.
Parallel Programming 0024 Spring Semester 2010 May 6, 2010.
1 Data Structures CSCI 132, Spring 2014 Lecture 4 Implementing Life.
Programming Principles Chapter 1. Objectives Discuss the program design process. Introduce the Game of Life. Discuss object oriented design. – Information.
עקרונות תכנות מונחה עצמים תרגול 6 - GUI. סיכום ביניים GUI:  Swing  Basic components  Event handling  Containers  Layouts.
Multidimensional Arrays. 2 Two Dimensional Arrays Two dimensional arrays. n Table of grades for each student on various exams. n Table of data for each.
Homework 9 Due ( M & T sections ) ( W & Th sections ) at midnight Sun., 11/3 Mon., 11/4 Problems
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
A Variation on Conway’s Game of Life Winston Lee EPS 109.
Clicker questions 11/14/13 CSE 1102 Fall A. Composite B. Holder C. Proxy D. Factory E. Impossible to tell from diagram In this example, we want.
Cellular Automata Introduction  Cellular Automata originally devised in the late 1940s by Stan Ulam (a mathematician) and John von Neumann.  Originally.
A few of the people involved and what they’ve done.
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
David Squeri CELLULAR AUTOMATON. A cellular automaton is an array of cells that switch on or off depending on whether other cells are on or off. “Rules”
Week 9 - Monday.  What did we talk about last time?  Method practice  Lab 8.
Conway’s Game of Life Jess Barak Game Theory. History Invented by John Conway in 1970 Wanted to simplify problem from 1940s presented by John von Neumann.
Week 9 - Wednesday.  What did we talk about last time?  2D arrays  Queen attacking pawn example  Started Game of Life.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Arrays Chapter 7. MIS Object Oriented Systems Arrays UTD, SOM 2 Objectives Nature and purpose of an array Using arrays in Java programs Methods.
Test Review. General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write.
Programming for Art: Arrays – 2D ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 16 Fall 2010.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: Graphs Data Structures.
Two Dimensional Arrays. Students will be able to: code algorithms to solve two- dimensional array problems. use 2-D arrays in programs. pass two-use 2-D.
C++ Array 1. C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used.
Clue Paths. Memory Alias Review Remember that it’s possible for two unique variables to point to the same memory location myList MyClass mc 0x100 someFn.
Chapter 9 Introduction to Arrays Fundamentals of Java.
1 A Case Study: Percolation Percolation. Pour liquid on top of some porous material. Will liquid reach the bottom? Applications. [ chemistry, materials.
2.4 A Case Study: Percolation Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008.
Arrays. 2 Why do we care (about arrays)? What if you have a whole bunch of cars (or aliens or balls or ???) bouncing around the screen? How do we keep.
Jeopardy Topic 1Topic Q 1Q 6Q 11Q 16Q 21 Q 2Q 7Q 12Q 17Q 22 Q 3Q 8Q 13Q 18Q 23 Q 4Q 9Q 14Q 19Q 24 Q 5Q 10Q 15Q 20Q 25.
Practical Session 9 Computer Architecture and Assembly Language.
Task 1 and Task 2. Variables in Java Programs Variables start with lower case letter Variables are descriptive of what they store Variables are one word.
Illustrations of Simple Cellular Automata
Week 9 - Monday CS 121.
עקרנות תכנות מונחה עצמים
Multidimensional Arrays
Multidimensional Arrays
Computer Architecture and Assembly Language
Computer Architecture and Assembly Language
Trigonometry & Random March 2, 2010.
Cave generation with cellular automata
Presentation transcript:

Review Recursion Call Stack

Two-dimensional Arrays Visualized as a grid int[][] grays = {{0, 20, 40}, {60, 80, 100}, {120, 140, 160}, {180, 200, 220}}; int[][] grays= new int[4][3];

Processing 2D Arrays Need two indices, one for the rows and one for the columns. int[][] grays = {{0, 20, 40}, {60, 80, 100}, {120, 140, 160}, {180, 200, 220}}; grays[2][1] = 255; grays[2][3] = 0;

Lengths of 2D Arrays int[][] grays = new int[80][100]; println(grays.length); println(grays[0].length);

Cellular Automata Cell Two States 1. On 2. Off Neighborhood Cell states evolve over time according to a predefined set of rules. A regular grid of Cells

Sample Set of Rules – Conway's Game of Life 1.Any live cell with fewer than two live neighbors dies, as if caused by under-population. 2.Any live cell with two or three live neighbors lives on to the next generation. 3.Any live cell with more than three live neighbors dies, as if by overcrowding. 4.Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction. An example of "Emergence"

Interesting Patterns – Conway's Game of Life

current next Top-level procedure 1.Draw the current grid 2.Advance game by applying rules to all cells of current and filling next 3.Swap current and next grid Top-level procedure 1.Draw the current grid 2.Advance game by applying rules to all cells of current and filling next 3.Swap current and next grid

int N = 5; boolean[] cell = new boolean[N]; false cell false  One-dimensional array

int N = 5; boolean[][] cell = new boolean[N][N]; cell  Two-dimensional array … an array of arrays false

cell false true false int N = 5; boolean[][] cell = new boolean[N][N]; cell[1][2] = true;

current: cell[r][c][0] next: cell[r][c][1] // 3-Dimensional Array int N = 50; boolean[][][] cell = new boolean[N][N][2]; cell[1][2][0] = true;

Add the necessary lines of code within setup() to fill the vals array with random numbers of your choosing. Your implementation must use for loops. float[][] vals; void setup() { vals = new float[20][300]; // Add your code here } // Closing brace for setup()

float[][] vals; void setup() { vals = new float[20][300]; for (int i=0; i<20; i++) { println( vals[i].length ); // What is going on here? }

Ragged Arrays int[][] numbers = { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 3, 5, 7, 9}, {0, 2, 4, 6, 8, 10}, {2, 3, 5, 7}, {0}, };

float[][] grays = new float[100][100]; int cellSize = 5; void setup() { size(500, 500); for (int i=0; i<grays.length; i++) { for (int j=0; j<grays[i].length; j++) { grays[i][j] = int(random(255)); } for (int i=0; i<grays.length; i++) { for (int j=0; j<grays[i].length; j++) { fill(grays[i][j]); pushMatrix(); translate(j*cellSize, i*cellSize); rect(0, 0, cellSize, cellSize); popMatrix(); } Fill a 2D array with data and draw it to the sketch as grayscale levels.

Challenge Modify the previous example to plot black squares whenever both the row and column of a cell are even.