forked from miyosuda/unreal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperience_test.py
39 lines (28 loc) · 1008 Bytes
/
experience_test.py
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
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import unittest
from train.experience import Experience, ExperienceFrame
class TestExperience(unittest.TestCase):
def _add_frame(self, experience, reward):
frame = ExperienceFrame(0, reward, 0, False, 0, 0, 0)
experience.add_frame(frame)
def test_process(self):
experience = Experience(10)
for i in range(10):
if i == 5:
self._add_frame(experience, 1)
else:
self._add_frame(experience, 0)
self.assertTrue( experience.is_full() )
self.assertTrue( experience._top_frame_index == 0 )
self._add_frame(experience, 0)
self.assertTrue( experience._top_frame_index == 1 )
for i in range(100):
frames = experience.sample_rp_sequence()
self.assertTrue( len(frames) == 4 )
# Reward should be shewed here.
#print(frames[3].reward)
if __name__ == '__main__':
unittest.main()