Ignore:
Timestamp:
06/26/13 13:27:31 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • use java annotations to mark classes and fields to be used when:
    • using java classes with ReflectionAccess? to represent remote objects with FramsClass? description found by "info ..." requests
    • to build up FramsClass? representation of objects not present at remote server
  • allow using primitive types (instead of wraping counterparts) in reflected classes
  • rework FramsClass? creation process (add FramsClassBuilder?)
  • add more tests

CHANGELOG:
Prepare model.World class.

Minor change.

Use primitive types for Genotype and Creature classes.

Use primitive types in model.Neuro* classes.

Use primitive types in model.Joint* classes.

Use primitive types in model.Part* classes.

Fix primitive values.

Extract FramsClassBuilder?.

Add tests of Model classes.

More fixes.

Refactorize out ParamCandidate?.

Several fixes.

Fix all regressions after introducing annotations.

Use annotations throughout the project.

Add exception classes.

Improve creation of FramsClass?.

More changes.

Many changes regarding annotations.

Annotate classes in com.framsticks.model package.

Remove manual FramsClass? constructor.

Construct FramsClass? for Creature. Add test.

Add default values to the ParamAnnotation?.

Add ParamBuilderTest? and ParamAnnotation?.

Add FramsClassAnnotation?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/model/Creature.java

    r84 r86  
    11package com.framsticks.model;
    22
    3 import com.framsticks.params.FramsClass;
     3import com.framsticks.params.annotations.FramsClassAnnotation;
     4import com.framsticks.params.annotations.ParamAnnotation;
    45import com.framsticks.util.math.Point3d;
    56
     
    78import java.util.List;
    89
     10@FramsClassAnnotation
    911public class Creature {
     12
     13        @ParamAnnotation
    1014        public String name;
    1115
     16        @ParamAnnotation
    1217        public String genotype;
    1318
     19        @ParamAnnotation
    1420        public String info;
    1521
     22        @ParamAnnotation
    1623        public Object group;
    1724
    18         public Integer generation;
    19         public Integer getGnum() { return generation; }
    20         public void setGnum(Integer gnum) { generation = gnum; }
     25        @ParamAnnotation(id = "gnum")
     26        public int generation;
    2127
    22         public Integer buildProblems;
    23         public Integer getBuildproblems() { return buildProblems; }
    24         public void setBuildproblems(Integer buildproblems) { buildProblems = buildproblems; }
     28        @ParamAnnotation(id = "buildproblems")
     29        public int buildProblems;
    2530
    26         public Double startingEnergy;
    27         public Double getEnerg0() { return startingEnergy; }
    28         public void setEnerg0(Double energ0) { startingEnergy = energ0; }
     31        @ParamAnnotation(id = "energ0")
     32        public double startingEnergy;
    2933
    30         public Double idlePowerConsumption;
    31         public Double getIdleen() { return idlePowerConsumption; }
    32         public void setIdleen(Double idleen) { idlePowerConsumption = idleen; }
     34        @ParamAnnotation(id = "idleen")
     35        public double idlePowerConsumption;
    3336
    34         public Double energy;
     37        @ParamAnnotation
     38        public double energy;
    3539
    36         public Double energyIncome;
    37         public Double getEnergy_p() { return energyIncome; }
    38         public void setEnergy_p(Double energy_p) { energyIncome = energy_p; }
     40        @ParamAnnotation(id = "energy_p")
     41        public double energyIncome;
    3942
    40         public Double energyCosts;
    41         public Double getEnergy_m() { return energyCosts; }
    42         public void setEnergy_m(Double energy_m) { energyCosts = energy_m; }
     43        @ParamAnnotation(id = "energy_m")
     44        public double energyCosts;
    4345
    44         public Double energyBalance;
    45         public Double getEnergy_b() { return energyBalance; }
    46         public void setEnergy_b(Double energy_b) { energyBalance = energy_b; }
     46        @ParamAnnotation(id = "energy_b")
     47        public double energyBalance;
    4748
    48         public Integer performanceCalculation;
    49         public Integer getPerf() { return performanceCalculation; }
    50         public void setPerf(Integer perf) { performanceCalculation = perf; }
     49        @ParamAnnotation(id = "perf")
     50        public int performanceCalculation;
    5151
    52         public Boolean neuralNetworkEnabled;
     52        @ParamAnnotation(id = "nnenabled")
     53        public boolean neuralNetworkEnabled;
    5354
    54         public Boolean getNnenabled() { return neuralNetworkEnabled; }
    55         public void setNnenabled(Boolean nnenabled) { neuralNetworkEnabled = nnenabled; }
     55        @ParamAnnotation(id = "bodysim")
     56        public boolean bodySimulation;
    5657
    57         public Boolean bodySimulation;
    58         public Boolean getBodysim() { return bodySimulation; }
    59         public void setBodysim(Boolean bodysim) { bodySimulation = bodysim; }
     58        @ParamAnnotation(id = "selfcol")
     59        public boolean selfCollisions;
    6060
    61         public Boolean selfCollisions;
    62         public Boolean getSelfcol() { return selfCollisions; }
    63         public void setSelfcol(Boolean selfcol) { selfCollisions = selfcol; }
     61        @ParamAnnotation(id = "lifespan")
     62        public int lifeSpan;
    6463
    65         public Integer lifeSpan;
    66         public Integer getLifespan() { return lifeSpan; }
    67         public void setLifespan(Integer lifespan) { lifeSpan = lifespan; }
     64        @ParamAnnotation
     65        public double distance;
    6866
    69         public Double distance;
     67        @ParamAnnotation(id = "c_velocity")
     68        public double currentVelocity;
    7069
    71         public Double currentVelocity;
    72         public Double getC_velocity() { return currentVelocity; }
    73         public void setC_velocity(Double c_velocity) { currentVelocity = c_velocity; }
     70        @ParamAnnotation(id = "c_vertvelocity")
     71        public double currentVerticalVelocity;
    7472
    75         public Double currentVerticalVelocity;
    76         public Double getC_vertvelocity() { return currentVerticalVelocity; }
    77         public void setC_vertvelocity(Double c_vertvelocity) { currentVerticalVelocity = c_vertvelocity; }
     73        @ParamAnnotation(id = "c_vertpos")
     74        public double currentVerticalPosition;
    7875
    79         public Double currentVerticalPosition;
    80         public Double getC_vertpos() { return currentVerticalPosition; }
    81         public void setC_vertpos(Double c_vertpos) { currentVerticalPosition = c_vertpos; }
     76        @ParamAnnotation(id = "velocity")
     77        public double averageVelocity;
    8278
    83         public Double averageVelocity;
    84         public Double getVelocity() { return averageVelocity; }
    85         public void setVelocity(Double c_velocity) { averageVelocity = c_velocity; }
     79        @ParamAnnotation(id = "vertvel")
     80        public double averageVerticalVelocity;
    8681
    87         public Double averageVerticalVelocity;
    88         public Double getVertvel() { return averageVerticalVelocity; }
    89         public void setVertvel(Double c_vertvelocity) { averageVerticalVelocity = c_vertvelocity; }
     82        @ParamAnnotation(id = "vertpos")
     83        public double averageVerticalPosition;
    9084
    91         public Double averageVerticalPosition;
    92         public Double getVertpos() { return averageVerticalPosition; }
    93         public void setVertpos(Double c_vertpos) { averageVerticalPosition = c_vertpos; }
    94 
    95         /** pos_x, pos_y, pos_z*/
     85        @ParamAnnotation
    9686        public double pos_x, pos_y, pos_z;
    9787
     
    9989        public void setPosition(Point3d pos) { pos_x = pos.x; pos_y = pos.y; pos_z = pos.z; }
    10090
     91        @ParamAnnotation
    10192        public double size_x, size_y, size_z;
    10293
     
    10697
    10798        /** center_x, center_y, center_z*/
     99        @ParamAnnotation
    108100        public double center_x, center_y, center_z;
    109101
     
    111103        public void setCenter(Point3d center) { center_x = center.x; center_y = center.y; center_z = center.z; }
    112104
    113         public Integer getNumparts() { return parts.size(); }
    114         public void setNumparts(Integer numparts) { }
     105        @ParamAnnotation
     106        public int getNumparts() { return parts.size(); }
     107        @ParamAnnotation
     108        public void setNumparts(int numparts) { }
    115109
    116         public Integer getNumjoints() { return joints.size(); }
    117         public void setNumjoints(Integer numjoints) { }
     110        @ParamAnnotation
     111        public int getNumjoints() { return joints.size(); }
     112        @ParamAnnotation
     113        public void setNumjoints(int numjoints) { }
    118114
    119         public Integer getNumneurons() { return neurons.size(); }
    120         public void setNumneurons(Integer numneurons) { }
     115        @ParamAnnotation
     116        public int getNumneurons() { return neurons.size(); }
     117        @ParamAnnotation
     118        public void setNumneurons(int numneurons) { }
    121119
    122120        public Object[] userFields = new Object[3];
     121        @ParamAnnotation
    123122        public Object getUser1() { return userFields[0]; }
     123        @ParamAnnotation
    124124        public void setUser1(Object user1) { userFields[0] = user1; }
    125125
     126        @ParamAnnotation
    126127        public Object getUser2() { return userFields[1]; }
     128        @ParamAnnotation
    127129        public void setUser2(Object user2) { userFields[1] = user2; }
    128130
     131        @ParamAnnotation
    129132        public Object getUser3() { return userFields[2]; }
     133        @ParamAnnotation
    130134        public void setUser3(Object user3) { userFields[2] = user3; }
    131135
    132         public Integer selfCollisionMask;
    133         public Integer getSelfmask() { return selfCollisionMask; }
    134         public void setSelfmask(Integer selfmask) { selfCollisionMask = selfmask; }
     136        @ParamAnnotation(id = "selfmask")
     137        public int selfCollisionMask;
    135138
    136         public Integer otherCollisionMask;
    137         public Integer getOthermask() { return otherCollisionMask; }
    138         public void setOthermask(Integer othermask) { otherCollisionMask = othermask; }
     139        @ParamAnnotation(id = "othermask")
     140        public int otherCollisionMask;
    139141
     142        @ParamAnnotation(id = "selfcolstate")
     143        public boolean selfCollisionsState;
     144
     145        @ParamAnnotation
    140146        public String uid;
    141147
    142         public Integer index;
     148        @ParamAnnotation
     149        public int index;
    143150
     151        @ParamAnnotation
    144152        public final List<Part> parts = new ArrayList<Part>();
     153        @ParamAnnotation
    145154        public final List<Joint> joints = new ArrayList<Joint>();
     155        @ParamAnnotation
    146156        public final List<NeuroDef> neurodefs = new ArrayList<NeuroDef>();
    147157
     
    150160        public final List<NeuroDef> getNeuroDefs() { return neurodefs; }
    151161
     162        @ParamAnnotation
    152163        public final List<MechPart> mechparts = new ArrayList<MechPart>();
     164        @ParamAnnotation
    153165        public final List<MechJoint> mechjoints = new ArrayList<MechJoint>();
     166        @ParamAnnotation
    154167        public final List<Neuro> neurons = new ArrayList<Neuro>();
    155168
     
    158171        public final List<Neuro> getNeurons() { return neurons; }
    159172
    160 
    161 
    162         public static void constructFramsClass(FramsClass.Constructor constructor) {
    163                 constructor.field("name");
    164                 constructor.field("parts");
    165                 constructor.field("joints");
    166                 constructor.field("neurodefs");
    167                 constructor.field("mechparts");
    168                 constructor.field("mechjoints");
    169                 constructor.field("neurons");
    170         }
    171 
    172173}
Note: See TracChangeset for help on using the changeset viewer.