Skip to content

Commit

Permalink
insourcing from computer_kurzweil
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaswoehlke committed Mar 13, 2020
1 parent cd68829 commit bf82878
Show file tree
Hide file tree
Showing 86 changed files with 2,186 additions and 160 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Simulated Evolution
Abstract
--------

Green food appears in a worldModel with red moving cells. These cells eat the food if it is on their position.
Green food appears in a simulatedEvolutionModel with red moving cells. These cells eat the food if it is on their position.
Movement of the cells depends on random and their DNA. A fit cell moves around and eats enough to reproduce.
Reproduction is done by splitting the cell and randomly changing the DNA of the two new Cells.
If a cell doesn't eat enough, it will first stand still and after a while it dies.
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.woehlke.computer.kurzweil</groupId>
<artifactId>simulated-evolution</artifactId>
<artifactId>simulatedevolution</artifactId>
<version>2.4-SNAPSHOT</version>
<packaging>jar</packaging>
<url>https://github.com/Computer-Kurzweil/simulated-evolution</url>
Expand Down Expand Up @@ -444,7 +444,7 @@
</execution>
</executions>
<configuration>
<mainClass>org.woehlke.computer.kurzweil.simulation.evolution.SimulatedEvolutionApplication</mainClass>
<mainClass>org.woehlke.computer.kurzweil.SimulatedEvolutionApplication</mainClass>
</configuration>
</plugin>
<plugin>
Expand All @@ -454,7 +454,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.woehlke.computer.kurzweil.simulation.evolution.SimulatedEvolutionApplication</mainClass>
<mainClass>org.woehlke.computer.kurzweil.SimulatedEvolutionApplication</mainClass>
</manifest>
</archive>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.woehlke.computer.kurzweil;

import lombok.extern.log4j.Log4j2;
import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties;
import org.woehlke.computer.kurzweil.tabs.simulatedevolution.SimulatedEvolutionTab;

/**
* Class with main Method for Starting the Desktop Application.
*
* @see SimulatedEvolutionTab
*
* &copy; 2006 - 2008 Thomas Woehlke.
* http://thomas-woehlke.de/p/simulated-evolution/
* @author Thomas Woehlke
*/
@Log4j2
public class SimulatedEvolutionApplication {

private SimulatedEvolutionApplication(String configFileName, String jarFilePath) {
ComputerKurzweilProperties properties = ComputerKurzweilProperties.propertiesFactory(configFileName, jarFilePath);
SimulatedEvolutionTab simulatedEvolutionTab = new SimulatedEvolutionTab(properties);
}

/**
* Starting the Desktop Application
* @param args CLI Parameter
*/
public static void main(String[] args) {
String configFileName = "application.yml";
String jarFilePath = "target/simulatedevolution.jar";
SimulatedEvolutionApplication application = new SimulatedEvolutionApplication(configFileName,jarFilePath);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package org.woehlke.computer.kurzweil.application;

import lombok.Getter;
import lombok.ToString;
import lombok.extern.log4j.Log4j2;
import org.woehlke.computer.kurzweil.commons.Startable;
import org.woehlke.computer.kurzweil.commons.model.LatticePoint;
import org.woehlke.computer.kurzweil.tabs.simulatedevolution.model.CellCore;
import org.woehlke.computer.kurzweil.tabs.simulatedevolution.model.LifeCycle;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import java.util.Date;
import java.util.Random;

@Log4j2
@Getter
@ToString(exclude={"random","frame"},callSuper=true)
public class ComputerKurzweilContext implements Startable {

private final Random random;
private final ComputerKurzweilProperties properties;

public ComputerKurzweilContext(
ComputerKurzweilProperties computerKurzweilProperties
) {
this.properties = computerKurzweilProperties;
long seed = new Date().getTime();
this.random = new Random(seed);
}

public CompoundBorder getTabbedPaneBorder() {
return getBorder();
}

public CompoundBorder getFrameBorder(){
return getBorder();
}

public CompoundBorder getBorder(){
int left = this.getProperties().getAllinone().getView().getBorderPaddingX();
int right = this.getProperties().getAllinone().getView().getBorderPaddingX();
int top = this.getProperties().getAllinone().getView().getBorderPaddingY();
int bottom = this.getProperties().getAllinone().getView().getBorderPaddingY();
return BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(),
BorderFactory.createEmptyBorder(left,right,top,bottom)
);
}

public CompoundBorder getBorder(String label){
int top = this.getProperties().getAllinone().getView().getBorderPaddingY();
int left = this.getProperties().getAllinone().getView().getBorderPaddingX();
int bottom = this.getProperties().getAllinone().getView().getBorderPaddingY();
int right = this.getProperties().getAllinone().getView().getBorderPaddingX();
return BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder(label),
BorderFactory.createEmptyBorder(top,left,bottom,right)
);
}

private CompoundBorder getDoubleBorder(){
int left = this.getProperties().getAllinone().getView().getBorderPaddingX();
int right = this.getProperties().getAllinone().getView().getBorderPaddingX();
int top = this.getProperties().getAllinone().getView().getBorderPaddingY();
int bottom = this.getProperties().getAllinone().getView().getBorderPaddingY();
return BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(left,right,top,bottom),
BorderFactory.createEmptyBorder(left,right,top,bottom)
);
}

