-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneticInvaderGeneDensity.m
More file actions
33 lines (30 loc) · 919 Bytes
/
Copy pathGeneticInvaderGeneDensity.m
File metadata and controls
33 lines (30 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
classdef GeneticInvaderGeneDensity < GeneticInvaderGene & handle
properties (Constant)
MAX = 36
SEED = 24
end
methods
function obj = GeneticInvaderGeneDensity()
obj = obj@GeneticInvaderGene();
obj.setValue(GeneticInvaderGeneDensity.SEED);
end
function setValue(obj, d)
obj.value = obj.checkValue(d);
end
function v = getVariedValue(obj)
randFactor = randn(1)/10 * 2.25;
v = obj.value + (obj.value * randFactor);
v = obj.checkValue(v);
end
end
methods (Access=private)
function v = checkValue(~, v)
% enforce density values >= 1 and <= 36
if v > GeneticInvaderGeneDensity.MAX
v = GeneticInvaderGeneDensity.MAX;
elseif v < 1
v = 1;
end
end
end
end