Skip to main content

Battle of AI - Python library

Object-oriented easy2use solution for interacting with https://battleofai.net/ 's API.

A short summary of the basic features.

Configure your client easily.

from battleofai import Client

client = Client(credentials=('username', 'password'))

# if you want to export your config
client.config.from_python_file('config.py')

# or use json
client.config.from_json_file('config.json')

Play games automatically.

from battleofai import Client, Core


client = Client()  # specify credentials


@client.callback()
def turn(board, symbol):
    for x_pos, columns in enumerate(board):
        for y_pos, field in enumerate(columns):
            if field == '#':  # if position is free
                return x_pos, y_pos  # set my stone


client.play(Core)

Play games manually.

from battleofai import Client, Core, GameState
import time


client = Client()  # specify credentials


def turn(board, symbol):
    for x_pos, columns in enumerate(board):
        for y_pos, field in enumerate(columns):
            if field == '#':  # if position is free
                return x_pos, y_pos  # set my stone


game = Core.create_game()

client.login()

my_match = Core(callback=turn)
my_match.join_game(client, game)

# then either
my_match.play()

# or even something like this
playing = True
while playing:
    game.update()

    if not game.state == GameState.STARTED:
        break

    if my_match.is_active:
        resp = my_match.make_turn()

        if resp.status_code == 200 and 'false' in resp.text:
            playing = False

    time.sleep(5)

Manage games.

from battleofai import Game, GameState, Core

my_game = Game.get(game_id=100)
print(my_game.players)

open_games = Game.list(game_state=GameState.WAITING)

new_game = Game.create(Core.__game_name__)

Metadata

Release files for battleofai 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for battleofai 0.1.1
File Interpreter ABI Platform Actions
battleofai-0.1.1-py3-none-any.whl Python 3 none any Details for battleofai-0.1.1-py3-none-any.whl

Release files / battleofai-0.1.1-py3-none-any.whl

Download URL battleofai-0.1.1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d22043476730bdc2831c851146997e83375ca8726cc94d2113fd480d8e51601a
BLAKE2b-256 checksum
How to use checksums
c4226093434e35e6bf77b6fb4d1434ea6fd90d19c27fe6d3367217565ecea7d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

Security for battleofai 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page