Fun Stuff

 

Home
Baby Pictures
Cathy Before Tom
Cebuano
First Trip to Cebu
Friends and Family
Fun Stuff
Immigration Timeline
Interstellar Message
Life in Houston
Links
Reviews
Second Trip to Cebu
Third Trip to Cebu
Tom Before Cathy
Trip to Grand Canyon
Trip to Niagara Falls
Wedding in Cebu
Wedding in Houston
What's New?

This page contains some fun online programs written by Tom.  Click on the various links below in order to activate the programs.

Cellular Automaton: LIFE

Cellular automata are discrete mathematical models involving a grid of cells with each cell being in one of a finite number of states.  The cells are advanced in time discretely from time step N to time step N + 1 according to a specified set of transition rules.  The most famous cellular automaton is called LIFE and it was invented by the British mathematician John Horton Conway in 1970.  In LIFE the cells are squares in a planar grid.  Each cell may be in one of two states: alive or dead.  Each cell has 8 neighbors.  The transition rules are as follows:
If a cell is dead at time step N then it remains dead at time step N + 1 unless exactly 3 of its neighbors are living
If a cell is alive at time step N then it remains alive at time step N + 1 if 2 or 3 of its neighbors are living.  Otherwise it dies.

The following programs implement the LIFE cellular automaton by representing living cells by the color blue and dead cells by the color white.  They differ in the size of the grid and in the various initial patterns that can be selected.  In order to start the cellular automaton select an initial pattern in the drop-down list and then click the run button.

LIFE on a 21 x 21 grid
LIFE on a 51 x 51 grid
LIFE on a 101 x 101 grid

 

Cellular Automaton: LOOPS

Chris Langton created the LOOPS cellular automaton in the 1980's as a demonstration of artificial life.  LOOPS has 8 different states for the spatial cells which are defined as follows:
State Color Description
0 white background cell
1 red core cell (all interior cells are set to this state when the organism dies)
2 blue sheath cell (functions as the skin of the organism)
3 magenta bonder cell (bonds the tip of the pseudopod back to the body of the organism; also used to make a left turn)
4 yellow turn gene cell (causes the growing pseudopod to turn left)
5 brown dissolver cell (dissolves the connection between the child organism and the parent organism)
6 cyan messenger cell (causes a new pseudopod to begin growing)
7 green straight gene cell (causes the pseudopod to grow straight)

The organism extends a pseudopod out which makes three left turns and then reconnects back to the body.  Once the pseudopod reconnects the dissolver cell dissolves the connection between the child organism and the parent organism.  A messenger cell starts the growth of the new pseudopod.  Once an organism is totally surrounded by neighbors on all four sides it dies (i.e., all of its internal cells revert to the core state) and no further reproduction is possible.  The transition rules involve the four nearest neighbors to a cell (i.e., above, below, to the left, and to the right).  The following table shows a timeline of events for the LOOPS cellular automaton:

Time step # Living Organisms # Dead Organisms Description
0 1 0 start (pseudopod of length 4 is facing to right)
30 1 0 beginning of first left turn of pseudopod
65 1 0 beginning of second left turn of pseudopod
100 1 0 beginning of third left turn of pseudopod
120 1 0 tip of pseudopod touches back to its arm
126 1 0 dissolver and messenger cells created
129 1 0 dissolver separates child organism from parent organism and turns into a messenger cell
148 1 0 original organism regrows a pseudopod of length 4
152 2 0 child organism grows a pseudopod of length 4
303 4 0  
434 3 1 first dead organism (the one to the right of the original organism)
454 7 1  
605 10 5  

The following programs implement the LOOPS cellular automaton.  They differ in the size of the grid only.  In order to start the cellular automaton click the run button.

LOOPS on a 50 x 50 grid
LOOPS on a 100 x 100 grid

 

Simulated Evolution

The following program simulates evolution on a 50 x 50 planar grid.  Each spatial cell must be in one of the following four states:
empty (white)
food (green)
poison (red)
organism (blue)

Each organism has 16 genes which tell it what to do when it is adjacent to either poison or food.  Each gene has a numeric value from 1 to 8.  Each cell has 8 neighboring cells as follows:

1    2    3

4    *    5

6    7    8

The first 8 genes tell the organism what to do when it is adjacent to poison and the last 8 genes tell the organism what to do when it is adjacent to food.  For example, let's suppose that the 9th gene has a value of 1.  The 9th gene is the 1st food gene which tells the organism what to do if food is located at relative position 1 (i.e., upper left).  In this case the value tells the organism to move to relative position 1 which means that the organism lands on the food and eats it.

