diff --git a/Polonium.csproj b/Polonium.csproj index d78ccb7..ab814f7 100644 --- a/Polonium.csproj +++ b/Polonium.csproj @@ -8,12 +8,12 @@ false Polonium true - 0.0.167-d + 0.1.0 Hangman - + : Agent + where TAgent : Agent + where TAgentDecisionMaker : AgentDecisionMaker, new() + where TAgentKnowledge : AgentKnowledge, new() +{ + + private static int ComputerCount = 0; + public TAgentDecisionMaker DecisionMaker { get; init; } + public TAgentKnowledge Knowledge { get; init; } + + + public Agent() : base($"Computer {ComputerCount++}") + { + DecisionMaker = new TAgentDecisionMaker(); + Knowledge = new TAgentKnowledge(); + } + + public Agent(string name, TAgentDecisionMaker decisionMaker, TAgentKnowledge knowledge) : base(name) + { + DecisionMaker = decisionMaker; + Knowledge = knowledge; + } +} diff --git a/src/Agents/AgentDecisionMaker.cs b/src/Agents/AgentDecisionMaker.cs new file mode 100644 index 0000000..c5d28bd --- /dev/null +++ b/src/Agents/AgentDecisionMaker.cs @@ -0,0 +1,28 @@ +namespace Polonium.Agents; + +public abstract class AgentDecisionMaker + where TAgent : Agent + where TAgentDecisionMaker : AgentDecisionMaker, new() + where TAgentKnowledge : AgentKnowledge, new() +{ + + public enum DecisionMakerType + { + None = 0, + Player = 1, + Computer = 2, + Global = 3, + } + + public DecisionMakerType Type { get; init; } + + public AgentDecisionMaker() + { + Type = DecisionMakerType.Computer; + } + + public AgentDecisionMaker(DecisionMakerType type) + { + Type = type; + } +} \ No newline at end of file diff --git a/src/Agents/AgentKnowledge.cs b/src/Agents/AgentKnowledge.cs new file mode 100644 index 0000000..8f986b1 --- /dev/null +++ b/src/Agents/AgentKnowledge.cs @@ -0,0 +1,13 @@ +namespace Polonium.Agents; + +public abstract class AgentKnowledge + where TAgent : Agent + where TAgentDecisionMaker : AgentDecisionMaker, new() + where TAgentKnowledge : AgentKnowledge, new() +{ + public AgentKnowledge() + { + } + + public abstract void Update(TAgentKnowledge newKnowledge); +} diff --git a/src/Attributes/ProxyMethod.cs b/src/Attributes/ProxyMethod.cs new file mode 100644 index 0000000..cacd204 --- /dev/null +++ b/src/Attributes/ProxyMethod.cs @@ -0,0 +1,6 @@ +namespace Polonium.Attributes; +[AttributeUsage(AttributeTargets.Method)] +public class ProxyMethod : Attribute +{ + +} \ No newline at end of file diff --git a/src/PoloniumRegistry.cs b/src/PoloniumRegistry.cs index 4460893..5b775dc 100644 --- a/src/PoloniumRegistry.cs +++ b/src/PoloniumRegistry.cs @@ -1,4 +1,5 @@ using Godot; +using Polonium.Agents; using Polonium.Resources; using Polonium.Scenes; @@ -16,4 +17,5 @@ public class PoloniumRegistry { DirAccess.MakeDirAbsolute("user://saves"); } + public Dictionary Agents { get; set; } = new(); } \ No newline at end of file diff --git a/src/Scenes/LoadingScene.cs b/src/Scenes/LoadingScene.cs index af4c8ea..513a091 100644 --- a/src/Scenes/LoadingScene.cs +++ b/src/Scenes/LoadingScene.cs @@ -1,9 +1,8 @@ -using Godot; + using Polonium.DataStructures; using Polonium.Managers; namespace Polonium.Scenes; - public abstract partial class LoadingScene : Scene where T : ProgressInfo { diff --git a/src/Scenes/RootScene.cs b/src/Scenes/RootScene.cs index 4ee35f2..58f8f94 100644 --- a/src/Scenes/RootScene.cs +++ b/src/Scenes/RootScene.cs @@ -6,7 +6,7 @@ namespace Polonium.Scenes; public partial class RootScene : Node2D { private Scene CurrentScene { get; set; } - + public void SwitchScene(Scene scene) { if (CurrentScene != null) @@ -20,4 +20,15 @@ public partial class RootScene : Node2D PoloniumRegistry.Instance.RootScene = this; base._Ready(); } + + [ProxyMethod] + public virtual void Enter() + { + } + + public override void _EnterTree() + { + Enter(); + base._EnterTree(); + } } \ No newline at end of file diff --git a/src/Scenes/Scene.cs b/src/Scenes/Scene.cs index 434bebc..0a5bde4 100644 --- a/src/Scenes/Scene.cs +++ b/src/Scenes/Scene.cs @@ -1,8 +1,9 @@ using Godot; +using Polonium.Attributes; namespace Polonium.Scenes; - -public abstract partial class Scene : Node2D +[ProxyNode] +public partial class Scene : Node2D { } \ No newline at end of file