CowHerd is a partially-observed reinforcement learning environment, where the player walks around an area and is rewarded for milking cows. The cows try to escape and the player can place fences to help capture them. The implementation of CowHerd is based on the Crafter environment.
You can play the game yourself with an interactive window and keyboard input.
The mapping from keys to actions, health level, and inventory state are printed
to the terminal.
# Install with GUI pip3 install 'cowherd[gui]' # Start the game cowherd # Alternative way to start the game python3 -m cowherd.run_gui
The following optional command line flags are available:
||800 800||Window size in pixels, used as width and height.|
||5||How many times to update the environment per second.|
||None||Record a video of the trajectory.|
||3||The number of cows in the environment.|
||7 7||The layout size in cells; determines view distance.|
||None||Time limit for the episode.|
||None||Determines world generation and creatures.|
pip3 install -U cowherd
The environment follows the OpenAI Gym interface:
import cowherd env = cowherd.Env(seed=0) obs = env.reset() assert obs.shape == (64, 64, 3) done = False while not done: action = env.action_space.sample() obs, reward, done, info = env.step(action)
A reward of +1 is given every time the player milks one of the cows.
Episodes terminate after 1000 steps.
Each observation is an RGB image that shows a local view of the world around
the player, as well as the inventory state of the agent.
The action space is categorical. Each action is an integer index representing
one of the possible actions:
||Walk to the left.|
||Walk to the right.|
||Pick up a placed fence or milk a cow.|
||Place a fence in front of the player.|