From e5a215752802ecacbad6bb457c82a878a7640660 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 02:29:13 +0100 Subject: 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. --- src/process.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/process.c') 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; -- cgit v1.2.1