Command-line program to manage PS battle logs. WIP.

Overview

psbattletools

Crates.io codecov

psbattletools is a command-line tool written in Rust for manipulating Pokémon Showdown battle logs.

Installation

psbattletools currently requires nightly Rust, since it uses Rust's built-in benchmarker. If you don't have nightly Rust, install rustup, then run rustup install nightly.

Installing psbattletools itself is as simple as running cargo install psbattletools.

Usage

Searching for battles

The search or s subcommand allows you to search for battles; this is significantly faster than Showdown's built-in /battlesearch functionality (TODO: add benchmark).

You must specify a username to search for, and a list of directories to search in (these will be searched recursively, ignoring non-JSON files). You may also specify any of the following options:

  • --forfeits-only or -f: search only for battles that ended by forfeit
  • --wins-only or -w: search only for battles that the specified username won

For example, psbattletools search --wins-only Annika logs/2020-06/gen8randombattle logs/2020-05/gen8randombattle would search for [Gen 8] Random Battle battles won by Annika in May and June of 2020.

Calculating winrates and statistics

The statistics (or stats or winrates) subcommand calculates the winrates (in percentage, raw games, and standard deviations) for each Pokémon used in a given format. Currently, usage stats are handled by other, closed-source scripts, but if there is demand for it I'm happy to consider implementing more complex statistics.

By default, this command prints a human-readable winrates format to standard output, but there are also options to produce CSVs (for easy consumption by scripts and programs), and/or write output to a file.

You must provide a list of directories to analyze, but psbattletools statistics also accepts the following optional arguments:

  • --csv [path]: writes CSV output to the given file
  • --human-readable [path] or --pretty [path]: writes human-readable (prettytable) output to the given file
  • --minimum-elo [ELO] or --elo [ELO]: ignores battles where either player is below the given ELO rating at the start of the battle
  • --exclude [text]: ignores directories and JSON files whose names include the given text

For example, psbattletools stats --pretty gen8randombattle-1500.txt --minimum-elo 1500 logs/2021-08/gen8randombattle would write winrates for [Gen 8] Random Battle games in August 2021 with 1500 ELO or higher as human-readable tables to the file gen8randombattle-1500.txt.

Anonymizing battles

The anonymize subcommand removes personally-identifying data from battle logs, while assigning each player a unique ID (so it's still possible to identify when two anonymous players are the same).

You must provide a list of directories containing JSON files to anonymize; all of the JSON battle logs in these directories will be anonymized, and directory structure will not be preserved in the output. This subcommand accepts only one argument, which must be specified: --output [directory] (or -o [directory]), which specifies the directory in which anonymized battle logs will be written.

For example, to write anonymized [Gen 8] Random Battle logs from June-August 2021 to the directory anonymized/, you'd use the command psbattletools anonymize -o anonymized logs/2021-06/gen8randombattle logs/2021-07/gen8randombattle logs/2021-08/gen8randombattle.

Development

I welcome contributions to psbattletools. There's currently no formal contribution guide, but pull requests are always welcome. If possible, make sure your code is rustfmted and has unit test(s) to detect regressions and/or test added functionality.

Unit and integration tests can be run with cargo test, and benchmarks can be run with cargo bench. The following features may be enabled during benchmarks (with cargo bench --features ...) to run additional benchmarks:

  • bench_old_battlesearch runs the same benchmark as is used for the integration benchmark of psbattletools search on my old battlesearch program; this allows for direct performance comparisons. Don't enable this feature unless you have battlesearch installed.
  • bench_old_winrates runs the same benchmark as is used for the integration benchmark of psbattletools statistics on my old randbats-winrates program; this allows for direct performance comparisons. Don't enable this feature unless you have randbats-winrates installed.
  • bench_old_anonbattle runs the same benchmark as is used for the integration benchmark of psbattletools anonymize on my old anonbattle program; this allows for direct performance comparisons. Don't enable this feature unless you have anonbattle installed.
You might also like...
A silly program written in Rust to output nonsensical sentences in the command line interface.

A silly program written in Rust to output nonsensical sentences in the command line interface.

A Rust port of the command line program playing with the cutscenes files (USM) from Genshin Impact.

GI-cutscenes : Rust Remix A command line program playing with the cutscene files (USM) from Genshin Impact, reimplemented in Rust. Much like its origi

A simple command line program to upload file or directory to web3.storage with optional encryption and compression
A simple command line program to upload file or directory to web3.storage with optional encryption and compression

w3s-cli A simple command line program to upload file or directory to web3.storage with optional encryption and compression. Features Uploads single fi

A simple command-line calculator program writen with Rust.

Calculator.rs An simple command-line calculator program writen with Rust. Features Math functions support sin(1) = 0.84147098 Variable support a

A panic hook for wasm32-unknown-unknown that logs panics with console.error
A panic hook for wasm32-unknown-unknown that logs panics with console.error

console_error_panic_hook This crate lets you debug panics on wasm32-unknown-unknown by providing a panic hook that forwards panic messages to console.

Infino - Fast and scalable service to store time series and logs - written in Rust

Infino 〽️ 🪵 — 🔍 📊 — ⚖️ 💰 Ingest Metrics and Logs — Query and Insights — Scale and Save $$ Infino is an observability platform for storing metrics

A fast, simple TUI for interacting with systemd services and their logs
A fast, simple TUI for interacting with systemd services and their logs

systemctl-tui A fast, simple TUI for interacting with systemd services and their logs. systemctl-tui can quickly browse service status and logs, and s

Command-line HTTP client for sending a POST request to specified URI on each stdin line.

line2httppost Simple tool to read lines from stdin and post each line as separate POST request to a specified URL (TCP connection is reused though). G

Pink is a command-line tool inspired by the Unix man command.

Pink is a command-line tool inspired by the Unix man command. It displays custom-formatted text pages in the terminal using a subset of HTML-like tags.

Comments
  • Deployment

    Deployment

    • [x] publish to Cargo
    • [x] deprecate:
      • [x] anonbattle
      • [x] battlesearch
      • [x] randbats-winrates
        • [x] sim3 scripts
    • [x] fix TODOs
    • [x] benchmark against old tools
    opened by AnnikaCodes 0
  • Bump regex from 1.5.4 to 1.5.5

    Bump regex from 1.5.4 to 1.5.5

    Bumps regex from 1.5.4 to 1.5.5.

    Changelog

    Sourced from regex's changelog.

    1.5.5 (2022-03-08)

    This releases fixes a security bug in the regex compiler. This bug permits a vector for a denial-of-service attack in cases where the regex being compiled is untrusted. There are no known problems where the regex is itself trusted, including in cases of untrusted haystacks.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(v0.2.2)
  • v0.2.2(Mar 18, 2022)

    • Anonymization: output each format into its own directory
    • Support saving/loading anonymizer state (mapping of players <=> ID numbers)

    Full Changelog: https://github.com/AnnikaCodes/psbattletools/compare/v0.2.0...v0.2.2

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Mar 10, 2022)

    • Ties are now properly anonymized.
    • ELO is now included in anonymized logs, but is rounded to the nearest 50 ELO.
    • A --no-log option has been added to the anonymization subcommand to remove the log and inputLog attributes to save space.
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Oct 27, 2021)