The cells are advanced in time discretely from time step N to time step N + 1.  The transition rules are as follows:

Initially organisms are assigned random positions and random genes.  Each organism also as a random direction of travel.
If an organism is adjacent to poison or food then its genetic code controls its behavior.  If it lands on poison then it is assumed to eat the poison (i.e., it dies immediately and is removed from the grid).  If it lands on food then it is assumed to eat the food and its energy supply is assumed to be replenished.
Food particles and poison particles which disappear because an organism eats them reappear at a random location in the grid.  Thus, the total amount of food and the total amount of poison remain constant.
If an organism is not adjacent to poison or food then it continues in the same direction it had before.
If an organism goes without food for more than 27 time steps then it is assumed to starve to death (i.e., it dies and is removed from the grid).
An organism which survives for 30 time steps will reproduce one copy of itself.  The child organism will inherit the parent's genes except for mutations which may happen to only one gene.
The simulation runs until a maximum time is reached or until all the organisms die.  The maximum time can be selected by the user.
Statistical information is displayed at the top of the screen (i.e., current number of living organisms, average age of living organisms, maximum age of living organisms, genome associated with the longest lived organism, etc.)

In order to start the cellular automaton select the maximum time step in the drop-down list and then click the run button.

Simulated Evolution on a 50 x 50 grid

 

Planetary Orbit

The following program simulates the elliptical orbit of a planet around a star.  It demonstrates Kepler's 2nd Law of Planetary Motion which says that the radius vector from the star to the planet sweeps out equal areas in equal times.  The user may select any of the following four parameters from drop-down lists:
whether or not the path of the planet is displayed (off or on)
the mass of the star relative to the sun (20 values)
the length of the semi-major axis in A.U. (27 values)
the eccentricity of the planet's orbit (20 values)

In order to start the simulation select parameters from the various drop-down lists and then click the run button.  In order to stop the simulation click the pause button.  You may continue the simulation by clicking the run button.  When the simulation is paused you may click the data button in order to bring up a window displaying the following parameters concerning the simulation: mass of star (sun = 1.0), luminosity of star (sun = 1.0), length of semi-major axis of planet's orbit, eccentricity of planet's orbit, orbital period, elapsed time since beginning of simulation, orbit number, current distance from star (A.U.), current azimuthal angle (deg), current orbital velocity (km/sec), current stellar flux (watts per square meter), planetary albedo, current blackbody temperature (deg C), and current surface temperature (deg C).  The simulation shows the periastrion point (i.e., the point at which the planet is closest to its star) at the top of the orbit.

Simulated Planetary Orbit

 

Our Solar System

The following program simulates the orbits of the following nine planets in our solar system:
Mercury (orange)
Venus (yellow)
Earth (blue)
Mars (red)
Jupiter (green)
Saturn (cyan)
Uranus (magenta)
Neptune (purple)
Pluto (brown)

The view point of the simulation is from Polaris (i.e., the North Star) which means that all nine planets orbit the sun in the counterclockwise direction.  The simulation begins on January 1, 2001 and goes forward in time from there one day at a time.  In order to start the simulation click the run button.  In order to stop the simulation click the pause button.  You may continue the simulation by clicking the run button.  When the simulation is paused you may click the data button in order to bring up a window displaying the current data for each of the nine planets.  Initially the zoom factor is set so that only Mercury, Venus, Earth, and Mars can be seen.  In order to zoom out and see the outer planets click the zoom out button.  In order to zoom in and see the inner planets exclusively click the zoom in button.  In order to restart the simulation from January 1, 2001 click the restart button.

Simulated Solar System

 

Tic-tac-toe

The following program allows the user to play a game of tic-tac-toe against the computer.  The game board consists of 9 squares arranged in 3 rows with 3 columns per row.  The user selects the player who moves first from a drop-down list.  Then the user clicks the start game button in order to begin the game.  The player moving first will put an X in the cell of his or her choice.  The player moving second will put an O in the cell of his or her choice.  The user chooses the cell he or she wants by clicking on it.  The game proceeds until three X's in a row occur (horizontally, vertically, or diagonally), three O's in a row occur (horizontally, vertically, or diagonally), or there are no more empty cells.  At the end of the game the user can click the play again button in order to erase the board and prepare for a new game.  Then the user can click the start game button in order to start a new game.  The program keeps track of the number of times that the computer has won, the number of times that the user has won, and the number of tie games.

 
Tic-tac-toe Game

 

