aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:13 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:13 +0100
commite5a215752802ecacbad6bb457c82a878a7640660 (patch)
treea3989d938b1154bc329fa569b523b38c79e5585a
parentd6037472b4bbff809092f3ec2c9328b663956224 (diff)
Processes can now eat from writeable addresses only.
I've found that allowing organisms to eat from everywhere (including addresses owned by other organisms) made the simulation too unstable. Organisms may now eat from either free memory, or from self-owned memory.
-rw-r--r--src/process.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/process.c b/src/process.c
index 8d500ae..4004ae1 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1286,7 +1286,13 @@ static boolean eat_seek(uint32 pidx, boolean forward)
return FALSE;
}
- if (g_procs[pidx].sp == next_addr) {
+ /* Processes may only eat code copies from memory areas that are either
+ deallocated or owned by them (i.e. writeable).
+ */
+ if (
+ !is_writeable_by(pidx, g_procs[pidx].sp) ||
+ g_procs[pidx].sp == next_addr
+ ) {
increment_sp(pidx, forward);
return FALSE;
}
@@ -1313,7 +1319,8 @@ static void eat(uint32 pidx)
However, whenever an organism eats, the detected copy of the source code
gets destroyed (randomized). The main idea of the EAT instruction is to
- turn 'information' into a valuable resource in Salis.
+ turn 'information' into a valuable resource in Salis. Organisms,
+ nonetheless, may only eat information which they have 'write' access to.
*/
uint32 source;
uint32 target;