Changed AI prototype structure to use global variables for implementation simplicity.
This commit is contained in:
parent
b8088023ec
commit
3c7cd66cb7
@ -6,20 +6,20 @@ package body ai is
|
|||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
function agent_is_envious (index : in natural) return boolean is begin return (agent (index).soul and envy) = envy; end agent_is_envious;
|
function actor_is_envious return boolean is begin return (actor (active).soul and envy) = envy; end actor_is_envious;
|
||||||
function agent_is_glutton (index : in natural) return boolean is begin return (agent (index).soul and gluttony) = gluttony; end agent_is_glutton;
|
function actor_is_glutton return boolean is begin return (actor (active).soul and gluttony) = gluttony; end actor_is_glutton;
|
||||||
function agent_is_greedy (index : in natural) return boolean is begin return (agent (index).soul and greed) = greed; end agent_is_greedy;
|
function actor_is_greedy return boolean is begin return (actor (active).soul and greed) = greed; end actor_is_greedy;
|
||||||
function agent_is_slutty (index : in natural) return boolean is begin return (agent (index).soul and lust) = lust; end agent_is_slutty;
|
function actor_is_slutty return boolean is begin return (actor (active).soul and lust) = lust; end actor_is_slutty;
|
||||||
function agent_is_proud (index : in natural) return boolean is begin return (agent (index).soul and pride) = pride; end agent_is_proud;
|
function actor_is_proud return boolean is begin return (actor (active).soul and pride) = pride; end actor_is_proud;
|
||||||
function agent_is_lazy (index : in natural) return boolean is begin return (agent (index).soul and sloth) = sloth; end agent_is_lazy;
|
function actor_is_lazy return boolean is begin return (actor (active).soul and sloth) = sloth; end actor_is_lazy;
|
||||||
function agent_is_angry (index : in natural) return boolean is begin return (agent (index).soul and wrath) = wrath; end agent_is_angry;
|
function actor_is_angry return boolean is begin return (actor (active).soul and wrath) = wrath; end actor_is_angry;
|
||||||
function agent_is_thirsty (index : in natural) return boolean is begin return (agent (index).mind and thirst) = thirst; end agent_is_thirsty;
|
function actor_is_thirsty return boolean is begin return (actor (active).mind and thirst) = thirst; end actor_is_thirsty;
|
||||||
function agent_is_hungry (index : in natural) return boolean is begin return (agent (index).mind and hunger) = hunger; end agent_is_hungry;
|
function actor_is_hungry return boolean is begin return (actor (active).mind and hunger) = hunger; end actor_is_hungry;
|
||||||
function agent_is_tired (index : in natural) return boolean is begin return (agent (index).mind and fatigue) = fatigue; end agent_is_tired;
|
function actor_is_tired return boolean is begin return (actor (active).mind and fatigue) = fatigue; end actor_is_tired;
|
||||||
function agent_is_lonely (index : in natural) return boolean is begin return (agent (index).mind and solitude) = solitude; end agent_is_lonely;
|
function actor_is_lonely return boolean is begin return (actor (active).mind and solitude) = solitude; end actor_is_lonely;
|
||||||
function agent_is_healthy (index : in natural) return boolean is begin return (agent (index).mind and health) = health; end agent_is_healthy;
|
function actor_is_healthy return boolean is begin return (actor (active).mind and health) = health; end actor_is_healthy;
|
||||||
function agent_is_happy (index : in natural) return boolean is begin return (agent (index).mind and joy) = joy; end agent_is_happy;
|
function actor_is_happy return boolean is begin return (actor (active).mind and joy) = joy; end actor_is_happy;
|
||||||
function agent_is_bored (index : in natural) return boolean is begin return (agent (index).mind and boredom) = boredom; end agent_is_bored;
|
function actor_is_bored return boolean is begin return (actor (active).mind and boredom) = boredom; end actor_is_bored;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -32,9 +32,9 @@ package body ai is
|
|||||||
|
|
||||||
procedure serialize (i : in natural) is
|
procedure serialize (i : in natural) is
|
||||||
begin
|
begin
|
||||||
if agent_is_bored (i) and agent_is_healthy (i) and not agent_is_hungry (i) then
|
--~if actor_is_bored (i) and actor_is_healthy (i) and not actor_is_hungry (i) then
|
||||||
null;
|
null;
|
||||||
end if;
|
--~end if;
|
||||||
end serialize;
|
end serialize;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
@ -48,28 +48,31 @@ package body ai is
|
|||||||
|
|
||||||
procedure synchronize is
|
procedure synchronize is
|
||||||
begin
|
begin
|
||||||
core.echo (core.failure, "No AI yet folk!");
|
null;
|
||||||
end synchronize;
|
end synchronize;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
procedure review is
|
procedure review is
|
||||||
width : integer := 600;
|
--~width : integer := 600;
|
||||||
height : integer := 300;
|
--~height : integer := 300;
|
||||||
offset : integer := 32;
|
--~offset : integer := 32;
|
||||||
x : integer := (core.window_width - width) / 2;
|
--~x : integer := (core.window_width - width) / 2;
|
||||||
y : integer := (core.window_height - height) / 2;
|
--~y : integer := (core.window_height - height) / 2;
|
||||||
begin
|
begin
|
||||||
ui.draw_tiny_menu (x, y, width, height, true);
|
--~ui.draw_tiny_menu (x, y, width, height, true);
|
||||||
for index in 1 .. agent_count
|
--~for index in 1 .. actor_count
|
||||||
loop
|
--~loop
|
||||||
core.write ("Bot" & integer'image (index), x + offset + 0, y * index + offset, ui.glyphs (ui.active));
|
--~core.write ("Bot" & integer'image (index), x + offset + 0, y * index + offset, ui.glyphs (ui.active));
|
||||||
core.write ("T =" & boolean'image (agent_is_thirsty (index)), x + offset + 120, y * index + offset, ui.glyphs (ui.active));
|
--~core.write ("T =" & boolean'image (actor_is_thirsty (index)), x + offset + 120, y * index + offset, ui.glyphs (ui.active));
|
||||||
core.write ("H =" & boolean'image (agent_is_hungry (index)), x + offset + 240, y * index + offset, ui.glyphs (ui.active));
|
--~core.write ("H =" & boolean'image (actor_is_hungry (index)), x + offset + 240, y * index + offset, ui.glyphs (ui.active));
|
||||||
end loop;
|
--~end loop;
|
||||||
|
null;
|
||||||
end review;
|
end review;
|
||||||
|
|
||||||
procedure view_agent_state (index : in integer) is
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
procedure view_actor_state (index : in integer) is
|
||||||
width : integer := 320;
|
width : integer := 320;
|
||||||
height : integer := 544;
|
height : integer := 544;
|
||||||
offset : integer := 32;
|
offset : integer := 32;
|
||||||
@ -78,23 +81,25 @@ package body ai is
|
|||||||
begin
|
begin
|
||||||
ui.draw_tiny_menu (x, y, width, height, true);
|
ui.draw_tiny_menu (x, y, width, height, true);
|
||||||
--
|
--
|
||||||
core.write (male_name_array (agent (index).name), x + offset, y + offset, ui.glyphs (ui.active));
|
active := index;
|
||||||
--
|
--
|
||||||
core.write ("Envious =" & boolean'image (agent_is_envious (index)), x + offset, y + offset + 32, ui.glyphs (ui.active));
|
core.write (male_name_array (actor (index).name), x + offset, y + offset, ui.glyphs (ui.active));
|
||||||
core.write ("Glutton =" & boolean'image (agent_is_glutton (index)), x + offset, y + offset + 64, ui.glyphs (ui.active));
|
--
|
||||||
core.write ("Greedy =" & boolean'image (agent_is_greedy (index)), x + offset, y + offset + 96, ui.glyphs (ui.active));
|
core.write ("Envious = " & boolean'image (actor_is_envious), x + offset, y + offset + 32, ui.glyphs (ui.active));
|
||||||
core.write ("Slutty =" & boolean'image (agent_is_slutty (index)), x + offset, y + offset + 128, ui.glyphs (ui.active));
|
core.write ("Glutton = " & boolean'image (actor_is_glutton), x + offset, y + offset + 64, ui.glyphs (ui.active));
|
||||||
core.write ("Proud =" & boolean'image (agent_is_proud (index)), x + offset, y + offset + 160, ui.glyphs (ui.active));
|
core.write ("Greedy = " & boolean'image (actor_is_greedy), x + offset, y + offset + 96, ui.glyphs (ui.active));
|
||||||
core.write ("Lazy =" & boolean'image (agent_is_lazy (index)), x + offset, y + offset + 192, ui.glyphs (ui.active));
|
core.write ("Slutty = " & boolean'image (actor_is_slutty), x + offset, y + offset + 128, ui.glyphs (ui.active));
|
||||||
core.write ("Angry =" & boolean'image (agent_is_angry (index)), x + offset, y + offset + 224, ui.glyphs (ui.active));
|
core.write ("Proud = " & boolean'image (actor_is_proud), x + offset, y + offset + 160, ui.glyphs (ui.active));
|
||||||
core.write ("Thirsty =" & boolean'image (agent_is_thirsty (index)), x + offset, y + offset + 256, ui.glyphs (ui.active));
|
core.write ("Lazy = " & boolean'image (actor_is_lazy), x + offset, y + offset + 192, ui.glyphs (ui.active));
|
||||||
core.write ("Hungry =" & boolean'image (agent_is_hungry (index)), x + offset, y + offset + 288, ui.glyphs (ui.active));
|
core.write ("Angry = " & boolean'image (actor_is_angry), x + offset, y + offset + 224, ui.glyphs (ui.active));
|
||||||
core.write ("Tired =" & boolean'image (agent_is_tired (index)), x + offset, y + offset + 320, ui.glyphs (ui.active));
|
core.write ("Thirsty = " & boolean'image (actor_is_thirsty), x + offset, y + offset + 256, ui.glyphs (ui.active));
|
||||||
core.write ("Lonely =" & boolean'image (agent_is_lonely (index)), x + offset, y + offset + 352, ui.glyphs (ui.active));
|
core.write ("Hungry = " & boolean'image (actor_is_hungry), x + offset, y + offset + 288, ui.glyphs (ui.active));
|
||||||
core.write ("Healthy =" & boolean'image (agent_is_healthy (index)), x + offset, y + offset + 384, ui.glyphs (ui.active));
|
core.write ("Tired = " & boolean'image (actor_is_tired), x + offset, y + offset + 320, ui.glyphs (ui.active));
|
||||||
core.write ("Happy =" & boolean'image (agent_is_happy (index)), x + offset, y + offset + 416, ui.glyphs (ui.active));
|
core.write ("Lonely = " & boolean'image (actor_is_lonely), x + offset, y + offset + 352, ui.glyphs (ui.active));
|
||||||
core.write ("Bored =" & boolean'image (agent_is_bored (index)), x + offset, y + offset + 448, ui.glyphs (ui.active));
|
core.write ("Healthy = " & boolean'image (actor_is_healthy), x + offset, y + offset + 384, ui.glyphs (ui.active));
|
||||||
end view_agent_state;
|
core.write ("Happy = " & boolean'image (actor_is_happy), x + offset, y + offset + 416, ui.glyphs (ui.active));
|
||||||
|
core.write ("Bored = " & boolean'image (actor_is_bored), x + offset, y + offset + 448, ui.glyphs (ui.active));
|
||||||
|
end view_actor_state;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
103
source/ai.ads
103
source/ai.ads
@ -10,29 +10,9 @@ package ai is
|
|||||||
|
|
||||||
subtype string_16 is string (1 .. 16);
|
subtype string_16 is string (1 .. 16);
|
||||||
|
|
||||||
agent_digit : constant natural := 8;
|
|
||||||
agent_state : constant natural := 2;
|
|
||||||
agent_count : constant natural := 4;
|
|
||||||
|
|
||||||
type name_limit is mod 400;
|
type name_limit is mod 400;
|
||||||
type clan_limit is mod 120;
|
type clan_limit is mod 120;
|
||||||
type data_limit is mod agent_state ** agent_digit - 1;
|
type data_limit is mod 256;
|
||||||
|
|
||||||
envy : constant data_limit := 2#00000001#;
|
|
||||||
gluttony : constant data_limit := 2#00000010#;
|
|
||||||
greed : constant data_limit := 2#00000100#;
|
|
||||||
lust : constant data_limit := 2#00001000#;
|
|
||||||
pride : constant data_limit := 2#00010000#;
|
|
||||||
sloth : constant data_limit := 2#00100000#;
|
|
||||||
wrath : constant data_limit := 2#01000000#;
|
|
||||||
|
|
||||||
thirst : constant data_limit := 2#00000001#;
|
|
||||||
hunger : constant data_limit := 2#00000010#;
|
|
||||||
fatigue : constant data_limit := 2#00000100#;
|
|
||||||
solitude : constant data_limit := 2#00001000#;
|
|
||||||
health : constant data_limit := 2#00010000#;
|
|
||||||
joy : constant data_limit := 2#00100000#;
|
|
||||||
boredom : constant data_limit := 2#01000000#;
|
|
||||||
|
|
||||||
-- CONCIOUSNESS
|
-- CONCIOUSNESS
|
||||||
-- UNCONCIOUSNESS
|
-- UNCONCIOUSNESS
|
||||||
@ -71,7 +51,7 @@ package ai is
|
|||||||
name : core.short_string;
|
name : core.short_string;
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
type agent_data is
|
type actor_data is
|
||||||
record
|
record
|
||||||
name : name_limit;
|
name : name_limit;
|
||||||
clan : clan_limit;
|
clan : clan_limit;
|
||||||
@ -84,36 +64,12 @@ package ai is
|
|||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
function agent_is_envious (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_glutton (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_greedy (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_slutty (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_proud (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_lazy (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_angry (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_thirsty (index : in natural) return boolean;
|
|
||||||
function agent_is_hungry (index : in natural) return boolean;
|
|
||||||
function agent_is_tired (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_lonely (index : in natural) return boolean;
|
|
||||||
function agent_is_healthy (index : in natural) return boolean;
|
|
||||||
function agent_is_happy (index : in natural) return boolean; -- wtf
|
|
||||||
function agent_is_bored (index : in natural) return boolean; -- wtf
|
|
||||||
|
|
||||||
procedure action_none;
|
procedure action_none;
|
||||||
procedure action_walk;
|
procedure action_walk;
|
||||||
procedure action_talk;
|
procedure action_talk;
|
||||||
procedure action_find;
|
procedure action_find;
|
||||||
|
|
||||||
procedure view_agent_state (index : in integer);
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
agent : array (1 .. agent_count) of agent_data := ((0, 0, 1, 1, walk, 0, 0), others => (0, 0, 3, 3, walk, 0, 0));
|
|
||||||
|
|
||||||
action_array : constant array (action) of action_data := (
|
|
||||||
(2#00000000#, action_none'access, "standing "),
|
|
||||||
(2#00000000#, action_walk'access, "walking "),
|
|
||||||
(2#00000000#, action_talk'access, "talking "),
|
|
||||||
(2#00000000#, action_find'access, "finding ")
|
|
||||||
);
|
|
||||||
|
|
||||||
male_name_array : constant array (name_limit) of string_16 := (
|
male_name_array : constant array (name_limit) of string_16 := (
|
||||||
"Unumis ", "Aardappel ", "Aaron ", "Abel ", "Abgar ", "Abiathar ", "Abijah ", "Abraham ",
|
"Unumis ", "Aardappel ", "Aaron ", "Abel ", "Abgar ", "Abiathar ", "Abijah ", "Abraham ",
|
||||||
@ -221,7 +177,7 @@ package ai is
|
|||||||
"Zepyur ", "Zilpah ", "Zina ", "Zipporah ", "Zod ", "Zophea ", "Zora ", "Zuanai "
|
"Zepyur ", "Zilpah ", "Zina ", "Zipporah ", "Zod ", "Zophea ", "Zora ", "Zuanai "
|
||||||
);
|
);
|
||||||
|
|
||||||
clan_name_array : constant array (clan_limit) of string_16 := (
|
clan_array : constant array (clan_limit) of string_16 := (
|
||||||
"Aldheln ", "Abedol ", "Adonis ", "Amelin ", "Ankonih ", "Aoshin ", "Ariel ", "Arma ",
|
"Aldheln ", "Abedol ", "Adonis ", "Amelin ", "Ankonih ", "Aoshin ", "Ariel ", "Arma ",
|
||||||
"Arthel ", "Ashal ", "Astrid ", "Avdotiya ", "Barkur ", "Bavakiel ", "Bednudan ", "Calarian ",
|
"Arthel ", "Ashal ", "Astrid ", "Avdotiya ", "Barkur ", "Bavakiel ", "Bednudan ", "Calarian ",
|
||||||
"Chleayan ", "Cinnkhan ", "Dairin ", "Daok ", "Daudroht ", "Deakan ", "Degerynn ", "Demenokt ",
|
"Chleayan ", "Cinnkhan ", "Dairin ", "Daok ", "Daudroht ", "Deakan ", "Degerynn ", "Demenokt ",
|
||||||
@ -239,14 +195,63 @@ package ai is
|
|||||||
"Velian ", "Verlon ", "Volash ", "Yaad ", "Yarren ", "Zeanash ", "Ziinyakh ", "Zuno "
|
"Velian ", "Verlon ", "Volash ", "Yaad ", "Yarren ", "Zeanash ", "Ziinyakh ", "Zuno "
|
||||||
);
|
);
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
actor_digit : constant natural := 8;
|
||||||
|
actor_state : constant natural := 2;
|
||||||
|
actor_count : constant natural := 4;
|
||||||
|
|
||||||
|
envy : constant data_limit := 2#00000001#;
|
||||||
|
gluttony : constant data_limit := 2#00000010#;
|
||||||
|
greed : constant data_limit := 2#00000100#;
|
||||||
|
lust : constant data_limit := 2#00001000#;
|
||||||
|
pride : constant data_limit := 2#00010000#;
|
||||||
|
sloth : constant data_limit := 2#00100000#;
|
||||||
|
wrath : constant data_limit := 2#01000000#;
|
||||||
|
|
||||||
|
thirst : constant data_limit := 2#00000001#;
|
||||||
|
hunger : constant data_limit := 2#00000010#;
|
||||||
|
fatigue : constant data_limit := 2#00000100#;
|
||||||
|
solitude : constant data_limit := 2#00001000#;
|
||||||
|
health : constant data_limit := 2#00010000#;
|
||||||
|
joy : constant data_limit := 2#00100000#;
|
||||||
|
boredom : constant data_limit := 2#01000000#;
|
||||||
|
|
||||||
|
action_array : constant array (action) of action_data := (
|
||||||
|
(2#00000000#, action_none'access, "standing "),
|
||||||
|
(2#00000000#, action_walk'access, "walking "),
|
||||||
|
(2#00000000#, action_talk'access, "talking "),
|
||||||
|
(2#00000000#, action_find'access, "finding ")
|
||||||
|
);
|
||||||
|
|
||||||
|
actor : array (1 .. actor_count) of actor_data := (
|
||||||
|
(0, 0, 3, 3, talk, 0, 0), -- Ignore
|
||||||
|
others => (0, 0, 1, 1, walk, 0, 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
active : natural := 1;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function actor_is_envious return boolean; -- wtf
|
||||||
|
function actor_is_glutton return boolean; -- wtf
|
||||||
|
function actor_is_greedy return boolean; -- wtf
|
||||||
|
function actor_is_slutty return boolean; -- wtf
|
||||||
|
function actor_is_proud return boolean; -- wtf
|
||||||
|
function actor_is_lazy return boolean; -- wtf
|
||||||
|
function actor_is_angry return boolean; -- wtf
|
||||||
|
function actor_is_thirsty return boolean;
|
||||||
|
function actor_is_hungry return boolean;
|
||||||
|
function actor_is_tired return boolean; -- wtf
|
||||||
|
function actor_is_lonely return boolean;
|
||||||
|
function actor_is_healthy return boolean;
|
||||||
|
function actor_is_happy return boolean; -- wtf
|
||||||
|
function actor_is_bored return boolean; -- wtf
|
||||||
|
|
||||||
procedure configure;
|
procedure configure;
|
||||||
procedure synchronize;
|
procedure synchronize;
|
||||||
procedure review;
|
procedure review;
|
||||||
|
|
||||||
|
procedure view_actor_state (index : in integer);
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
end ai;
|
end ai;
|
||||||
|
@ -160,7 +160,7 @@ begin
|
|||||||
signal_list (core.signal_code'val (core.signal_mode)).all;
|
signal_list (core.signal_code'val (core.signal_mode)).all;
|
||||||
--
|
--
|
||||||
ai.review;
|
ai.review;
|
||||||
ai.view_agent_state (1);
|
ai.view_actor_state (1);
|
||||||
--
|
--
|
||||||
menu_render;
|
menu_render;
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user