forked from Shushman/16-831-Class-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAgent.m
36 lines (30 loc) · 1.1 KB
/
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
classdef Agent < handle
%AGENT One who actively moves around with a policy and collects reward
properties
policy
cumReward % cumulative reward
game
site
weightDist % weight on distance
weightWait % weight on wait time
weightRide % weight on ride satisfaction
end
methods
function self = Agent(policy, game)
self.policy = policy;
self.game = game;
self.cumReward = 0;
self.site = 0; %initial site
self.weightDist = game.weightDist;
self.weightWait = game.weightWait;
self.weightRide = game.weightRide;
end
function [reward, nextsite, cumReward, satisf, waitTime] = ride(self)
nextsite = self.policy.decision(self.site, self.game.round);
[reward, ~, waitTime, satisf] = self.game.get_reward(self.site, nextsite);
self.cumReward = self.cumReward + reward;
cumReward = self.cumReward;
self.site = nextsite;
end
end
end