Skip to content

playsuipi/core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Play Suipi Core

Rust

The core game logic that is at the center of all Play Suipi products.

Quick Start

  1. Install the Rust language. (rust-lang.org)
  2. Run the demo game.
cargo run

Because Suipi randomly shuffles the deck before each game, you cannot play the same game twice by default. You can get around this by specifying a seed to use when shuffling. If you use the same seed twice, you will get the exact same shuffle both times.

You can specify a seed for the game to use by passing an argument with the path to a seed file. A seed file is just a plain text file with a number from 0 to 255 on each line. There may be up to 32 lines in the file, anything over that will be ignored, and anything less than that will be assumed to be a zero. So a blank file would be a seed of 32 zeros.

touch ./seed.txt
cargo run ./seed.txt

Cross Platform Setup

Rust needs to install target plugins for each architecture we want to compile for. We can do this using the rustup tool installed in the "Quick Start".

Quick Cross Platform Setup

make init

The make init command will install all of the Rust targets listed below.

Build Android Libraries:

make android

Build iOS Libraries:

make ios

Build macOS Libraries:

make macos

Manual Cross Platform Setup

Android

Install Android targets:

rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android

iOS

Enable Rust nightly toolchain:

rustup toolchain install nightly

Install iOS targets:

This allows us to compile Rust code for iOS devices.

rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios

macOS

Install macOS targets:

This allows us to compile Rust code for macOS devices.

rustup target add aarch64-apple-darwin x86_64-apple-darwin

FFI Setup

Install cbindgen command:

This tool lets us generate a C header file with bindings for our library.

cargo install cbindgen

Generate header file:

This C header file can be used to generate FFI bindings for different languages.

cbindgen --crate playsuipi_core -c cbindgen.toml > target/playsuipi_core.h

Testing

Run the unit and integration tests.

cargo test

Debugging

On Linux, you can run cargo commands inside of GDB using the ./bin/debug.sh script.

./bin/debug.sh test

Reproducing Issues

There is also a ./bin/record.py script that you can use to record your moves as you go, and replay them if you need to restart.

python3 -m pip install --user pwntools
touch log.txt seed.txt
./bin/record.py

The ./bin/record.py script will automatically save your moves to a log file, which you can configure with the LOG_PATH argument. By default this is set to ./log.txt. The log file contains plain text Suipi annotations on each line.

echo '!1' >> log2.txt
echo '!1' >> log2.txt
./bin/record.py LOG_PATH=./log2.txt

To specify a seed file for your game, you can use the SEED_PATH argument. By default this is set to ./seed.txt.

touch ./seed2.txt
./bin/record.py SEED_PATH=./seed2.txt

The ./bin/record.py script will automatically run GDB for you if you pass a GDB argument.

Note: By default the script will attempt to run the GDB process in a new tmux pane. If you are not using tmux, you may configure this behaviour by setting the context.terminal variable at the top of the script.

./bin/record.py GDB

About

The core game logic that is at the center of all Play Suipi products

Topics

Resources

License

Stars

Watchers

Forks