Code Monkey home page Code Monkey logo

wilderness-scavenger's Introduction

Wilderness Scavenger: 3D Open-World FPS Game AI Challenge

This is a platform for intelligent agent learning based on a 3D open-world FPS game developed by Inspir.AI.

Change Log

  • 2022-08-15: removed raycaster libs of the Mac and Windows platforms, only Linux platform is supported currently!
  • 2022-05-16: improved engine backend (Linux) with better stability (v1.0)
    • Check out Supported Platforms for download links.
    • Make sure to update to the latest version of the engine if you would like to use depth map or enemy state features.
  • 2022-05-18: updated engine backend for Windows and MacOS (v1.0)
  • 2022-05-30: added submission template and instructions for submitting solutions to the online evaluation system

Competition Overview

With a focus on learning intelligent agents in open-world games, this year we are hosting a new contest called Wilderness Scavenger. In this new game, which features a Battle Royale-style 3D open-world gameplay experience and a random PCG-based world generation, participants must learn agents that can perform subtasks common to FPS games, such as navigation, scouting, and skirmishing. To win the competition, agents must have strong perception of complex 3D environments and then learn to exploit various environmental structures (such as terrain, buildings, and plants) by developing flexible strategies to gain advantages over other competitors. Despite the difficulty of this goal, we hope that this new competition can serve as a cornerstone of research in AI-based gaming for open-world games.

Features

  • A light-weight 3D open-world FPS game developed with Unity3D game engine
  • Rendering-off game acceleration for fast training and evaluation
  • Large open world environment providing high freedom of agent behaviors
  • Highly customizable game configuration with random supply distribution and dynamic refresh
  • PCG-based map generation with randomly spawned buildings, plants and obstacles (100 training maps)
  • Interactive replay tool for game record visualization

Basic Structures

We developed this repository to provide a training and evaluation platform for the researchers interested in open-world FPS game AI. For getting started quickly, a typical workspace structure when using this repository can be summarized as follows:

.
├── examples  # providing starter code examples and training baselines
│   ├── envs/...
│   ├── basic.py
│   ├── basic_track1_navigation.py
│   ├── basic_track2_supply_gather.py
│   ├── basic_track3_supply_battle.py
│   ├── baseline_track1_navigation.py
│   ├── baseline_track2_supply_gather.py
│   └── baseline_track3_supply_battle.py
├── inspirai_fps  # the game play API source code
│   ├── lib/...
│   ├── __init__.py
│   ├── gamecore.py
│   ├── raycast_manager.py
│   ├── simple_command_pb2.py
│   ├── simple_command_pb2_grpc.py
│   └── utils.py
└── fps_linux  # the engine backend (Linux)
    ├── UnityPlayer.so
    ├── fps.x86_64
    ├── fps_Data/...
    └── logs/...
  • fps_linux (requires to be manually downloaded and unzipped to your working directory): the (Linux) engine backend extracted from our game development project, containing all the game related assets, binaries and source codes.
  • inspirai_fps: the python gameplay API for agent training and testing, providing the core Game class and other useful tool classes and functions.
  • examples: we provide basic starter codes for each game mode targeting each track of the challenge, and we also give out our implementation of some baseline solutions based on ray.rllib reinforcement learning framework.

Supported Platforms

We support the multiple platforms with different engine backends, including:

Installation (from source)

To use the game play API, you need to first install the package inspirai_fps by following the commands below:

git clone https://github.com/inspirai/wilderness-scavenger
cd wilderness-scavenger
pip install .

We recommend installing this package with python 3.8 (which is our development environment), so you may first create a virtual env using conda and finish installation:

$ conda create -n WildScav python=3.8
$ conda activate WildScav
(WildScav) $ pip install .

Installation (from PyPI)

Note: this may not be maintained in time. We strongly recommend using the installation method above

Alternatively, you can install the package from PyPI directly. But note that this will only install the gameplay API inspirai_fps, not the backend engine. So you still need to manually download the correct engine backend from the Supported Platfroms section.

pip install inspirai-fps

Loading Engine Backend

To successfully run the game, you need to make sure the game engine backend for your platform is downloaded and set the engine_dir parameter of the Game init function correctly. For example, here is a code snippet in the script example/basic.py:

from inspirai_fps import Game, ActionVariable
...
parser.add_argument("--engine-dir", type=str, default="../fps_linux")
...
game = Game(..., engine_dir=args.engine_dir, ...)

Loading Map Data

To get access to some features like realtime depth map computation or randomized player spawning, you need to load the map data and load them into the Game. After this, once you turn on the depth map rendering, the game server will automatically compute a depth map viewing from the player's first person perspective at each time step.

  1. Download map data from Google Drive or Feishu and decompress the downloaded file to your preferred directory (e.g., <WORKDIR>/map_data).
  2. Set map_dir parameter of the Game initializer accordingly
  3. Set the map_id as you like
  4. Turn on the function of depth map computation
  5. Turn on random start location to spawn agents at random places

