Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[biosilico][ants][anthill] work on biosilio, common & crypto #23

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Some ideas about Artificial Life, Creatures (game series) and Neural Networks. R

Probably out-of-date for some reasons (but many ideas inside), codes from 2008-2012 (and before then) ; ideas I didn't continue for times spent reasons and I wish to continue (year 2020).

Tests and learning on coding / programming (Java, Perl, I did some HyperTalk / HyperCard before that long ago) ; some studies on biochemistry and video games (Myst, Marathon, and the first Creature game) then bioinformatics. Find some old code here !
Tests and learning on coding / programming (Java, Perl, I did some HyperTalk / HyperCard before that long ago) ; some studies on biochemistry and video games (Myst, Marathon, and the first Creature game) then bioinformatics. Find some old code here ! And reviewed so far.

Some parts where done in Java 1.4 (before the Generics of Java 1.5) ! Some review for generics and some other for stream (Java 8 !). Adding some unit tests and more review !

Expand All @@ -14,7 +14,19 @@ Units Tests ; review...

For dev on BioSilico :

* genetic execution / genes use age and cycle (to avoid multiple instantiation of Brain / BrainLobe ++ execution of InitConcGene) : make good usage of age_min and age_max (0, 0) for initiation at start / 'birth'.
* genetic execution / genes use age and cycle (to avoid multiple instantiation of Brain / BrainLobe ++ execution of InitConcGene) : make good usage of ageMin and ageMax (0, 0) for initiation at start / 'birth'.
* Design Patterns 'Builder' to make better implements
* ...

## Common resources

Some utils. Data (File, Directory, Filter), Structures, View...

## Ant Hill Example

First Aim was to do / retake an example with Ants, ans some plants and fruits. Not totally from scratch / from nothing : it gives some ideas about how the engine could works.

## Creatures (Game Series) ressources

Some (original) ideas comes from here, some articles, documentations, ressources...

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package gabywald.biosilico.anthill;

import gabywald.biosilico.model.Organism;

