Coder Social home page Coder Social logo

gameoflife's Introduction

Game of Life

Getting Started

Just compile the sources and type in the CLI:

java -jar GameOfLife.jar

Use

All inputs can be applied using a graphical user interface. A click on cells sets them alive (if dead) or kills them (if alive). You can also draw lines by clicking and hovering over multiple cells. Further features are are cutomizing the size of the cell automata or inserting shapes. You can also choose the speed of the simulation

Development

The programm is written in Java. All sources are included. We use and recommend IntelliJ for development.

Known Issues

Resizing the windowd leads to an alternation of the (x,y) model. At runtime, the simulation can become buggy if figures are sliding over the edge of the window (this is actually more a concurrency problem than a bug as resizing (the ui thread) is not synchronized with the actual simulation)

Complexity

Living cells are stored in a hashmap (the current generation) with access in O(1). The algorithm works in-place and only looks as living cells, hence it scales independently of the size of the (x,y) model. The memory complexity is O(n) with n being the number of living cells, which is optimal, since every living cell needs to be inspected by the algorithm. The algorithm iterates over the hashmap and searches for every cell for its neighbors as a potential candidate for the next generation. Then the number of living neighbours of each candidate will be computed and the Cornway rules will be applied. The run-time complexity is thus O(n) which is optimal.

Alternative Rule Sets

Der Code is generic to support different rule sets:

public class Game implements Grid {
    /*
     * Spielregeln!! Moeglich sind beispielsweise:
     * 
     * ALIVE | DEAD     | World 
     * ------------------------ 
     * 3      | 0145678 | Cornway Original 
     * 0123478| 5       | Anti Cornway 
     * 1357   | 02468   | Copy System 
     * 02468  |1357     | Anti copy system
     * 3      | 014578  | Exploding, similiar zu Conway
     */
    private static final int[] ALIVE_RULE = {3};
    private static final int[] KILL_RULE = {0, 1, 4, 5, 6, 7, 8};
     

See class "Game.java"

gameoflife's People

Contributors

bergerch avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.