https://github.com/vesche/pyba
https://github.com/vesche/pyba
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/vesche/pyba
- Owner: vesche
- Created: 2017-12-22T20:52:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-24T00:31:46.000Z (over 8 years ago)
- Last Synced: 2025-04-12T22:45:05.170Z (about 1 year ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pyba
Python API for [ByteArena](https://doc.bytearena.com/). Still a work in progress, but it's functional.
Within `test-agent/agent/` is `agent.py` and `pyba.py`.
* `agent.py` is the agent that will run inside your docker container.
* `pyba.py` is a Python API for ByteArena.
The provided agent moves around randomly similar to the [example nodejs agent](https://doc.bytearena.com/guides/getting-started/). Here's how it works:
```python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# import the pyba ByteArena API
import pyba
import random
# create an instance of the ByteArena class from pyba
comm = pyba.ByteArena()
# start a loop
while True:
# start getting perception of the world
if comm.stream("perception"):
# get a random direction to move in
direction = random.choice([-1, 1])
x = direction * random.random()
y = 3
# give actions to steer and shoot in this direction
comm.steer(x, y)
comm.shoot(x, y)
# execute those actions
comm.sendActions()
```