source: java/main/src/main/java/com/framsticks/model/Creature.java @ 86

Last change on this file since 86 was 86, checked in by psniegowski, 11 years ago

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 size: 4.5 KB
RevLine 
[77]1package com.framsticks.model;
2
[86]3import com.framsticks.params.annotations.FramsClassAnnotation;
4import com.framsticks.params.annotations.ParamAnnotation;
[84]5import com.framsticks.util.math.Point3d;
[77]6
7import java.util.ArrayList;
8import java.util.List;
9
[86]10@FramsClassAnnotation
[79]11public class Creature {
[86]12
13        @ParamAnnotation
[77]14        public String name;
15
[86]16        @ParamAnnotation
[77]17        public String genotype;
18
[86]19        @ParamAnnotation
[77]20        public String info;
21
[86]22        @ParamAnnotation
[77]23        public Object group;
24
[86]25        @ParamAnnotation(id = "gnum")
26        public int generation;
[77]27
[86]28        @ParamAnnotation(id = "buildproblems")
29        public int buildProblems;
[77]30
[86]31        @ParamAnnotation(id = "energ0")
32        public double startingEnergy;
[77]33
[86]34        @ParamAnnotation(id = "idleen")
35        public double idlePowerConsumption;
[77]36
[86]37        @ParamAnnotation
38        public double energy;
[77]39
[86]40        @ParamAnnotation(id = "energy_p")
41        public double energyIncome;
[77]42
[86]43        @ParamAnnotation(id = "energy_m")
44        public double energyCosts;
[77]45
[86]46        @ParamAnnotation(id = "energy_b")
47        public double energyBalance;
[77]48
[86]49        @ParamAnnotation(id = "perf")
50        public int performanceCalculation;
[77]51
[86]52        @ParamAnnotation(id = "nnenabled")
53        public boolean neuralNetworkEnabled;
[77]54
[86]55        @ParamAnnotation(id = "bodysim")
56        public boolean bodySimulation;
[77]57
[86]58        @ParamAnnotation(id = "selfcol")
59        public boolean selfCollisions;
[77]60
[86]61        @ParamAnnotation(id = "lifespan")
62        public int lifeSpan;
[77]63
[86]64        @ParamAnnotation
65        public double distance;
[77]66
[86]67        @ParamAnnotation(id = "c_velocity")
68        public double currentVelocity;
[77]69
[86]70        @ParamAnnotation(id = "c_vertvelocity")
71        public double currentVerticalVelocity;
[77]72
[86]73        @ParamAnnotation(id = "c_vertpos")
74        public double currentVerticalPosition;
[77]75
[86]76        @ParamAnnotation(id = "velocity")
77        public double averageVelocity;
[77]78
[86]79        @ParamAnnotation(id = "vertvel")
80        public double averageVerticalVelocity;
[77]81
[86]82        @ParamAnnotation(id = "vertpos")
83        public double averageVerticalPosition;
[77]84
[86]85        @ParamAnnotation
[78]86        public double pos_x, pos_y, pos_z;
[77]87
[78]88        public Point3d getPosition() { return new Point3d(pos_x, pos_y, pos_z) ; }
89        public void setPosition(Point3d pos) { pos_x = pos.x; pos_y = pos.y; pos_z = pos.z; }
[77]90
[86]91        @ParamAnnotation
[78]92        public double size_x, size_y, size_z;
[77]93
[78]94        public Point3d getBoundingBox() { return new Point3d(size_x, size_y, size_z) ; }
95        public void setBoundingBox(Point3d size) { size_x = size.x; size_y = size.y; size_z = size.z; }
[77]96
97
[78]98        /** center_x, center_y, center_z*/
[86]99        @ParamAnnotation
[78]100        public double center_x, center_y, center_z;
[77]101
[78]102        public Point3d getCenter() { return new Point3d(center_x, center_y, center_z) ; }
103        public void setCenter(Point3d center) { center_x = center.x; center_y = center.y; center_z = center.z; }
[77]104
[86]105        @ParamAnnotation
106        public int getNumparts() { return parts.size(); }
107        @ParamAnnotation
108        public void setNumparts(int numparts) { }
[77]109
[86]110        @ParamAnnotation
111        public int getNumjoints() { return joints.size(); }
112        @ParamAnnotation
113        public void setNumjoints(int numjoints) { }
[77]114
[86]115        @ParamAnnotation
116        public int getNumneurons() { return neurons.size(); }
117        @ParamAnnotation
118        public void setNumneurons(int numneurons) { }
[77]119
120        public Object[] userFields = new Object[3];
[86]121        @ParamAnnotation
[77]122        public Object getUser1() { return userFields[0]; }
[86]123        @ParamAnnotation
[77]124        public void setUser1(Object user1) { userFields[0] = user1; }
125
[86]126        @ParamAnnotation
[77]127        public Object getUser2() { return userFields[1]; }
[86]128        @ParamAnnotation
[77]129        public void setUser2(Object user2) { userFields[1] = user2; }
130
[86]131        @ParamAnnotation
[77]132        public Object getUser3() { return userFields[2]; }
[86]133        @ParamAnnotation
[77]134        public void setUser3(Object user3) { userFields[2] = user3; }
135
[86]136        @ParamAnnotation(id = "selfmask")
137        public int selfCollisionMask;
[77]138
[86]139        @ParamAnnotation(id = "othermask")
140        public int otherCollisionMask;
[77]141
[86]142        @ParamAnnotation(id = "selfcolstate")
143        public boolean selfCollisionsState;
144
145        @ParamAnnotation
[77]146        public String uid;
147
[86]148        @ParamAnnotation
149        public int index;
[77]150
[86]151        @ParamAnnotation
[77]152        public final List<Part> parts = new ArrayList<Part>();
[86]153        @ParamAnnotation
[77]154        public final List<Joint> joints = new ArrayList<Joint>();
[86]155        @ParamAnnotation
[77]156        public final List<NeuroDef> neurodefs = new ArrayList<NeuroDef>();
157
[78]158        public final List<Part> getParts() { return parts; }
159        public final List<Joint> getJoints() { return joints; }
160        public final List<NeuroDef> getNeuroDefs() { return neurodefs; }
[77]161
[86]162        @ParamAnnotation
[79]163        public final List<MechPart> mechparts = new ArrayList<MechPart>();
[86]164        @ParamAnnotation
[79]165        public final List<MechJoint> mechjoints = new ArrayList<MechJoint>();
[86]166        @ParamAnnotation
[79]167        public final List<Neuro> neurons = new ArrayList<Neuro>();
[78]168
[79]169        public final List<MechPart> getMechParts() { return mechparts; }
170        public final List<MechJoint> getMechJoints() { return mechjoints; }
171        public final List<Neuro> getNeurons() { return neurons; }
[78]172
[77]173}
Note: See TracBrowser for help on using the repository browser.