Skip to content

Half Shape (320 x 240) instead of (640x480) in Saturn Game #137

Open
@paulo101977

Description

@paulo101977

I was trying to train using the Virtual Fighter 2 environment on Saturn, and I came across a problem: the observations are appearing cut off. The image frame is cut off. I believe the resolution of the original game would be around 640x480, but the shape is showing in the observation as 320x240.

I used the code below to do the preliminary work of doing the training:

import retro
from stable_baselines3.common.atari_wrappers import ClipRewardEnv, WarpFrame
from gymnasium.wrappers import RecordVideo
import cv2
import numpy as np
import matplotlib.pyplot as plt

def preprocess_observation(obs):
    resized = cv2.resize(obs, (640, 480))
    
    padded = cv2.copyMakeBorder(resized, 20, 20, 10, 10, cv2.BORDER_CONSTANT, value=[0, 0, 0])

    return padded

env = retro.make(
    game="VirtuaFighter2-Saturn",
    render_mode="human",
    inttype=retro.data.Integrations.ALL,
)


# env = display.GameDisplayEnv(env)
env = WarpFrame(env)

obs = env.reset()

while True:
    env.render()
    action = env.action_space.sample()
    env.render()
    observation, reward, terminated, truncated, info = env.step(action)
    processed = preprocess_observation(observation)
    
    
    cv2.imshow("Processed Frame", processed)
    cv2.waitKey(1)
    
    
    if terminated or truncated:
        break
env.close()
cv2.destroyAllWindows()

Images of the problem:

Image

Image

Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions