Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ice causes the agent to get thrown out of the map in ChopTree-v0 #4

Open
francelico opened this issue Dec 23, 2024 · 0 comments
Open

Comments

@francelico
Copy link

Minetest version

Minetest 5.9.0-dev-a066bdac1-dirty (Linux)
Using LuaJIT 2.1.0-beta3
Built by GCC 11.4
Running on Linux/6.5.0-1025-azure x86_64
BUILD_TYPE=Release
RUN_IN_PLACE=1
USE_CURL=1
USE_GETTEXT=1
USE_SOUND=1
STATIC_SHAREDIR="."
STATIC_LOCALEDIR="locale"

Irrlicht device

not sure

Operating system and version

Ubuntu 22.04

CPU model

AMD EPYC 7V13 64-Core Processor

GPU model

Nvidia A100 80GB

Active renderer

not sure

Summary

This is my first time running Craftium. I started with running Craftium/ChopTree-v0 with random actions while recording the agent observations, to confirm everything worked fine. See Steps to reproduce for the code.

At some point, the agent appears to get ejected upwards, far about the cloud cover of the map. I believe this happens after it jumps on something that looks like an ice patch, or perhaps water.

See the recorded video, around 2:07 mark. After the agent hits the ice, the forest can briefly be seen from above. The agent appears to cross the cloud cover of the map a few frames later.

test_1.mp4

Steps to reproduce

The video was obtained using the following code:

from xvfbwrapper import Xvfb
import pickle
import os
import numpy as np
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
import tyro
import gymnasium as gym
import craftium
from dataclasses import dataclass

@dataclass
class Args:
    model: str = "models/3x.model"
    "path to the model skeleton (not used)"
    weights: str = "models/BC-house-3x.weights (not used)"
    "path to the model weights"
    record_video: bool = False
    "capture a video of the agent's view"
    save_video_to: str = "videos/latest.mp4"
    "save path for the video"
    num_frames: int = 24*60
    "number of frames to record when recording a video"

def main(args):
    env = gym.make("Craftium/ChopTree-v0")

    observation, info = env.reset()

    recorded_frames = []
    for t in range(args.num_frames):
        if args.record_video:
            recorded_frames.append(observation)
        action = env.action_space.sample()  # get a random action
        observation, reward, terminated, truncated, _info = env.step(action)

        if terminated or truncated:
            observation, info = env.reset()

    if args.record_video:
        clip = ImageSequenceClip(recorded_frames, fps=24)
        if not os.path.exists(os.path.dirname(args.save_video_to)):
            os.makedirs(f"videos", exist_ok=True)
        clip.write_videofile(args.save_video_to, logger="bar")

    env.close()

if __name__ == "__main__":

    args = tyro.cli(Args)
    vdisplay = Xvfb()
    vdisplay.start()
    main(args)
    vdisplay.stop()

Terminal output

==> Creating Minetest run directory: ./minetest-run-876af1d7-3032-4e54-9ba4-1ca781ed239a
Moviepy - Building video videos/test.mp4.
Moviepy - Writing video videos/test.mp4

Moviepy - Done !
Moviepy - video ready videos/test.mp4

Process finished with exit code 0

Note: What happens to the run directory upon script completion? I can find them inside ~/craftium when the run script crashes. However I cannot find the run directories when the python script finishes correctly (i.e. exit code 0). The run directory gets created, but it either gets deleted or is moved somewhere else upon script completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant