-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathController.cs
More file actions
89 lines (76 loc) · 2.75 KB
/
Controller.cs
File metadata and controls
89 lines (76 loc) · 2.75 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// the test controller of our library
namespace com.glups.Reward
{
public class Controller
{
internal RewardModel _model;
internal RewardStrategy _FRS, _VRS, _VIS, _FIS;
internal RewardStrategy? _currentStrategy;
internal View _view;
public Controller(RewardModel model, View view)
{
_model = model;
StrategyParameters parameters = new StrategyParameters();
_FRS = new FixedRatioSchedule(_model, parameters);
_FIS = new FixedIntervalSchedule(_model, parameters);
_VRS = new VariableRatioSchedule(_model, parameters);
_VIS = new VariableIntervalSchedule(_model, parameters);
_view = view;
_currentStrategy = null;
}
internal virtual void openLevel(int level)
{
_model.openLevel(level);
_currentStrategy = _FIS;
}
internal virtual void traceModel(int date, int playerID)
{
string strategyName = "?";
if (_currentStrategy != null)
{
strategyName = _currentStrategy.name();
}
_model.trace(date, playerID, strategyName);
}
internal virtual void addPositive(int nsuccess)
{
if (_currentStrategy == null)
{
Console.Error.WriteLine("Controller: must select a strategy before calling addPositive");
return;
}
_currentStrategy.addPositive(nsuccess); // this returns the iScore
//_view.updatePositiveScore(_model.getScore(), _model.getRewardScore());
int rank = _currentStrategy.updateRank();
if (rank > 0)
{
_view.updateRank(rank);
}
int reward = _currentStrategy.updateReward();
if (reward > 0)
{
_view.updateReward(reward);
}
}
internal virtual void addNegative(int nfailure)
{
if (_currentStrategy == null)
{
Console.Error.WriteLine("Controller: must select a strategy before calling addNegative");
return;
}
_currentStrategy.addNegative(nfailure); // this returns the iScore
//_view.updateNegativeScore(_model.getScore(), _model.getRewardScore());
int rank = _currentStrategy.updateRank();
if (rank > 0)
{
_view.updateRank(rank);
}
int reward = _currentStrategy.updateReward();
if (reward > 0)
{
_view.updateReward(reward);
}
}
}
}