/**
*
* @author Gabriel Chandesris (2009, 2020)
*/
public class Ant extends Organism {

public enum AntStatus {
EGG_LARVA, // (0, 1),
WORKER, // (2, 3, 4, 5, 6, 7),
SOLDIER, // (8),
QUEEN; // (9);
}
/**
* Status of ant.
* <p></p>
* <ul>
* <li><b>0-1</b> : Egg / Larva</li>
* <li><b>2-7</b> : Worker</li>
* <li><b>8</b> : Soldier</li>
* <li><b>9</b> : Queen</li>
* </ul>
*/
private int status;

/** Default constructor of an Ant agent (alive). */
public Ant() {
super();
this.setAlive( true );
this.setEatable( false );
this.setMovable( false );

this.setNameCommon("Ant");
this.setOrganismType(OrganismType.BIOSILICO_ANIMA);

this.status = 0; /** start with an egg. */
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package gabywald.biosilico.anthill;

import java.util.ArrayList;
import java.util.List;

import gabywald.biosilico.genetics.Gene;
import gabywald.biosilico.genetics.builders.BiochemicalReactionBuilder;

/**
*
* @author Gabriel Chandesris (2020)
*/
public class AntBuilder {

public AntBuilder() {
;
}

public List<Gene> generateBasicGenome() {
List<Gene> toReturn = new ArrayList<Gene>();

// NOTEs ::
// // // need some initial concentration !!
// // // need some biochemical reaction
// // // receptor for some variables from environment
// // // emitter for some variables from environment
// // // Decision to take fruits !
// // // Decision to drop fruits ! (in the AntHill)
// // // Decision to eat fruits !
// // // Decision to display pheromones !

// // // detection of pheromones !
// // // choice of destination :: movement !!


BiochemicalReactionBuilder brb = new BiochemicalReactionBuilder();
toReturn.add(brb.achem( 20 ).acoef( 1 )
.bchem( 21 ).bcoef( 1 )
.cchem( 22 ).ccoef( 1 )
.dchem( 23 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 22 ).acoef( 1 )
.bchem( 23 ).bcoef( 1 )
.cchem( 24 ).ccoef( 1 )
.dchem( 25 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 24 ).acoef( 1 )
.bchem( 25 ).bcoef( 1 )
.cchem( 26 ).ccoef( 1 )
.dchem( 27 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 26 ).acoef( 1 )
.bchem( 27 ).bcoef( 1 )
.cchem( 28 ).ccoef( 1 )
.dchem( 29 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 28 ).acoef( 1 )
.bchem( 29 ).bcoef( 1 )
.cchem( 30 ).ccoef( 1 )
.dchem( 31 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 30 ).acoef( 1 )
.bchem( 31 ).bcoef( 1 )
.cchem( 32 ).ccoef( 1 )
.dchem( 33 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 32 ).acoef( 1 )
.bchem( 33 ).bcoef( 1 )
.cchem( 34 ).ccoef( 1 )
.dchem( 35 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 34 ).acoef( 1 )
.bchem( 35 ).bcoef( 1 )
.cchem( 36 ).ccoef( 1 )
.dchem( 37 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
return toReturn;
}

public Ant build() {

return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package gabywald.biosilico.anthill;

import gabywald.biosilico.model.Chemicals;
import gabywald.biosilico.model.Organism;

/**
* This class defines a specific element which is not alive but can be move and eat by agents in the system.
* <br />Produced by plants, do not do anything either.
* @author Gabriel Chandesris (2009, 2020)
*/
public class Fruit extends Organism {

/**
* Default constructor for Fruit.
*/
public Fruit() {
super();
this.setAlive( false );
this.setEatable( true );
this.setMovable( true );

this.setNameCommon("Fruit");
this.setOrganismType(OrganismType.BIOSILICO_VIRIDITA);
}

/**
* Constructor of a Fruit which have only one variable to feed.
* @param var (int)
* @param val (int)
* @see Chemicals#setVarPlus(int, int)
*/
public Fruit(int var, int val) {
this();
this.variables.setVarPlus(var, val);
}

/**
* Constructor with pre-established Variables set.
* @param toFeed (Chemicals)
*/
public Fruit(Chemicals toFeed) {
this();
this.variables = toFeed;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package gabywald.biosilico.anthill;

import gabywald.biosilico.model.Organism;

/**
* This class describes plants which produce fruits.
* @author Gabriel Chandesris (2009, 2020)
* @see Fruit
*/
public class Plant extends Organism {

/** Default Constructor. */
public Plant() {
super();
this.setAlive( true );
this.setEatable( false );
this.setMovable( false );

this.setNameCommon("Plant");
this.setOrganismType(OrganismType.BIOSILICO_VIRIDITA);

// ***** Here creation of 'egg' => create fruits !

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package gabywald.biosilico.anthill;

import java.util.ArrayList;
import java.util.List;

import gabywald.biosilico.genetics.Gene;
import gabywald.biosilico.genetics.builders.BiochemicalReactionBuilder;
import gabywald.biosilico.genetics.builders.InitialConcentrationBuilder;

/**
*
* @author Gabriel Chandesris (2020)
*/
public class PlantBuilder {

public PlantBuilder() {
;
}

public List<Gene> generateBasicGenome() {
List<Gene> toReturn = new ArrayList<Gene>();

// NOTEs ::
// // // need some initial concentration !!
// // // need some biochemical reaction
// // // receptor for some variables from environment
// // // emitter for some variables from environment
// // // Decision to make fruits !

InitialConcentrationBuilder icb = new InitialConcentrationBuilder();
toReturn.add( icb.varia( 0 ).value( 100 ).agemin( 0 ).agemax( 0 ).mutation(25).build() );

BiochemicalReactionBuilder brb = new BiochemicalReactionBuilder();
toReturn.add(brb.achem( 0 ).acoef( 1 )
.bchem( 1 ).bcoef( 1 )
.cchem( 2 ).ccoef( 1 )
.dchem( 3 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 2 ).acoef( 1 )
.bchem( 3 ).bcoef( 1 )
.cchem( 4 ).ccoef( 1 )
.dchem( 5 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 4 ).acoef( 1 )
.bchem( 5 ).bcoef( 1 )
.cchem( 6 ).ccoef( 1 )
.dchem( 7 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 6 ).acoef( 1 )
.bchem( 7 ).bcoef( 1 )
.cchem( 8 ).ccoef( 1 )
.dchem( 9 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 8 ).acoef( 1 )
.bchem( 9 ).bcoef( 1 )
.cchem( 10 ).ccoef( 1 )
.dchem( 11 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 10 ).acoef( 1 )
.bchem( 11 ).bcoef( 1 )
.cchem( 12 ).ccoef( 1 )
.dchem( 13 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 12 ).acoef( 1 )
.bchem( 13 ).bcoef( 1 )
.cchem( 14 ).ccoef( 1 )
.dchem( 15 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 14 ).acoef( 1 )
.bchem( 15 ).bcoef( 1 )
.cchem( 16 ).ccoef( 1 )
.dchem( 17 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 16 ).acoef( 1 )
.bchem( 17 ).bcoef( 1 )
.cchem( 18 ).ccoef( 1 )
.dchem( 19 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 18 ).acoef( 1 )
.bchem( 19 ).bcoef( 1 )
.cchem( 20 ).ccoef( 1 )
.dchem( 21 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 20 ).acoef( 1 )
.bchem( 21 ).bcoef( 1 )
.cchem( 22 ).ccoef( 1 )
.dchem( 23 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 22 ).acoef( 1 )
.bchem( 23 ).bcoef( 1 )
.cchem( 24 ).ccoef( 1 )
.dchem( 25 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 24 ).acoef( 1 )
.bchem( 25 ).bcoef( 1 )
.cchem( 26 ).ccoef( 1 )
.dchem( 27 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 26 ).acoef( 1 )
.bchem( 27 ).bcoef( 1 )
.cchem( 28 ).ccoef( 1 )
.dchem( 29 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 28 ).acoef( 1 )
.bchem( 29 ).bcoef( 1 )
.cchem( 30 ).ccoef( 1 )
.dchem( 31 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 30 ).acoef( 1 )
.bchem( 31 ).bcoef( 1 )
.cchem( 32 ).ccoef( 1 )
.dchem( 33 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 32 ).acoef( 1 )
.bchem( 33 ).bcoef( 1 )
.cchem( 34 ).ccoef( 1 )
.dchem( 35 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
toReturn.add(brb.achem( 34 ).acoef( 1 )
.bchem( 35 ).bcoef( 1 )
.cchem( 36 ).ccoef( 1 )
.dchem( 37 ).dcoef( 1 )
.kmvm( 5 ).agemax(999).mutation(25).build());
return toReturn;
}

public Plant build() {

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class FilterBioSilico extends FilterUtils {

/** Default Constructor. */
public FilterBioSilico() {
super(FilterType.NONE, "BioSilico Files");
super(FilterGroupType.NONE, "BioSilico Files");
/** super();this.emptyListe(); */
this.addExtension(FilterBioSilico.ph2);
this.addExtension(FilterBioSilico.gatorg);
Expand Down
Loading