Background
jLogo Programming
- Commanding a Turtle
- Pseudocode
- Adding New Commands
- Iteration & Animation
- Hierarchical Structure
- Procedure Inputs
- Primitive Operators
- Defining Operators
- Words & Sentences
- User Interface Events
- What If? (Predicates)
- Recursion
- Local Variables
- Global Variables
- Word/Sentence Iteration
- Mastermind Project
- Multiple Turtles
- Arrays
Java
- A Java Program
- What's a Class?
- Extending Existing Classes
- Types
- Turtle Graphics
- Control Flow
- User Interface Events
Appendices
Lastly
Arrays
Introduction
Arrays are indexed collections of data.
In this lesson, you will learn:
- What an array is and why they are useful,
- How to create an array,
- How to put something into and array, and
- How to access something in the array.
The Game of Life
John Conway's Game of Life is an example of Cellular Automaton.
The "Game of Life" is played on a grid. The squares of the grid are called cells. A cell that is alive is colored in. The rules for Life are simple. They are:
- In order for a cell to remain alive, it must have two or three neighbors.
- If a live cell has less than two neighbors, it dies (loneliness).
- If a live cell has more than three neighbors, it dies (over-crowdedness).
- If an empty cell has exactly two neighbors, it comes to life.
A cell's neighbors are the eight cells which surround it (to its north, northeast, east, etc...).
Life Applet
Here is a Java applet that implements a subset of the Game of Life. Draw some patterns by clicking the left mouse button on squares to bring them to life. Then click on the [Step] button to watch what happens as the rules are applied in one cycle of Life.
Commands for Working With Arrays
| Name | Input(s) | Description |
| ARRAY | size | Outputs an array of size members, each of which is initially an empty sentence. Size must be a positive integer. |
| ITEM | index array |
Outputs the indexth member of array. |
| SETITEM | index array value |
Replaces the indexth member of array with value. | |
Summary
Go to the Table of Contents
On to A Java Program