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
A two-player strategy game played on a rectangular grid made up of smaller square cells of chocolate 🍫 or cookies 🍪

Chomp Game ©️ Chomp is a two-player strategy game played on a rectangular grid made up of smaller square cells of chocolate 🍫 or cookies 🍪 , which c

Farivar Tabatabaei 2 Feb 02, 2022
An exploration of a fantasy world, to autobattle your way to ruling the demesne.

Not Quite Paradise 2 (no relation to NQP, I just like the name enough to want to keep it.) Badges! Current position: Quality of last commit: Who dunni

9 Mar 12, 2022
Algorithm to solve Wordle correctly 100% of the time within 6 attempts.

WordleSolver © Zulkarnine, 2022. Algorithm to solve Wordle 100% of the time within 6 attempts. You can go ahead and run main.py to run it for all 2315

Zulkarnine Mahmud 69 Dec 11, 2022
A Street Fighter game in Pygame

What is Street Fighter? Street Fighter, commonly abbreviated as SF or スト, is a Japanese competitive fighting video game franchise developed and publis

Sameer Sahu 3 Aug 20, 2022
Chess-commandline - Chess in the Command Line using the Chess Module Can detect Checkmates

chess-commandline Chess in the Command Line using the Chess Module Can detect Ch

Harry Hopkinson 1 Jan 10, 2022
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame

Wordle-Python A simple low-key clone of the popular game WORDLE made with python

Showmick Kar 7 Feb 10, 2022
Blackjack-Py is a terminal based game of blackjack within your terminal playing against CPU.

About Blackjack-Py is a terminal based game of blackjack within your terminal playing against CPU. Usage Clone the repo and run it with whatever pytho

Eccentrici 1 Dec 28, 2021
Chess GUI

Lucas Chess Lucas Chess is a GUI of chess: To learn to play chess. To play chess against engines. Dependencies Python 2.7 PyQt4 PyAudio psutil Python

Lucas 322 Dec 20, 2022
Replicating Minecraft World Generation in Python

Minecraft World Generation in Python This is an attempt to replicate Minecraft world generation in Python. This is part of an article published on Med

Bilal Himite 159 Dec 19, 2022
a game of life implementation in python

gameoflife-py python implementation of game of life Installing As long as you have bash and curl installed and are on Linux the install script should

Raghav 5 Jun 09, 2021
Ice-Walker-Game - This repository is about the Ice Walker game made in Python.

Ice-Walker-Game Ce dépot contient le jeu Ice Walker programmé en Python. Les différentes grilles du jeu sont contenues dans le sous-dossier datas. Vou

Mohamed Amine SABIL 1 Jan 02, 2022
An old time game Tic-Tac-toe

A Tic Tac Toe Bot This is the code repository for my article on Medium - Playing Games with Python - Tic Tac Toe, where I have tried to take the famou

Jigyanshu 0 Feb 25, 2022
Minecraft.nix - Command line Minecraft launcher managed by nix

minecraft.nix Inspired by this thread, this flake contains derivations of both v

12 Sep 06, 2022
Minecraft - Online Players Overlay Generator

Minecraft - Online Players Overlay Generator Contents About Quick Start Download Pre-Built Binary Run from Source Configuration Command-Line Options F

4 Sep 12, 2022
Hex-brawl-v25 - Simple Brawl Stars v25.107 server emulator written in Python

Hex Brawl Simple Brawl Stars v25.107 server emulator written in Python. Requirem

Shark01 3 Nov 24, 2022
A base chess engine that makes moves on an instance of board.

A base chess engine that makes moves on an instance of board.

0 Feb 11, 2022
Game of life, with python code.

Game of Life The Game of Life, also known simply as Life, is a cellular automaton. It is a zero-player game, meaning that its evolution is determined

Mohammad Dori 3 Jul 15, 2022
Python module providing simple game networking

nethelper Python module providing simple game networking This module was originally created to facilitate a class on creating multiplayer games in Pyg

Cort 3 Jan 11, 2022
Tic-Tac-Toe - Tic-Tac-Toe game build With Python

Tic Tac Toe This game is very popular amongst all of us and even fun to build as

PyLaboratory 0 Feb 06, 2022
A rhythm-based game that automatically generates obstacles based on a song's features.

DISCLAIMER: This is my first coding project, created in December 2019. The game may not be optimized, and looking back on it, there are a lot of chang

Kenneth Huang 1 Dec 27, 2021