private CompoundBorder getDoubleBorder(String label){
int left = this.getProperties().getAllinone().getView().getBorderPaddingX();
int right = this.getProperties().getAllinone().getView().getBorderPaddingX();
int top = this.getProperties().getAllinone().getView().getBorderPaddingY();
int bottom = this.getProperties().getAllinone().getView().getBorderPaddingY();
return BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(left,right,top,bottom),
BorderFactory.createEmptyBorder(left,right,top,bottom)
);
}

public CompoundBorder getBottomButtonsPanelBorder(){
return getDoubleBorder();
}

public CompoundBorder getBottomButtonsPanelBorder(String label){
return getDoubleBorder(label);
}

private Border getZeroBorder() {
int top = 0;
int left = 0;
int bottom = 0;
int right = 0;
return BorderFactory.createEmptyBorder(top,left,bottom,right);
}

public Border getTabBorder() {
return getZeroBorder();
}

public Border getCanvasBorder() {
return getZeroBorder();
}

public LatticePoint getWorldDimensions(){
int x = this.properties.getAllinone().getLattice().getWidth();
int y = this.properties.getAllinone().getLattice().getHeight();
return new LatticePoint(x,y);
}

public LatticePoint getNextRandomLatticePoint() {
int x = this.properties.getAllinone().getLattice().getWidth();
int y = this.properties.getAllinone().getLattice().getHeight();
int nextX = this.getRandom().nextInt(x);
int nextY = this.getRandom().nextInt(y);
LatticePoint p = new LatticePoint(nextX,nextY);
p.normalize(this.getWorldDimensions());
p.absoluteValue();
return p;
}

public LifeCycle getNewCellLifeCycle() {
return new LifeCycle(this.properties.getSimulatedevolution().getCellConf().getFatAtBirth());
}

public CellCore getNewCellCore() {
return new CellCore(this.random);
}

public void start(){ }

public void stop() { }

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.woehlke.computer.kurzweil.simulation.evolution.config;
package org.woehlke.computer.kurzweil.application;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import lombok.*;
import lombok.extern.log4j.Log4j2;
import org.woehlke.computer.kurzweil.tabs.TabType;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
Expand Down Expand Up @@ -1025,11 +1026,65 @@ public static ComputerKurzweilProperties propertiesFactory(String conf, String j
return properties;
}

