Uploaded by Mervin D'Souza

Homework2

advertisement
Object Oriented Programming and Modelling – Homework 2
Problem statement:
The aim is to simulate a simple population. This population consists of cellular
automats, with each cell having two states: alive or dead. Every cell has 8 neighbors
(Moore-Neighborhood). The state of the cell depends on its current state and the
number of living and dead neighbors. The goal is, to simulate the evolution of an initial
population. The subsequent generation is a result of the prior one. The following are
the rules for the evolution process:
Dead automat:
•
•
Cell reincarnates it has 3 living neighbors.
Remains dead otherwise.
Living automat:
•
•
•
Cell dies if it has less than two living neighbors due to loneliness.
Cell remains alive if it has 2 or 3 living neighbors.
Cell dies if it has more than 3 living neighbors due to overpopulation.
Results:
Following are the class diagrams for the various classes that were implemented in this
code.
Main class
Rectangle class
FirstPattern class
SecondPattern class
ThirdPattern class
GenCheck1
GenCheck2
GenCheck3 class
Nasi Schneiderman diagrams:
Nasi Schneiderman diagram for the calculation of the whole field
Nasi Schneiderman diagram for visualization of the field
It must be noted that the figure above displays the Nasi Schneiderman diagram for the
visualization of the first pattern after the first generation. A similar algorithm applies to
visualization of the different patterns after different generations.
Pattern 1:
First generation
Fifth generation
Tenth generation
Twentieth generation
Fiftieth generation
Pattern 2:
First generation
Fifth generation
Tenth generation
Twentieth generation
Fiftieth generation
Pattern 3:
First generation
Fifth generation
Tenth generation
Twentieth generation
Fiftieth generation
Download