Chess

The following program allows the user to play a game of chess against the computer.  The game board consists of 64 squares arranged in 8 rows (i.e., ranks) with 8 columns (i.e., files) per row.  The user selects the player who moves first (i.e., the player controlling the white pieces) from a drop-down list.  Then the user clicks the start game button in order to begin the game.  When it's the user's turn to move the user must first click on the square containing the piece to be moved.  Then the user must perform a second click on the destination square for this piece.  If the user's move is invalid it will display the string "Illegal move" in the status box and the user must choose a valid destination for that piece.  In order to capture one of the computer's pieces the user must choose a destination square occupied by an enemy piece.  In order to castle the user must click on his or her king and then click on an empty square on the same rank which is located two squares away from the king (other conditions for castling apply).  Pawns of either side that make it all the way to the last rank will be automatically promoted to queens.  The game proceeds until the user is checkmated, the computer is checkmated, the game is a stalemate, or the game is a draw.  The outcome of the game is displayed in the status box.  At the end of the game the user can click the play again button in order to initialize the board and prepare for a new game.  Then the user can click the start game button in order to start a new game.  The program keeps track of whether the user or the computer is in check, the move number, the user's last move in chess notation, and the computer's last move in chess notation.

 
Chess Game

 

Simulated Cannonball Trajectory

The following program simulates the trajectory of a cannonball being fired out of a cannon.  The user may select any of the following six parameters from drop-down lists:
whether or not the path of the cannonball is displayed (off or on)
the initial velocity of the cannonball (6 values)
the initial elevation angle of the cannonball (18 values)
whether or not air resistance is to be included (no or yes)
the air density relative to sea level (5 values)
the diameter of the cannonball (6 values)

In order to start the simulation select parameters from the various drop-down lists and then click the run button.  In order to stop the simulation click the pause button.  You may continue the simulation by clicking the run button.  At the end of the cannonball's trajectory (i.e., when it hits the ground) the simulation will be automatically paused.  You may change parameters and click the run button again to run another simulated trajectory without erasing the previous trajectory of the cannonball.  When air resistance is turned off the cannonball trajectory is displayed in blue.  When air resistance is turned on the cannonball trajectory is displayed in red.  When the simulation is paused click the reset button in order to clear the screen and start over.

 
Cannonball Trajectory

 

Display Constellations

The following program allows the user to view various constellations as they appear in the night sky.  It also allows the user to simulate changes in the appearance of the constellation either going forward in time or backward in time.  The user may select any of the following four parameters from drop-down lists:
whether or not the path of each star is displayed (off or on)
the constellation to be displayed (14 values)
the time step to use for the simulation (10 values)
the direction in time for the simulation (future or past)

In order to start the simulation select parameters from the various drop-down lists and then click the run button.  In order to stop the simulation click the pause button.  You may continue the simulation by clicking the run button.  With the simulation paused you may advance the simulation by one time step by clicking the 1 step button.  With the simulation running click the faster button in order to increase the speed of the simulation, click the slower button in order to decrease the speed of the simulation, and click the normal button in order to set the simulation speed back to its default value.

The display will be centered on the center of the constellation with north at the top of the screen.  The current time for the simulation is displayed in a display box.  If a star scrolls off the edge of the screen you can bring it back into view by clicking the zoom out button (this will increase the value of the number displayed in the display width display box).  If you want to zoom in click the zoom in button.  If you want to set the zoom factor back to its default setting then click the zoom normal button.  Note that selecting another constellation will reset the time back to zero and the zoom factor back to its default setting.

In the display the stars are represented by white points on a black background.  In order to get information on a particular star just click on the white point.  A window will pop up containing the following information: constellation, star name, common name, current right ascension in J2000 coordinates, current declination in J2000 coordinates, distance in parsecs, distance in light-years, apparent magnitude, absolute magnitude, intrinsic visual brightness, current proper motion in right ascension, current proper motion in declination, current total proper motion, current radial velocity, spectral type, total luminosity, mass, surface temperature, radius, average density, surface gravity, minimum radius of habitable zone, maximum radius of habitable zone, lifetime of star, angle from north/south celestial pole, total space velocity, angle traveled since time zero, distance traveled since time zero, and the parameters for the star's nearest approach to Earth (i.e., when it will take place, how close will the star get, etc.).

 
Display Constellations