public String getSubtitle(){
return this.getSimulatedevolution().getView().getSubtitle();
public String getSubtitle(TabType tabType){
switch (tabType){
case CYCLIC_CELLULAR_AUTOMATON:
return this.getCca().getView().getSubtitle();
case DIFFUSION_LIMITED_AGGREGATION:
return this.getDla().getView().getSubtitle();
case SIMULATED_EVOLUTION:
return this.getSimulatedevolution().getView().getSubtitle();
case MANDELBROT_SET:
return this.getMandelbrot().getView().getSubtitle();
case RANDOM_WALK_WIENER_PROCESS:
return this.getRandomwalk().getView().getSubtitle();
case KOCH_SNOWFLAKE:
return this.getKochsnowflake().getView().getSubtitle();
case SAME_GAME:
return this.getSamegame().getView().getSubtitle();
case SIERPINSKI_TRIANGLE:
return this.getSierpinskitriangle().getView().getSubtitle();
case TETRIS:
return this.getTetris().getView().getSubtitle();
case TURMITE:
return this.getTurmite().getView().getSubtitle();
case WATOR:
return this.getWator().getView().getSubtitle();
case CONWAYS_GAME_OF_LIFE:
return this.getGameoflive().getView().getSubtitle();
default:
return "UNDEFINED";
}
}

public String getTitle(){
return this.getSimulatedevolution().getView().getTitle();
public String getTitle(TabType tabType){
switch (tabType){
case CYCLIC_CELLULAR_AUTOMATON:
return this.getCca().getView().getTitle();
case DIFFUSION_LIMITED_AGGREGATION:
return this.getDla().getView().getTitle();
case SIMULATED_EVOLUTION:
return this.getSimulatedevolution().getView().getTitle();
case MANDELBROT_SET:
return this.getMandelbrot().getView().getTitle();
case RANDOM_WALK_WIENER_PROCESS:
return this.getRandomwalk().getView().getTitle();
case KOCH_SNOWFLAKE:
return this.getKochsnowflake().getView().getTitle();
case SAME_GAME:
return this.getSamegame().getView().getTitle();
case SIERPINSKI_TRIANGLE:
return this.getSierpinskitriangle().getView().getTitle();
case TETRIS:
return this.getTetris().getView().getTitle();
case TURMITE:
return this.getTurmite().getView().getTitle();
case WATOR:
return this.getWator().getView().getTitle();
case CONWAYS_GAME_OF_LIFE:
return this.getGameoflive().getView().getTitle();
default:
return "UNDEFINED";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.woehlke.computer.kurzweil.commons;

public interface Startable {

void start();
void stop();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.woehlke.computer.kurzweil.commons;

public interface Updateable {

void update();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.woehlke.computer.kurzweil.commons.gui;

public interface GuiComponent {
//void showMe();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.woehlke.computer.kurzweil.commons.gui;

public interface GuiComponentApplication {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.woehlke.computer.kurzweil.commons.gui;

public interface GuiComponentCanvas {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.woehlke.computer.kurzweil.commons.gui;

public interface GuiComponentPanel {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.woehlke.computer.kurzweil.commons.gui;

public interface GuiComponentTab {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.woehlke.computer.kurzweil.commons.has;

import org.woehlke.computer.kurzweil.application.ComputerKurzweilContext;

public interface HasContextApplication {

ComputerKurzweilContext getCtx();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.woehlke.computer.kurzweil.commons.has;

import org.woehlke.computer.kurzweil.commons.widgets.PanelStartStopButtons;

public interface HasPanelStartStopButtons {

PanelStartStopButtons getPanelStartStopButtonsSubTab();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.woehlke.computer.kurzweil.commons.has;

import org.woehlke.computer.kurzweil.commons.widgets.PanelSubtitle;

public interface HasPanelSubtitle {
PanelSubtitle getPanelSubtitle();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.woehlke.computer.kurzweil.commons.has;

import org.woehlke.computer.kurzweil.tabs.Tab;

public interface HasTab {

Tab getTab();
//TabType getTabType();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.woehlke.computer.kurzweil.commons.has;

import org.woehlke.computer.kurzweil.commons.tabs.TabCanvas;

public interface HasTabCanvas {

TabCanvas getCanvas();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.woehlke.computer.kurzweil.commons.has;

import org.woehlke.computer.kurzweil.commons.tabs.TabContext;

public interface HasTabContext {

TabContext getTabCtx();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.woehlke.computer.kurzweil.commons.has;

import org.woehlke.computer.kurzweil.commons.tabs.TabController;

public interface HasTabController {

TabController getController();
void startController();
void stopController();
}
Loading

0 comments on commit bf82878

Please sign in to comment.