forked from FSTT-LIST/RewardEngine_Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VariableRatioSchedule.cs
49 lines (39 loc) · 1.26 KB
/
VariableRatioSchedule.cs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
namespace com.glups.Reward
{
public class VariableRatioSchedule : RewardStrategy
{
// the static values need to be defined
// These values can be adapted to the game. In our case, our mean value is 10.
private int _variableThreshold = 0;
public VariableRatioSchedule(RewardModel model, StrategyParameters p) : base(model, p)
{
}
internal override string name()
{
return "VRS";
}
internal override int addPositive(int points)
{
return _model.addPositive(points, points);
}
internal override int addNegative(int points)
{
return _model.addNegative(points, 0);
}
internal override int updateReward()
{
// computes the next Threshold with some random values (Variable)
if (_variableThreshold == 0)
{
_variableThreshold = _parameters.computeVariableSchedule();
}
int rewards = _model.updateReward(_variableThreshold);
if (rewards > 0)
{
// ask to update the threshold in the next call
_variableThreshold = 0;
}
return rewards;
}
}
}