From fc6c37bc2e2879707bbb4593e792bbaaaa87071a Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 24 Mar 2024 08:07:42 -0400 Subject: [PATCH] Finished 4th AI prototype, works nicely, we will see for scalability... --- source/ai.adb | 3 +++ source/ai.ads | 60 +++++++++++++++++++++++++++++---------------------------- source/main.adb | 4 ++++ 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/source/ai.adb b/source/ai.adb index 977b63d..1859c0c 100644 --- a/source/ai.adb +++ b/source/ai.adb @@ -6,6 +6,9 @@ package body ai is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + function agent_is_thirsty (index : in natural) return boolean is begin return (agent (index).mind and thirst) = thirst; end agent_is_thirsty; + function agent_is_hungry (index : in natural) return boolean is begin return (agent (index).mind and hunger) = hunger; end agent_is_hungry; + procedure configure is begin core.echo (core.failure, "No AI yet folk!"); diff --git a/source/ai.ads b/source/ai.ads index 0e46a9a..b6754a7 100644 --- a/source/ai.ads +++ b/source/ai.ads @@ -8,36 +8,34 @@ package ai is none, walk, talk, find ); - type mind_limit is ( - thirst, hunger, fatigue, solitude, - ); - subtype string_16 is string (1 .. 16); - envy : constant natural := 2#00000001#; - gluttony : constant natural := 2#00000010#; - greed : constant natural := 2#00000100#; - lust : constant natural := 2#00001000#; - pride : constant natural := 2#00010000#; - sloth : constant natural := 2#00100000#; - wrath : constant natural := 2#01000000#; - - thirst : constant natural := 2#00000001#; - hunger : constant natural := 2#00000010#; - fatigue : constant natural := 2#00000100#; - solitude : constant natural := 2#00001000#; - health : constant natural := 2#00010000#; - mana : constant natural := 2#00100000#; - boredom : constant natural := 2#01000000#; - - agent_digit : constant natural := 4; - agent_state : constant natural := 4; + agent_digit : constant natural := 8; + agent_state : constant natural := 2; agent_count : constant natural := 4; type name_limit is mod 400; type clan_limit is mod 120; type data_limit is mod agent_state ** agent_digit - 1; + 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#; + mana : constant data_limit := 2#00100000#; + boredom : constant data_limit := 2#01000000#; + + type byte is new natural range 0 .. 2 ** 8 - 1; + type action_data is record base : data_limit; @@ -49,9 +47,8 @@ package ai is record name : name_limit; clan : clan_limit; - data : data_limit; - soul : soul_limit; - mind : mind_limit; + soul : data_limit; + mind : data_limit; work : action; x : natural; y : natural; @@ -59,16 +56,21 @@ package ai is ------------------------------------------------------------------------------------------ + function agent_is_thirsty (index : in natural) return boolean; + function agent_is_hungry (index : in natural) return boolean; + procedure action_none; procedure action_walk; procedure action_talk; procedure action_find; + agent : array (1 .. agent_count) of agent_data := (others => (0, 0, 3, 3, walk, 0, 0)); + action_array : constant array (action) of action_data := ( - (4#3000#, action_none'access, "standing "), - (4#3000#, action_walk'access, "walking "), - (4#3000#, action_talk'access, "talking "), - (4#3000#, action_find'access, "finding ") + (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 := ( diff --git a/source/main.adb b/source/main.adb index f2d6ac7..8fa648a 100644 --- a/source/main.adb +++ b/source/main.adb @@ -166,6 +166,10 @@ begin ui.draw_text_box (0, core.window_height - 32, core.window_width, 32); end loop gameplay; + + core.echo (core.export, "Bot 1 is thirsty is " & boolean'image (ai.agent_is_thirsty (1))); + core.echo (core.export, "Bot 1 is hungry is " & boolean'image (ai.agent_is_hungry (1))); + ------------------------------------------------------------------------------------------ core.deinitialize;