forked from Shushman/16-831-Class-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAgent.m
37 lines (31 loc) · 1013 Bytes
/
Agent.m
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
classdef Agent < handle
%AGENT One who actively moves around with a policy and collects reward
properties
policy
cumReward % cumulative reward
game
site
f
g
h
end
methods
function self = Agent(policy, game)
self.policy = policy;
self.game = game;
self.cumReward = 0;
self.site = 0; %initial site
self.f = game.f;
self.g = game.g;
self.h = game.h;
end
function [reward, nextsite, cumReward, satisf, waitTime] = ride(self)
nextsite = self.policy.decision(self.site, self.game.round);
[dist, waitTime, satisf] = self.game.get_eltwise_reward(self.site, nextsite);
reward = -self.f*dist - self.g*waitTime + self.h*satisf;
self.cumReward = self.cumReward + reward;
cumReward = self.cumReward;
self.site = nextsite;
end
end
end