From de7a604e52a3ae55d2ab7cb44f635810f237b3b1 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 27 Nov 2011 02:54:52 +0100 Subject: [PATCH] Dead bodies have (slowly decaying) energy --- agent.cc | 7 ++++++- world.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/agent.cc b/agent.cc index d63f14d..a6dfeb1 100644 --- a/agent.cc +++ b/agent.cc @@ -34,6 +34,7 @@ void agent::die(void) { dead = true; + energy = world::dead_body_energy; } void @@ -50,9 +51,13 @@ agent::on_tick(void) { if (!dead) { energy += world::sun_energy; - if (energy <= 0) die(); + + } else { + energy += world::dead_decay; + if (energy < 0) + energy = 0; } } diff --git a/world.h b/world.h index dbfad88..e8afd4c 100644 --- a/world.h +++ b/world.h @@ -5,6 +5,9 @@ struct world { const static int newborn_energy = 500; const static int move_cost = 10; const static int sun_energy = 1; + + const static int dead_body_energy = 500; + const static int dead_decay = -1; }; #endif