Owner
Annika
I write code sometimes.
Annika
A command line tool, manage your hundreds of repository, written with Rust

A command line tool, manage your hundreds of repository, written with Rust

Axetroy 4 Aug 16, 2022
A Command-line tool to create, manage and deploy your python projects

PPM A Command-line tool to create, manage and deploy your python projects Table of Contents PPM Main Features Create a Project project.ini file Projec

FUSEN 6 Aug 30, 2022
☘️ A simple command line tool to manage your Minecraft Bedrock worlds

☘️ Haze A simple command line tool to manage your Minecraft Bedrock worlds Haze allows you to keep your project's worlds out of the com.mojang directo

Sedge 3 Dec 8, 2022
Rollback netcode for Mega Man Battle Network!

Tango Tango is rollback netplay for Mega Man Battle Network. Supported games MEGAMAN6_FXXBR6E: Mega Man Battle Network 6: Cybeast Falzar (US) MEGAMAN6

Tango 68 Dec 31, 2022
Mod for Mega Man Battle Network Legacy Collection to restore the WWW base music in the postgame.

MMBNLC Postgame WWW Base Music mod This is a mod for Mega Man Battle Network Legacy Collection Vol. 2 adjusts the field music played in the WWW base i

Prof. 9 3 May 7, 2023
A simulator for Street Fighter 6 battle data.

sf6_sim A simulator for Street Fighter 6 battle data. Very early in development. It can currently simulate boxes, cancel lists, and movement. Online v

null 4 Jun 18, 2023
A command line interface for trash written in Rust (WIP)

trashctl A command line interface for trash Features Add file to trash List files Permanently delete a file Restore file Empty the trash Documentation

0xMRTT 2 Nov 11, 2022
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
WIP: A program for switching Dygma layouts based on window name or exe name.

Dygma Layer Switcher Config On the first run of dygma-layer-switcher the config.yml will be generated. --- # Toggle logging. logging: false # Port of

Matthew Wilding 5 Nov 11, 2023
Command-Line program that takes images and produces the copy of the image with a thin frame and palette made of the 10 most frequent colors.

paleatra v.0.0.1 Command-Line program that takes an image and produces the copy of the image with a thin frame and palette made of the 10 most frequen

Beka Modebadze 24 Dec 29, 2022