Read the following code snippet in the script examples/basic.py as an example:

from inspirai_fps import Game, ActionVariable
...
parser.add_argument("--map-id", type=int, default=1)
parser.add_argument("--use-depth-map", action="store_true")
parser.add_argument("--random-start-location", action="store_true")
parser.add_argument("--map-dir", type=str, default="../map_data")
...
game = Game(map_dir=args.map_dir, ...)
game.set_map_id(args.map_id)  # this will load the valid locations of the specified map
...
if args.use_depth_map:
    game.turn_on_depth_map()
    game.set_depth_map_size(380, 220, 200)  # width (pixels), height (pixels), depth_limit (meters)
...
if args.random_start_location:
    for agent_id in range(args.num_agents):
        game.random_start_location(agent_id, indoor=False)  # this will randomly spawn the player at a valid outdoor location, or indoor location if indoor is True
...
game.new_episode()  # start a new episode, this will load the mesh of the specified map

Gameplay Visualization

We have also developed a replay visualization tool based on the Unity3D game engine. It is similar to the spectator mode common in multiplayer FPS games, which allows users to interactively follow the gameplay. Users can view an agent's action from different perspectives and also switch between multiple agents or different viewing modes (e.g., first person, third person, free) to see the entire game in a more immersive way. Participants can download the tool for their specific platforms here:

To use this tool, follow the instruction below:

  • Decompress the downloaded file to anywhere you prefer.
  • Turn on recording function with game.turn_on_record(). One record file will be saved at the end of each episode.

Find the replay files under the engine directory according to your platform:

  • Linux: <engine_dir>/fps_Data/StreamingAssets/Replay
  • Windows: <engine_dir>\FPSGameUnity_Data\StreamingAssets\Replay
  • MacOS: <engine_dir>/Contents/Resources/Data/StreamingAssets/Replay

Copy replay files you want to the replay tool directory according to your platform and start the replay tool.

For Windows users:

  • Copy the replay file (e.g. xxx.bin) into <replayer_dir>/FPSGameUnity_Data/StreamingAssets/Replay
  • Run FPSGameUnity.exe to start the application.

For MacOS users:

  • Copy the replay file (e.g. xxx.bin) into <replayer_dir>/Contents/Resources/Data/StreamingAssets/Replay
  • Run fps.app to start the application.

In the replay tool, you can:

  • Select the record you want to watch from the drop-down menu and click PLAY to start playing the record.
  • During the replay, users can make the following operations
    • Press Tab: pause or resume
    • Press E: switch observation mode (between first person, third person, free)
    • Press Q: switch between multiple agents
    • Press ECS: stop replay and return to the main menu

Q & A

Please feel free to join our WeChat group to ask questions about the platform and online evaluation.

wechat-group

wilderness-scavenger's People

Contributors

315930399 avatar fatedawnleon avatar lovewilling0923 avatar ruihan0495 avatar wangjitao1024 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wilderness-scavenger's Issues

About engine backend download

  • We have removed the default Linux engine backend from the source codes to reduce the size of the repo.
  • We will update download links of the engine backend for Windows, Linux and MacOS.
  • Two download sources (Google Drive and Feishu) are provided.

When I first try to acess this project, I can't run basic.py .I used the backend of linux.

Running Episodes ... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0% -:--:--
Traceback (most recent call last):
File "/home/leopold/marl/wilderness-scavenger/examples/basic.py", line 88, in
game.new_episode()
File "/home/leopold/marl/wilderness-scavenger/inspirai_fps/gamecore.py", line 796, in new_episode
self.__update_request()
File "/home/leopold/marl/wilderness-scavenger/inspirai_fps/gamecore.py", line 783, in __update_request
if self.__log_trajectory:
AttributeError: 'Game' object has no attribute '_Game__log_trajectory'

State里真的没有pixel信息吗

不管是在Readme中写的Agent State Variable还是代码中都没有看到任何的RGB pixel信息,
只有postion和direction, 还有深度图
感觉跟传统意义上理解的fps环境不太一样

关于评测的问题

请问目前各个赛道的评测是否已经确定,比如赛道1,其env_track1.py中定义的动作空间和观测空间过于简单,动作空间只有方向和速度,那么如果目标点在楼顶,则无法到达,因为没有jump动作。赛道2的多人对抗环境还没有定义,那么这部分封装gym环境是我们自己来做吗?

python visualize_depth_map.py报错

