Skip to content

Commit

Permalink
Upgrade README
Browse files Browse the repository at this point in the history
  • Loading branch information
nluka committed May 14, 2023
1 parent 41373d8 commit 70c4b45
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 56 deletions.
105 changes: 59 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

A high-performance toolchain for discovering interesting [Langton's Ant](https://en.wikipedia.org/wiki/Langton%27s_ant) outcomes.

## Table of Contents
- [The Toolchain](#toolchain)
- [Building](#building)
- [Third Party Libraries Used](#third-party-libraries-used)

<img src="resources/gallery1.png" />
<img src="resources/gallery2.png" style="margin-bottom:2rem;" />

## Toolchain
The toolchain consists of 5 separate programs designed to work together:
- [next_cluster](#next_cluster)
- Determines the next cluster number in a directory of clusters
Expand All @@ -19,52 +25,7 @@ The toolchain consists of 5 separate programs designed to work together:
- Similar to `simulate_one`, but runs a batch of simulations in a thread pool, intended for mass processing
- Simulations share a generation limit, save points, and save interval, but not state

Having separate programs creates flexibility by allowing users to orchestrate them as desired. A simple example script for creating clusters of simulations:

```sh
if [ $# -ne 2 ]; then
printf 'Usage: cluster.sh <out_dir> <sim_count>'
exit 1
fi

width=1000
height=1000
col=500
row=500
gen_limit=10000000000
out_dir=$1
sim_count=$2

./next_cluster_release.exe ${out_dir}
cluster=$?

printf "Cluster %d, %s\n" ${cluster} ${out_dir}

./make_states_release.exe \
-N ${sim_count} \
-o ${out_dir}/cluster${cluster} \
-n randwords,2 \
-m 256 -M 256 \
-t LR \
-s rand \
-w ${width} -h ${height} \
-x ${col} -y ${row} \
-O NESW \
-g fill=0 \
-W words.txt \
-c
wait

./simulate_many_release.exe \
-T 6 \
-L ${out_dir}/cluster${cluster}/log.txt \
-S ${out_dir}/cluster${cluster} \
-g ${gen_limit} \
-f raw \
-o ${out_dir}/cluster${cluster} \
-s -y -l
wait
```
Having separate programs creates flexibility by allowing users to orchestrate them as desired. See [scripts/cluster.py](/scripts/cluster.py) for a simple example script for creating clusters of simulations.

## make_states

Expand Down Expand Up @@ -273,6 +234,58 @@ Visualized:

<img src="resources/rules.svg" />

## Building

For now the primary supported platform is Linux. As such, only Linux has a build system included. This project uses make.

To build the toolchain in release (optimized) mode, run:

```shell
make -j $(nproc)
```

To build a specific program from the toolchain, run one of:

```shell
make -j $(nproc) next_cluster
make -j $(nproc) make_states
make -j $(nproc) make_image
make -j $(nproc) simulate_one
make -j $(nproc) simulate_many
```

To build the toolchain in debug mode, use `BUILD_TYPE=debug`:

```shell
# The whole toolchain:
make -j $(nproc) BUILD_TYPE=debug

# A specific program from the toolchain:
make -j $(nproc) BUILD_TYPE=debug next_cluster
make -j $(nproc) BUILD_TYPE=debug make_states
make -j $(nproc) BUILD_TYPE=debug make_image
make -j $(nproc) BUILD_TYPE=debug simulate_one
make -j $(nproc) BUILD_TYPE=debug simulate_many
```

To build and run the testing suite in debug mode (recommended), run:

```shell
make -j $(nproc) BUILD_TYPE=debug tests && bin/debug/tests
```

To build and run the testing suite in release mode, run:

```shell
make -j $(nproc) tests && bin/release/tests
```

And the usual cleaning process:

```shell
make clean
```

## Third Party Libraries Used

- [Boost 1.80.0](https://www.boost.org/users/history/version_1_80_0.html) (modules: program_options, container)
Expand Down
2 changes: 1 addition & 1 deletion src/simulation_parse_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ simulation::state simulation::parse_state(
auto const validate_property_set = [&json, &add_err](char const *const key) -> i8 {
u64 const num_occurences = json.count(key);
if (num_occurences == 0) {
add_err(make_str("`%s` not set", key));
add_err(make_str("%s not set", key));
return 0;
} else {
return 1;
Expand Down
18 changes: 9 additions & 9 deletions src/testing_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ i32 main()
};

assert_parse({/* state */}, {
"`generation` not set",
"`last_step_result` not set",
"`grid_width` not set",
"`grid_height` not set",
"`grid_state` not set",
"`ant_col` not set",
"`ant_row` not set",
"`ant_orientation` not set",
"`rules` not set",
"generation not set",
"last_step_result not set",
"grid_width not set",
"grid_height not set",
"grid_state not set",
"ant_col not set",
"ant_row not set",
"ant_orientation not set",
"rules not set",
}, "occurence_errors.json");

assert_parse({/* state */}, {
Expand Down

0 comments on commit 70c4b45

Please sign in to comment.