Skip to main content

Readers for Minesweeper replays

Project description

Sweeping View

Sweeping view is a library that can parse replay files produced by official Minesweeper clones, as well as Metasweeper.

It's fairly bare-bones, and doesn't do much more than parse replay files. If you want to do actual analysis of replay files, even just getting board events from mouse events, you probably want to use ms-toollib instead (see below).

Currently supported:

Formats:

  • RMV (Viennasweeper)
  • AVF (Minesweeper Arbiter, Freesweeper)
  • EVF (Metasweeper)

Tested Python versions:

  • 3.6
  • 3.7
  • 3.8
  • 3.9
  • 3.10
  • 3.11
  • 3.12

Is this a good idea? Shouldn't the formats be secret?

They aren't anymore anyway. There are open-source tools available to convert the implemented formats to rawvf, an entirely text-based format.

What this library doesn't do is make any attempt to verify checksums. Those remain as the primary obstacle to generating fake replays.

Similar projects

ms-toollib

ms-toollib is a library that provides way more features than sweeping-view.

Besides replay parsing, it also provides a fully featured minesweeper engine, as well as numerous algorithms. It is written in Rust, but there is a Python package of the same name on PyPI. https://github.com/eee555/ms-toollib/

On the other hand, sweeping-view is pure Python and has zero dependencies - so if all you need is metadata, it might be all you need!

Rawvf

Rawvf is a plain-text minesweeper replay format. A collection of command line tools to convert various formats to it can be found here: https://github.com/thefinerminer/minesweeper-rawvf

Rawvf offers far better support (more formats/old versions of formats), but the tools aren't usable as libraries.

State of completion and stability

This library is still a work in progress, and parts of the public API may change completely - this is because while all existing parsers work for now, not much care has been taken to make them consistent.

Example use

Arbiter

code

from sweeping_view.avf import AVFReplay

avf = AVFReplay.from_file("HI-SCORE Beg_5.41_3BV=28_3BVs=5.17_Tommy.avf")

print(avf.name)
print(avf.properties)
print(avf.mines)

output

'Tommy'
{'level': 'beginner', 'questionmarks': False}
[(4, 1), (5, 2), (8, 2), (2, 3), (6, 3), (4, 5), (8, 5), (6, 6), (8, 6), (4, 7)]

Viennasweeper

code

from sweeping_view.rmv import RMVReplay

rmv = RMVReplay.from_file("fd60_beg_4153_NF_1600544477.rmv")

print(rmv.player_data)
print(rmv.properties)
print(rmv.mines)

output

{'name': 'tkolar'}
{'questionmarks': False, 'nonflagging': True, 'mode': 'normal', 'level': 'beginner'}
[(1, 3), (2, 3), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 4), (6, 6), (7, 6)]

Metasweeper

code

from sweeping_view.evf import EVFReplay

evf = EVFReplay.from_file("test_subject.evf")

print(evf.user_identifier)
print(rmv.bbbv)
print(rmv.timeth)

output

Szymon_M
167
69597

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sweeping_view-0.4.0a0.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

sweeping_view-0.4.0a0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file sweeping_view-0.4.0a0.tar.gz.

File metadata

  • Download URL: sweeping_view-0.4.0a0.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for sweeping_view-0.4.0a0.tar.gz
Algorithm Hash digest
SHA256 a50f7251c50d17f86a206bf2d48a56ef462985ec29c50089c571e6fb6a5c5c75
MD5 c5f147e7c95f32d27f21c1ebe6895f03
BLAKE2b-256 f69291932a69b0070878087fe51bd4a62db26a8e5d9b9da1def913f7c43c8e29

See more details on using hashes here.

File details

Details for the file sweeping_view-0.4.0a0-py3-none-any.whl.

File metadata

File hashes

Hashes for sweeping_view-0.4.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea255fad78e61ea212ead8f64db2ae9f39ec1d2b335d1e603fe1ae7d64b9cf3a
MD5 abd7c3e3de28f4ba96b0057d05539153
BLAKE2b-256 623de0bc07ece9080af4181c9ac2b2185683c4709a9c9e0909468b24e12f0444

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page