Loaded valid locations from ../map_data/001.json
concatenating texture: may result in visual artifacts
Server started ...
E0527 15:19:31.224830216 2967962 fork_posix.cc:70]           Fork support is only compatible with the epoll1 and poll polling strategies
Unity3D started ...
Unity3D connected ...
Server stopped ...
Unity3D killed ...

Windows环境问题2

gamecore.py中,600行
self.engine_process = subprocess.Popen(cmd.split(),stdout=f, stderr=f)
应当增加shell=True,否则没法启动backend,会报错[WinError 2] 系统找不到指定的文件。

Navigation Track中 agent返回的movespeed数据异常

请问 在Navigation Track中 agent返回的movespeed数据好像异常。

输入action为 walkdir [0, 90,180,270] walkspeed [3, 6] turn_lr [-3, 0 ,3]

打印发现agent movespeed 从0递增到 3000+ 而非说明中的 m/s

环境是 linux 的backend【5.16】

is it possible headless mode?

HI, inspirai.

I'm trying to train my model. I wonder is it possible headless mode? because, Unity enviornment is paused frequently. I had to click client for tackling this problem always... when I trained on windows.
In case of linux version, can possible headlees mode?

Is the depth map available for all tracks?

I checked submission_template/eval_track_1_1.py and game.turn_on_depth_map() is not called, so state.depth is None (same for other trucks).

Since game.set_depth_map_size(DEPTH_MAP_WIDTH, DEPTH_MAP_HEIGHT, DEPTH_MAP_FAR) is called, it seems that the depth map is available, right?

baseline中使用的ray版本?

直接pip install ray再运行baseline_track1会报错,求指教
Traceback (most recent call last):
File "baseline_track1_navigation.py", line 28, in
import ray
File "/opt/conda/envs/wildscav/lib/python3.8/site-packages/ray/init.py", line 72, in
import ray._raylet # noqa: E402
File "python/ray/_raylet.pyx", line 108, in init ray._raylet
File "/opt/conda/envs/wildscav/lib/python3.8/site-packages/ray/exceptions.py", line 7, in
from ray.core.generated.common_pb2 import RayException, Language, PYTHON
File "/opt/conda/envs/wildscav/lib/python3.8/site-packages/ray/core/generated/common_pb2.py", line 33, in
_descriptor.EnumValueDescriptor(
File "/opt/conda/envs/wildscav/lib/python3.8/site-packages/google/protobuf/descriptor.py", line 755, in new
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Windows下raycaster.dll读取失败

windows10, py3.8
通过“pip install .”安装的inspirai_fps
运行basic.py报错:

Traceback (most recent call last):
File "D:/inspirai_Wilderness Scavenger/code/wilderness-scavenger-master/examples/basic.py", line 53, in
game = Game(map_dir=args.map_dir, engine_dir=args.engine_dir, server_port=args.port)
File "D:\Users\Miniconda3\lib\site-packages\inspirai_fps\gamecore.py", line 364, in init
self._ray_tracer = RaycastManager(mesh_file_path)
File "D:\Users\Miniconda3\lib\site-packages\inspirai_fps\raycast_manager.py", line 46, in init
self.ray_lib = ctypes.CDLL(lib_path, winmode=0)
File "D:\Users\Miniconda3\lib\ctypes_init
.py", line 381, in init
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'D:\Users\Miniconda3\lib\site-packages\inspirai_fps\lib\raycaster.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Exception ignored in: <function RaycastManager.del at 0x0000024B9EFE68B0>
Traceback (most recent call last):
File "D:\Users\Miniconda3\lib\site-packages\inspirai_fps\raycast_manager.py", line 207, in del
self._free_mesh()
File "D:\Users\Miniconda3\lib\site-packages\inspirai_fps\raycast_manager.py", line 200, in _free_mesh
c_func = self.ray_lib.free_mesh
AttributeError: 'RaycastManager' object has no attribute 'ray_lib'

A little bug in gamecore.py ?

gamecore.py 第155行代码:self.dir_vec = dir_vec / np.linalg.norm(self.dir_vec)

应该是 self.dir_vec = dir_vec / np.linalg.norm(dir_vec) 吧?

打开环境报错

OSError: dlopen(/Users/mxj/digisky/qiyuan/wilderness-scavenger/inspirai_fps/lib/libraycaster.dylib, 0x0006): tried: '/Users/mxj/digisky/qiyuan/wilderness-scavenger/inspirai_fps/lib/libraycaster.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h'))

Windows basic.py 第二步 卡死

image
如图所示的game.make_action()第二次执行会很慢,有时候执行了多步以后也会执行很久?请问这是正常的吗?
python 3.8 windows10

windows环境问题

Hi~, 我看到 windows环境下 raycaster 没有实现,请问这个什么时候能支持呢,也就是说目前windows环境是无法获取depth_map是吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.