-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
23 lines (20 loc) · 816 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# utils.py
import numpy as np
def process_state(state):
"""
Process the raw state from the environment into the format expected by the neural network.
"""
# Example: Extract RGB observation and resize
rgb = state['pov'] # Assuming 'pov' key contains the image
rgb = rgb.transpose((2, 0, 1)) # Convert to (C, H, W)
rgb = rgb / 255.0 # Normalize pixel values
return rgb
def simulate_action(env, state, action):
"""
Simulate taking an action from a given state.
This is a placeholder function; in practice, you need a way to predict the next state.
"""
# Since we can't step the environment without changing its state,
# you might need to create a copy or use a model to predict the next state.
# For simplicity, we'll return None here.
return None