adjusted fps in simple_factory.py
This commit is contained in:
@ -4,6 +4,7 @@ from pathlib import Path
|
||||
from collections import deque
|
||||
import pygame
|
||||
from typing import NamedTuple
|
||||
import time
|
||||
|
||||
|
||||
class Entity(NamedTuple):
|
||||
@ -20,7 +21,7 @@ class Renderer:
|
||||
AGENT_VIEW_COLOR = (9, 132, 227)
|
||||
ASSETS = Path(__file__).parent / 'assets'
|
||||
|
||||
def __init__(self, grid_w=16, grid_h=16, cell_size=40, fps=4, grid_lines=True, view_radius=2):
|
||||
def __init__(self, grid_w=16, grid_h=16, cell_size=40, fps=8, grid_lines=True, view_radius=2):
|
||||
self.grid_h = grid_h
|
||||
self.grid_w = grid_w
|
||||
self.cell_size = cell_size
|
||||
@ -35,6 +36,12 @@ class Renderer:
|
||||
self.assets = {path.stem: self.load_asset(str(path), 1) for path in assets}
|
||||
self.fill_bg()
|
||||
|
||||
now = time.time()
|
||||
font1 = pygame.font.Font(None, 24)
|
||||
print('Loading System font with pygame.font.Font took', time.time() - now)
|
||||
|
||||
|
||||
|
||||
def fill_bg(self):
|
||||
self.screen.fill(Renderer.BG_COLOR)
|
||||
if self.grid_lines:
|
||||
|
@ -46,7 +46,7 @@ class SimpleFactory(BaseFactory):
|
||||
|
||||
if not self._renderer: # lazy init
|
||||
height, width = self._state.shape[1:]
|
||||
self._renderer = Renderer(width, height, view_radius=self.pomdp_radius)
|
||||
self._renderer = Renderer(width, height, view_radius=self.pomdp_radius, fps=9)
|
||||
|
||||
dirt = [Entity('dirt', [x, y], min(0.15 + self._state[DIRT_INDEX, x, y], 1.5), 'scale')
|
||||
for x, y in np.argwhere(self._state[DIRT_INDEX] > h.IS_FREE_CELL)]
|
||||
|
Reference in New Issue
Block a user