barsuift.simLife.tree
Class BasicTreeBranchPart

java.lang.Object
  extended by barsuift.simLife.tree.BasicTreeBranchPart
All Implemented Interfaces:
LivingPart, Persistent<State>, TreeBranchPart, java.util.Observer

public class BasicTreeBranchPart
extends java.lang.Object
implements TreeBranchPart


Constructor Summary
BasicTreeBranchPart(Universe universe, TreeBranchPartState state)
           
 
Method Summary
protected  boolean canCreateOneNewLeaf()
           
protected  boolean canIncreaseOneLeafSize()
           
 java.math.BigDecimal collectFreeEnergy()
           
protected  javax.vecmath.Point3d computeAttachPointForNewLeaf()
           
protected  void createOneNewLeaf()
           
 int getAge()
           
 TreeBranchPart3D getBranchPart3D()
           
 java.math.BigDecimal getEnergy()
           
 java.util.List<TreeLeaf> getLeaves()
           
 int getNbLeaves()
           
protected  TreeLeaf getRandomLeafToIncrease()
          Returns one random leaf, with max odd to smallest leaf
 TreeBranchPartState getState()
           
protected  void increaseOneLeafSize()
           
protected  boolean shouldCreateOneNewLeaf()
          Test if we should create a new leaf or not.
protected  boolean shouldIncreaseOneLeafSize()
          Test if we should increase a leaf size or not.
 void spendTime()
          Make all leaves spend time.
 void synchronize()
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicTreeBranchPart

public BasicTreeBranchPart(Universe universe,
                           TreeBranchPartState state)
Method Detail

getAge

public int getAge()
Specified by:
getAge in interface LivingPart

spendTime

public void spendTime()
Make all leaves spend time.

Specified by:
spendTime in interface LivingPart

increaseOneLeafSize

protected void increaseOneLeafSize()

getRandomLeafToIncrease

protected TreeLeaf getRandomLeafToIncrease()
Returns one random leaf, with max odd to smallest leaf


canIncreaseOneLeafSize

protected boolean canIncreaseOneLeafSize()

shouldIncreaseOneLeafSize

protected boolean shouldIncreaseOneLeafSize()
Test if we should increase a leaf size or not. The result is a random function with :
  1. 0% odd to be true if energy <= increaseLeafCost
  2. 100% odd to be true if energy >= 5 * increaseLeafCost
  3. a linear progression between the two values


canCreateOneNewLeaf

protected boolean canCreateOneNewLeaf()

shouldCreateOneNewLeaf

protected boolean shouldCreateOneNewLeaf()
Test if we should create a new leaf or not. The result is a random function with :
  1. 0% odd to be true if energy < totalLeafCreationCost
  2. 100% odd to be true if energy >= 2 * totalLeafCreationCost
  3. a linear progression between the two values


createOneNewLeaf

protected void createOneNewLeaf()

computeAttachPointForNewLeaf

protected javax.vecmath.Point3d computeAttachPointForNewLeaf()

getEnergy

public java.math.BigDecimal getEnergy()
Specified by:
getEnergy in interface TreeBranchPart

collectFreeEnergy

public java.math.BigDecimal collectFreeEnergy()
Specified by:
collectFreeEnergy in interface TreeBranchPart

getNbLeaves

public int getNbLeaves()
Specified by:
getNbLeaves in interface TreeBranchPart

getLeaves

public java.util.List<TreeLeaf> getLeaves()
Specified by:
getLeaves in interface TreeBranchPart

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

getState

public TreeBranchPartState getState()
Specified by:
getState in interface Persistent<State>

synchronize

public void synchronize()
Specified by:
synchronize in interface Persistent<State>

getBranchPart3D

public TreeBranchPart3D getBranchPart3D()
Specified by:
getBranchPart3D in interface TreeBranchPart


Copyright © 2010. All Rights Reserved.