memory.py 747 Bytes
import numpy as np
from collections import deque

import config


class Memory:
    def __init__(self, memory_size):
        self.MEMORY_SIZE = config.MEMORY_SIZE or memory_size
        self.ltmemory = deque(maxlen=self.MEMORY_SIZE)
        self.stmemory = deque(maxlen=self.MEMORY_SIZE)

    # 학습할 때
    # 인덱스
    # state_check

    # AV는 label

    def commit_stmemory(self, state, action_value):
        self.stmemory.append({
            'state': state.state_check
            , 'AV': action_value
        })

    def commit_ltmemory(self):
        for i in self.stmemory:
            self.ltmemory.append(i)
        self.clear_stmemory()

    def clear_stmemory(self):
        self.stmemory = deque(maxlen=config.MEMORY_SIZE)