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
Backend application for a game to classify waste for recycling

Waste Organizer Game Backend application used in a game to classify trash for recycling. What is waste organizer game? It is a game developed during t

10 Jun 13, 2021
A fully automated system that transforms Twitch clips into gaming compilations

A fully automated system that transforms Twitch clips into gaming compilations Authors: Christian C., Moritz M., Luca S. Related Projects: Neural Netw

215 Dec 27, 2022
A Python based program that displays Your Minecraft Server's Status Infos.

Minecraft-server-Status This (very) small python script allows you to view any Minecraft server's status Information Usage Download the file, install

Jonas_Jones 2 Oct 05, 2022
Utility to find games owned by all (or at least some) of the passed players.

SteamCommonGameFinder Utility to find games that are owned by all (or at least some) of the players you pass into this programm. You can already find

Daniel O'Grady 4 Jan 04, 2022
I automated the lumberjack game on telegram, by recognising pixels and using pyautogui module

Lumberjack Automated: @gamebot According to the official documentation, @gamebot is a demo bot for the Telegram Gaming Platform.` It provides some sam

Yew Chong 1 Dec 07, 2021
Editor for Bioware's Original Neverwinter Nights Game

neveredit This is an import of an old sourceforge project. Neveredit is an editor for Bioware's Neverwinter Nights game. It also includes all the low

Peter Gorniak 2 Apr 12, 2022
Space Invaders x Asteroid Game

Retro Journey 1: Space Invaders A simple implementation of a retro style video game where users compete against asteroids and the goal is to destroy a

Sandesh Lamsal 2 Aug 05, 2022
Pygame for humans (pip install hooman) (25k+ downloads)

hooman ~ pygame for humans pip install hooman join discord: https://discord.gg/Q23ATve The package for clearer, shorter and cleaner PyGame codebases!

Abdur-Rahmaan Janhangeer 31 Nov 08, 2022
Software Design | Spring 2020 | Classic Arcade Game

Breakout Software Design Final Project, Spring 2020 Team members: Izumi, Lilo For our Interactive Visualization, we implemented the classic arcade gam

Lilo Heinrich 1 Jul 26, 2022
🪨 📄 ✂ game in python with recursion

🪨 📄 ✂ Game Rock Paper Scissor game in python with recursion ⚙️ Developer's Guide Things you need to get started with this code:- Download python3 fr

Atul Anand 3 Jul 25, 2022
🕹️ Jeu Azul en Python avec 4 IAs 🤖 implémentées, jouable de 1 à 4 joueurs

Projet jeu Azul 🕹️ Jeu Azul en Python avec 4 IAs 🤖 implémentées, jouable de 1 à 4 joueurs Par : Berachem MARKRIA et Tristan MARTINEZ Projet réalisé

Berachem Markria 2 Jun 07, 2022
This is the card game like HearthStone and Magic

Territory War How to use it use pip3 to install django and channels: pip3 install Django pip3 install channels go to CardGame/first/consumers.py and g

Caesar 3 Oct 24, 2022
This is a simple game of rock-paper-scissors developed in Python

This is a simple game of rock-paper-scissors developed in Python. It allows two players to play with one another on different command lines through networking.

NAMAN JAIN 3 Oct 21, 2022
TetrisAI - Tetris AI Bot using computer vision to play game automatically

Tetris AI Tetris AI Bot using computer vision to play game automatically bot.py

11 Aug 29, 2022
This is a good project to train your logic game with python language

JO-KEN-PÔ!!! | Description | basic. I make this game only to train. This is a good project to train your logic game with python language. This game is

Elianderson Silva 1 Jan 24, 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
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
To solve games using AI, we will introduce the concept of a game tree followed by minimax algorithm.

To solve games using AI, we will introduce the concept of a game tree followed by minimax algorithm.

Vaibhaw 7 Oct 13, 2022
Gamelib is a pure-Python single-file library/framework for writing simple games.

Gamelib is a pure-Python single-file library/framework for writing simple games. It is intended for educational purposes (e.g. to be used in b

Diego Essaya 15 Dec 22, 2022