Skip to content
Snippets Groups Projects
Select Git revision
  • c565c84342c99e6c978e72f1303db65df2f3caea
  • main default protected
  • develop
  • 0.1.1
  • 0.1.0
5 results

download_data.R

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    GameOfLifeState.java 882 B
    package model.automata;
    
    import javafx.scene.paint.Color;
    import model.State;
    
    import java.util.List;
    
    /**
     * {@link GameOfLifeState} instances represent the possible states of a {@link GameOfLifeState}.
     */
    public enum GameOfLifeState implements State<GameOfLifeState> {
        ALIVE(Color.RED),
        DEAD(Color.WHITE);
    
        public final Color color;
    
        GameOfLifeState(Color color) {
            this.color = color;
        }
    
        @Override
        public Color getColor() {
            return this.color;
        }
    
        @Override
        public GameOfLifeState next() {
            return GameOfLifeState.values()[1 - this.ordinal()];
        }
    
        @Override
        public GameOfLifeState update(List<GameOfLifeState> neighbours) {
            int countAlive = State.count(ALIVE, neighbours);
            return (countAlive == 3 || this == ALIVE && countAlive == 2)?
                     ALIVE:
                     DEAD;
        }
    
    }