This repositor contains code for reading data files of Little Fighter 2.

Zelphir Kaltstahl 144f0bca02 update submodule 2 weeks ago
data 155ea4e99c remove not needed data files 5 months ago
doc 0fd5f344e2 move documents into doc folder 5 months ago
guix-env 094c23506d add guix environment 7 months ago
lib 144f0bca02 update submodule 2 weeks ago
.gitignore 0b9c6c88e0 add gitignore 7 months ago
.gitmodules b59f76443b add random utils 5 months ago
LICENSE 88037f82b6 Initial commit 7 months ago
Makefile 25f7bcfff5 update readme for makefile usage 5 months ago
logging.scm cbe2b5844d add first implementation 7 months ago
main.scm b7c8f0b90b uncomment print 3 months ago
model.scm d78ec48fc4 add model 6 months ago 20688fce71 add more "about" detail 2 months ago c1d5419c6e extend example usage in readme 2 weeks ago


LF2 Survival Stage Generator is a work-in-progress (WIP) project for generating random survival stages fir Little Fighter 2. There is still a lot of work to be done. For ideas about the planned functionality take a look at doc/ or doc/

The code is written in GNU Guile (3.0.7). As far as I know there is no GNU Guile 3.0.7 version for other operating system than GNU/Linux. This means, that in order to use this program, you will likely have to use GNU/Linux.


(project is still work-in-progress)


This repository uses git submodules.

git clone
cd lf2-data-reader
git submodule update --init --recursive

Using GNU Guix

With GNU Guix installed, you can do the following:

  1. activate the specified GNU Guix environment:

       bash guix-env/
  2. run the program:

       make run

The output should show a decrypted stage.dat file.

Other ways

All you need is a working GNU Guile installation to run the program. How you get it, does not really matter. For example you could use your system package to install GNU Guile, if it is available in your the package sources of your system, or you could download the source code of GNU Guile and compile it for your system.

Interactive REPL session

Here is an example for an interactive REPL session. Run your REPL from the root directory of this project and then input the following:

(add-to-load-path ".")
(add-to-load-path "lib")
(add-to-load-path "lib/lf2-data-reader/")
(add-to-load-path "lib/lf2-data-crypt/")
(add-to-load-path "lib/guile-random-utils/")
(load "lib/lf2-data-reader/renderer.scm")

  (except (rnrs base) let-values)
  (only (guile)
        lambda* λ
  (prefix (logging) log:)
  (ice-9 binary-ports)
  (ice-9 textual-ports)
  (ice-9 peg)
  (ice-9 pretty-print)
  (prefix (lf2-data-crypt) lf2crypt:)
  (prefix (grammar) grammar:)
  (prefix (srfi srfi-1) srfi-1:))

(load "lib/peg-tree-utils.scm")
(import (renderer))

(define loc "data/stage.dat")
(define stage-text (process-file loc lf2crypt:decrypt))
(define stage-data (peg:tree (match-pattern grammar:STAGE-DAT stage-text)))
(define survival-data (find-in-peg-tree stage-data 'SURVIVAL-STAGE))
(define phases (flatten-filter-peg-tree (find-all-in-peg-tree survival-data 'PHASE) 'PHASE))
(define phase (list-ref phases 0))

(print-limited stage-text #:max 1024)
(print-limited (fisher-yates-shuffle phases)
               #:max 2048)

(render-data (list phase))


You can run unit tests using the following command:

guile -L . test/<TEST FILE>

Or run tests from submodules, if tests exist.


The project depends on nothing except GNU Guile. It is tested using GNU Guile 3.0.7, but probably works using many older versions as well.

To do

  • write the code for translating back the data structure of a stage to a string
  • implement replace operation for peg tree
  • add more tests