-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomStartAgent.py
More file actions
23 lines (20 loc) · 890 Bytes
/
RandomStartAgent.py
File metadata and controls
23 lines (20 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from CognitiveAgent import CognitiveAgent
import numpy as np
class FixedStartAgent(CognitiveAgent):
def __init__(self, currentAction=None, fftSize=1024, cpiLen=256, rng=None):
super().__init__(currentAction, fftSize, cpiLen)
if currentAction==None:
self.takeRandomAction(rng=rng)
def takeRandomAction(self, rng=None, min_true=30, max_true=102):
if max_true > self.fftSize:
raise ValueError("max_true cannot exceed fftSize")
start = 0
length = 0
if rng == None:
length = np.random.randint(min_true, max_true + 1)
start = np.random.randint(0, self.fftSize - length + 1)
else:
length = rng.integers(min_true, max_true + 1)
start = rng.integers(0, self.fftSize - length + 1)
stop = start + length
self.currentAction = (start, stop)