View on GitHub

shuffle-go

Shuffle-Go

See an HTML formatted version of this document here

A Go implementation of the [shuffle](https://github.com/chrplr/shuffle) program, providing a core library and both CLI and GUI interfaces for generating randomized sequences with sequential constraints.

This tool is particularly useful for generating stimuli lists for psychological experiments or any task requiring quasi-randomized permutations that avoid specific repetitions or patterns.

Features

Installation

The easiest way to get Shuffle-Go is to download the latest installer directly below.

These are standard installers that will set up the application on your computer:

2. Using Pre-compiled Binaries (Portable version)

If you don’t want to install the app, download a .zip archive from the Releases page for your platform.

  1. Download the .zip file for your Operating System and Architecture.
  2. Extract the archive to a folder of your choice.
  3. You will find:
    • shuffle-gui: The main graphical interface (Fyne version).
    • shuffle-gio: An alternative lightweight graphical interface.
    • shuffle-cli: The command-line interface for terminal use.

3. Compiling from Source (For developers)

If you have Go installed, you can build the project yourself.

Prerequisites

Building

Run the provided build script:

bash build.sh

Or build specific components manually:

# Build the CLI
go build -o shuffle-cli ./cmd/shuffle-cli

# Build the Fyne GUI
go build -o shuffle-gui ./cmd/shuffle-gui

Usage

CLI Tool

./shuffle-cli [flags] < [input_file]

Flags:

Example:

# Shuffle sample.txt, max 1 repetition in col 1, output 10 lines
./shuffle-cli -c "1" -n 10 sample.txt
cat sample.txt | ./shuffle-cli -n 10

GUI Application (Fyne version)

Run the GUI by double-clicking it (on macOS, use shuffle-gui.app) or from the terminal:

./shuffle-gui      # on Linux
./shuffle-gui.exe  # on Windows
./shuffle-gui.app  # on macOS

The Fyne version allows you to:

  1. Load data from .txt or .csv files using the “Open” button.
  2. Interactively set constraints and shuffling parameters.
  3. Preview the results in a text area.
  4. Save the shuffled list to a new file using the “Save” button.

GUI Application (Gio version)

Run the Gio GUI by double-clicking it (on macOS, use shuffle-gio.app) or from the terminal:

./shuffle-gio      # on Linux
./shuffle-gio.exe  # on Windows
./shuffle-gio.app  # on macOS

The Gio version features a native file selector via the Import button.

  1. Click Import to load a .txt or .csv file.
  2. Adjust constraints and parameters in the sidebar.
  3. Click Shuffle! to process the data.

Constraints Explained

Constraints are defined per column:

Example: -c "1 -4"

Library Integration

You can use the core logic in your own Go projects:

import "github.com/chrplr/shuffle-go"

// ... load data ...
constraints := []shuffle.Constraint{1, -3}
shuffler := shuffle.NewShuffler(data, constraints, 0, 100, 0)
result, err := shuffler.ShuffleConstructive()

License

This project is copyrighted by its author, Christophe Pallier christophe@pallier.org

It is licensed under the GPLv3.