summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/lib94/lib94.hpp4
-rw-r--r--lib94/core.cpp4
-rw-r--r--lib94/executors.cpp9
-rw-r--r--readme.txt3
4 files changed, 16 insertions, 4 deletions
diff --git a/include/lib94/lib94.hpp b/include/lib94/lib94.hpp
index cfbb978..c91c24b 100644
--- a/include/lib94/lib94.hpp
+++ b/include/lib94/lib94.hpp
@@ -12,6 +12,10 @@
#define LIB94_CORE_SIZE 8000
#endif
+#ifndef LIB94_MAX_PROCESSES
+#define LIB94_MAX_PROCESSES 16000
+#endif
+
namespace lib94 {
//this type is used to represent values inside the core.
diff --git a/lib94/core.cpp b/lib94/core.cpp
index 1c09b3f..1693c39 100644
--- a/lib94/core.cpp
+++ b/lib94/core.cpp
@@ -259,6 +259,10 @@ namespace lib94 {
this_warrior->processes.push_back(pc);
}
+ bool at_process_limit() {
+ return this_warrior->processes.size() + 1 == LIB94_MAX_PROCESSES;
+ }
+
template <bool update_address_sets>
const warrior *single_step() {
this_warrior = alive_warriors.front();
diff --git a/lib94/executors.cpp b/lib94/executors.cpp
index 0e75cfa..e90e329 100644
--- a/lib94/executors.cpp
+++ b/lib94/executors.cpp
@@ -5,6 +5,7 @@
namespace lib94 {
void enqueue_process(number_t pc);
+ bool at_process_limit();
extern instruction core[LIB94_CORE_SIZE];
extern number_t program_counter;
@@ -336,9 +337,11 @@ namespace lib94 {
}
else if constexpr (op == SPL) {
- maybe_add_read_instruction(a_instruction_writable);
- enqueue_process((program_counter + 1) % LIB94_CORE_SIZE);
- program_counter = (a_instruction_writable - core + LIB94_CORE_SIZE - 1) % LIB94_CORE_SIZE;
+ if (!at_process_limit()) {
+ maybe_add_read_instruction(a_instruction_writable);
+ enqueue_process((program_counter + 1) % LIB94_CORE_SIZE);
+ program_counter = (a_instruction_writable - core + LIB94_CORE_SIZE - 1) % LIB94_CORE_SIZE;
+ }
return true;
}
diff --git a/readme.txt b/readme.txt
index 1691370..0b09e32 100644
--- a/readme.txt
+++ b/readme.txt
@@ -14,7 +14,8 @@ Then, to build all of the software, just run make.
lib94 attempts to follow the draft standard at <https://corewar.co.uk/standards/icws94.txt>, minus P-space. There are no read/write
limits (or if you prefer, they are the same as the core size). The minimum separation is always 0, and the core size is set at 8000.
-To change the core size, change LIB94_CORE_SIZE in include/lib94/lib94.hpp, run make clean, and then run make.
+To change the core size, change LIB94_CORE_SIZE in include/lib94/lib94.hpp, run make clean, and then run make. The maximum number of
+processes is set at 16000. To change that, change LIB94_MAX_PROCESSES in include/lib94/lib94.hpp, run make clean, and then run make.
=== bench ===