pelita
pelita copied to clipboard
First-class movie creation mode
Please do not yet merge. The new code as well as the surrounding old Tk code needs some more polishing.
This adds the highly sought-after (#531, https://github.com/ASPP/pelita/issues/524#issuecomment-424395032) ‘automatic replay movie creation mode’ to Pelita, which uses Tk’s Canvas.postscript
function to write a postscript representation. As the generated postscript depends on what is shown on the screen, this mode also activates a few changes in the UI representation.
- The canvas size will be resized such that each square has a size of 24x24 (open for discussion),
- the status part of the UI will be hidden during the replay as it cannot be transformed to Postscript (it is not a Canvas) and hiding it makes some of the calculations needed for proper resizing easier.
Usage:
$ pelita --dump replay.json --null # I think we should rename --dump though
...
$ pelita --replay replay.json --snapshot-folder my_replay/
$ ninja -C my_replay/
$ vlc my_replay/movie.mp4
For personal convenience, I am creating a ninja.build
automatically. Not strictly needed since we are only expected to convert it once (except for testing, where it is useful) and a bash script should do just fine. But parallelisation is nice. :)
Current drawbacks:
- The snapshot mode creates two ps files. For the header and the game canvas. Both of them need to be converted to a png with Image Magic with proper settings to have the right amount of anti-aliasing.
- The status bar is missing. So e.g. the name of the layout is not shown.
- It is not clear which font will be used, so it is potentially very ugly looking.
- The first few frames should not be snapshotted (at least not before the game knows the names of the teams).
- ffmpeg needs to know the output dimensions and introduces some further rescaling.
- If the game window is resized during snapshotting, things will get weird.
- Creating the movie has to be done with external tools.
Codecov Report
Merging #542 into master will decrease coverage by
0.62%
. The diff coverage is2.12%
.
@@ Coverage Diff @@
## master #542 +/- ##
==========================================
- Coverage 62.87% 62.24% -0.63%
==========================================
Files 33 33
Lines 4611 4656 +45
==========================================
- Hits 2899 2898 -1
- Misses 1712 1758 +46
Impacted Files | Coverage Δ | |
---|---|---|
pelita/scripts/pelita_main.py | 0% <0%> (ø) |
:arrow_up: |
pelita/ui/tk_viewer.py | 0% <0%> (ø) |
:arrow_up: |
pelita/ui/tk_canvas.py | 0% <0%> (ø) |
:arrow_up: |
pelita/scripts/pelita_tkviewer.py | 0% <0%> (ø) |
:arrow_up: |
pelita/libpelita.py | 51.95% <33.33%> (-0.38%) |
:arrow_down: |
pelita/player/RandomExplorerPlayer.py | 84.21% <0%> (-5.27%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 57f2cb0...2541ae1. Read the comment docs.
- Converting on macOS is really slow…
Currently I would much prefer looking into a solution that just uses a Qt interface (or we hand-craft a direct-to-png writer) and directly saves the canvas to png. Converting ps to png takes maybe 10 seconds per frame which is far too much time.
Let’s go full svg. It looks very all right and is quite fast to export (ie. not noticeable). That means we can export it already while the tournament is running.

Additional open idea: Do we actually need mp4 video files? Maybe an animated Javascript canvas is the better solution for presenting the matches after the tournament anyway. Obviously low priority.
Codecov Report
Merging #542 (088bfaa) into main (98d4810) will decrease coverage by
0.07%
. The diff coverage is40.00%
.
@@ Coverage Diff @@
## main #542 +/- ##
==========================================
- Coverage 85.39% 85.32% -0.08%
==========================================
Files 21 21
Lines 2301 2303 +2
==========================================
Hits 1965 1965
- Misses 336 338 +2
Impacted Files | Coverage Δ | |
---|---|---|
pelita/game.py | 86.06% <40.00%> (-0.48%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 98d4810...088bfaa. Read the comment docs.