CompSci 307
Spring 2019
Software Design and Implementation

Simulation

The chess-board is the world; the pieces are the phenomena of the universe; the rules of the game are what we call the laws of Nature. — T. H. Huxley

Cellular Automata, CA, are simulations based on a model that consists of a regular grid of cells, each in one of a finite number of states (such as on and off). Simulations start with all cells in an initial state and are run by updating each cell based on a set of fixed rules described in terms of the cell's current state and the states of its immediate neighbors. Though this model is simply described, it can be used to simulate a wide variety of complex phenomena, such as ant foraging to economic theory. In fact, after 20 years of study, Stephen Wolfram declared CA were a universal mechanism for moving scientific study forward in his 1280 page book A New Kind of Science that contains hundreds of example models. Its simulations have also been called art.

The following programming assignments, aimed at CompSci 101 or CompSci 201 level courses, may look very different but they are simply different examples of CA:

All of these are simulations based on a CA models of a real system, built to better understand it, to observe and predict its behavior, or to perform experiments on the model. Many real systems are difficult or impossible to observe and control, much less experiment with, because they involve events that are not precisely predictable though the relative frequencies of event results may be known, e.g., a flipped coin comes up heads roughly as often as tails, one can not be certain of a particular result. A simulation program, however, may be easily run repeatedly and modified to explore the effect of changes to the model (how accurate the model is can lead to ethical questions).

Specification

In teams, write a Java program using OpenJFX that makes it as easy as possible to animate any 2D grid CA simulation — at the very least, the simulations described in the linked assignments above — by providing an initial configuration and coding a set of rules in Java that determines how each cell interacts with their neighbors each step of the simulation. The grid can be configured at the start of the simulation to be of any number of cells, composed of a variety of typical shapes, complete or partial neighborhoods, and edge policies. The simulation is run by applying the same rules on each cell "simultaneously", i.e., based only on their current state, and then updating their states in a second pass so cells are only affected by information from their nearby neighbors.

You will provide a GUI to allow users to load and save any kind of simulation, interact with the current simulation, and dynamically display information about the running simulation. The kind of simulation, its starting configuration, as well as any initial parameter settings will be read from a data file with appropriate error checking.

Design

Traditionally desktop Graphical User Interfaces (GUIs) have been organized into an architecture featuring separate Model, View, and Controllers (MVC) — this has proved so successful that it has also become the de facto standard for designing web and mobile applications as well, with many popular frameworks basically requiring it. This is done to separate internal representations of information from the ways information is presented to and accepted from the user, decoupling these components and allowing for efficient code reuse and parallel development, often by people with very different skill sets. The Model, typically called the backend, is the application's dynamic data structure, its knowledge, and it manages the data, logic and rules of the application. The View, typically called the frontend, is a visual representation of the model and can be any number of output representations of information. The Controller, typically called the middleware, acts as an interface between Model and View to process the logic and interactions and is a more tightly coupled to the specific application and, with some frameworks, can be somewhat ambiguous in its role. These layers can typically be developed and tested separately.

This assignment provides a context to begin thinking about issues of design and coding style.

  1. Developing a GUI program. Learning how to create a properly structured GUI that responds to user events while still maintaining clear separation from the model requires clear articulation about what information needs to be communicated between each part.
  2. Encapsulation: Creating meaningful classes, based on their behavior rather than their state, is the key to hiding the each part's implementation decisions.
  3. Dependency Inversion Principle. Structure the main parts of your project around abstractions built using inheritance and polymorphism so that project details can be more easily changed.

Project Goals

This project is intended to introduce you to

Deliverables

You will submit this project in stages:

Resources