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 simple matrix code rain created using Python with Pygame.

Matrix4_code_rain A simple matrix code rain created using Python with Pygame. To run the code you will need Pygame and MS Mincho font. Create a projec

7 Nov 06, 2022
🌍🍓 A better MCPi Launcher

Planet Launcher A better, maintained launcher for the Minecraft: Pi Edition Reborn mod. Report Bug | Request Feature Planet is a maintained, feature-r

15 Oct 19, 2022
Datamining of 15 Days of (free) Games at the Epic Games Store (EGS).

EGS: 15 Days of Games This repository contains Python code to data-mine the 15 Days of (free) Games at the Epic Games Store (EGS). Requirements Instal

Wok 9 Dec 27, 2022
A small script to help me solve Wordle because I'm that lazy

Wordle Solver A small script to help me solve Wordle because I'm that lazy. Warning: I didn't write this to be efficient nor elegant at all, so you'll

K4YT3X 3 Feb 11, 2022
Adventure-Game - Adventure Game which is created using Python

Adventure Game 🌇 This is a Adventure Game which is created using Python. Featur

ArinjoyTheDev 1 Mar 19, 2022
Python Interactive Mini Games

Python Interactive Mini Games Mini projects from Coursera's An Introduction to I

Ashish Choudhary 1 Jan 16, 2022
Tic tac toe game developed by naman in python

TIC TAC TOE GAME DEVELOPED BY NAMAN IN PYTHON . IT USES MINMAX ALGORITHM TO COMPETE IN DIFFICULTY MODE

Naman Anand 4 Jun 24, 2022
Deliver buycraft orders to players across the map in minecraft servers using baritone

Deliver buycraft orders to players across the map in minecraft servers using baritone

synthels 1 Nov 14, 2021
Games: Create interesting games by pure python.

Create interesting games by pure python.

4.2k Jan 06, 2023
Dragon Quest IV (NDS) English + Party Chat Script Patcher for Japan ROM

Patches English script files from the US version of Dragon Quest IV for Nintendo DS and Android so they are rendered nicely when used with the Japan ROM. Addresses various issues caused by the Japan

Aric Huang 35 Dec 18, 2022
A Higher-Lower web game made in Python using Flask framework.

Higher Lower Web Game Guess the random number from 0 to 9 in this web game made with Python and Flask Framework Modules that were used Random Flask In

Yago Goltara 1 Oct 27, 2021
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
Graphical impimetaion of Conway's Game of Life in Python using pyglet

Conway's Game of Life in Python Konstantin Opora Conway's Game of Life: graphical implementation in python using pyglet. developed in Python 3.10.0 Re

Konstantin Opora 1 Nov 30, 2021
Automatic game data translator for RPGMaker-MV

RPGMaker-MV Translator 🕹️ 🎮 Use AI to translate all the dialogs and texts of your RPGMaker automatically. 👊 You worked hard to make your game, now

Davide Liu 11 Dec 26, 2022
An single python server emulator of MMORPG game WindSlayer also known as WS1.

PySlayer An single python server emulator of MMORPG game WindSlayer also known as WS1. Requirements Python = 3.7 Old windslayer client (Korea Yahoo!

mirusu400 29 Dec 19, 2022
Meu primeiro jogo desenvolvido em Python, usado o módulo do Pygame

📖 Sobre Esse repositório é dedicado ao meu primeiro jogo feito em Python, utilizando o módulo do pygame. O jogo foi desenvolvido seguindo o tutorial

Michael Douglas 0 May 06, 2022
Building a Mario-like, classic platformer game in Python using the PyGame Library

Building a Mario-like, classic platformer game in Python using the PyGame Library

Clarence Vinzcent Reyes 1 Feb 06, 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
シューティングゲームぽい?未完成ですけど

シューティングゲームぽい?未完成ですけど

kawamineka 64 Jun 25, 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