AWBW Replay Parser - a Python package to open and step through AWBW game replays.

Overview

AWBW Replay Parser

pylint unittest Open In Colab

This repository is home to the AWBW Replay Parser, a Python package to open and step through AWBW game replays. This project is unafilliated with AWBW or any related property.

To get started, click the Open In Colab badge at the top of the README, or fork the repository to tinker with the package directly.

Package Documentation

To open a replay file, use the AWBWReplay class:

from awbw_replay.replay import AWBWReplay

with AWBWReplay("my_replay.zip") as replay:
    replay_actions = list(replay.actions())
    replay_turns = replay.turns()
    print(f"There are {len(replay_actions)} actions and {len(replay_turns)} turns in {replay.path()}")

The AWBWReplay class is the parser and general wrapper around the replay archive, but is generally not used directly. Instead, we use the game_info() and actions() functions to get the necessary information to determine the game state between each action.

The AWBWGameState and AWBWGameAction classes take this information from the AWBWReplay instance and turn it into a consistent state format that can be analyzed over the course of a match. Generate the initial state from the replay.game_info(), then generate each successive state using the previous state's apply_action() method. Here's an example for how to generate all game states in a replay:

from awbw_replay.replay import AWBWReplay
from awbw_replay.awbw import AWBWGameState, AWBWGameAction

# Read out all the game states
states = []
with AWBWReplay("my_replay.zip") as replay:
    states.append(AWBWGameState(replay_initial=replay.game_info()))

    for action in replay.actions():
        states.append(states[-1].apply_action(AWBWGameAction(action)))

Extract game information from the replay by examining the game states. AWBWGameState stores dictionaries for the following information:

  • game_info: Global information including the game ID, the active player and the day.
  • players: Player information given by player ID. Includes funds and CO power meter.
  • units: Unit information given by unit ID. Includes hit points, cost and (x, y) coordinates
  • buildings : Building information given by building ID. Includes capture values and (x, y) coordinates
  • game_map (PLANNED): Map information including the map ID, map size and text representation of map

All of this information is stored in various dictionary types given by the classes awbw.GameInfo, awbw.Player, awbw.Unit and awbw.Building. The ALLOWED_DATA dictionary of each of these classes provides the documentation for the present keys and expected types for parsing.

Here's an example of reading out players funds over the course of match:

# Examine player funds over time
player_funds = {}
player_ids = states[0].players.keys()
for p_id in player_ids:
    player_funds[p_id] = []

for state in states:
    for p_id in player_ids:
        player_funds[p_id].append(state.players[p_id]["funds"])

Contributing

This project is open source and welcomes contributions from the community. Please review the contribution guidelines for how to get involved.

Spoiler alert: Bugs probably exist in this repository. Please use Github's Issues system for reporting, and be as detailed as you can. Again, see the contributing guidelines for more information.

Owner
Tarkan Al-Kazily
Tarkan Al-Kazily
Tictactoe py tkinter canvas - Tic Tac Toe written in Python 3 with tkinter mainly using canvas

Python 3 Tic Tac Toe with tkinter This is a tkinter version of my Tic Tac Toe ga

Bojan Adzic 1 Jan 09, 2022
Snake Game in Python

Snake game is one of the most popular arcade games of all time. In this game, the main objective of the player is to catch the maximum number of fruits without hitting the wall or itself.

Pavan Ananth Sharma 4 Jul 05, 2022
XO game with server, client and visualizer for AI bots.

XO game with server, client and visualizer for AI bots.

Ali 4 Jul 14, 2022
MinMax Algo , Python

Write a PYTHON program to play the game of TIC-TAC-TOE on a 3×3 board with alternate inputs from user and computer.

Naman Anand 1 Nov 26, 2021
Lutris desktop client in Python / PyGObject

Lutris Lutris is an open source gaming platform that makes gaming on Linux easier by managing, installing and providing optimal settings for games. Lu

Lutris 6.1k Dec 30, 2022
Deep Running

Deep Running 1. Install $ pip install --user deep_running 2. Lap N Lap. Name Remarks Citation Meta 1 Mario Deeeeeep Running I was born to run. dannyso

karaage 69 Jan 31, 2022
This is a 2D Link to the Past-esque game made using Python 3.2.5 and pygame 1.9.2

Queen-s-Demise Queen's Demise This is a 2D Link to the Past-esque game made using Python 3.2.5 and pygame 1.9.2 I made this for a game development cla

Zoey 1 Dec 15, 2021
A python script that uses pygame to display fractals.

Pygame-Fractals A python script that uses pygame to display interactive fractals. There are 3 fractals on the script. They can be displayed on the col

michel 2 Feb 09, 2022
Vitrix is an open-source FPS video game coded in python

Vitrix is an open-source FPS video game coded in python Table of contents Usage Game Server Installing Requirements Hardware Requirements Software Req

Vitrix 1 Feb 13, 2022
QuizGame is a quiz with different topics. You can choose a topic and take the quiz

QuizGame is a quiz with different topics. You can choose a topic and take the quiz. In the end you will get your result. The program is under active development, so there may be errors or flaws in it

Lev Likhachev 2 Nov 12, 2021
Snake game mixed with Conway's Game of Life

SnakeOfLife Snake game mixed with Conway's Game of Life The rules are the same than a normal snake game but you have to avoid cells created by Conway'

Aidan 5 May 26, 2022
Just a copied of flappy bird game made by Thuongton999

flappy-bird Just a copied of flappy bird game made by Thuongton999 Installation and Usage Using terminal (on Window) Make sure you installed Python an

ThuongTon 9 Aug 08, 2021
Script to remap minecraft 1.12 java classes.

Remapper Script to remap minecraft 1.12 java classes. Usage You must have Python installed. You must have the script, mappings, and files / folders in

8 Dec 02, 2022
Simple game where you try to survive as long as you can on screen.

Survival Game Simple game where you try to survive as long as you can on screen. Play To run, download the code and run the survival_game.py file. Fro

Logan Morris 1 Feb 10, 2022
My first Minecraft CPU. Created in collaboration with Peer Carnes as a final project in CS 281: Architecture and Assembly at the University of Puget Sound

Minecraft CPU This is my first ever Minecraft CPU, created in collaboration with Peer Carnes. We created a custom assembly language, including an asse

Andy Chamberlain 4 Oct 10, 2022
We tried to recreate this classic game using python physics libraries.

We tried to recreate this classic game using python physics libraries. The result is certainly hilarious but enjoyable. One of my very first physics application.

Delwys Glokpor 2 Dec 12, 2021
Aftermath is an anti token grabber written in Python3.

🎈 Aftermath 🎈 Aftermath is an anti token grabber written in Python3. This tool with a GUI setup is checking the Downloads folder to search for token

Billy 39 Dec 16, 2022
Mandaw 2 Mar 01, 2022
Trio Assembly Snakemake Workflow

Trio Assembly Snakemake Workflow Input HiFi reads for child in bam format Either

Juniper A. Lake 1 Jan 28, 2022
A simple yet powerful Snake Game made with myPygameWorkflow

snakeGame A simple yet powerful Snake Game made with myPygameWorkflow. Requirments python3 Python.org myPygameWorkflow Github Ripo Usage $ cd main $ p

DuskyElf 1 Dec 26, 2021