Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critter combined tree #113

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
107 changes: 107 additions & 0 deletions assets/behaviors/creatures/combinedCritter.behavior
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
selector: [
{
guard: {

// Territory would to be implemented as Component
// Implementation of territorial Critter
componentPresent: "Behaviours:Territory",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the TerritoryComponent exists in the Behaviors module.

The closest thing we have is TerritoryDistance, a component with two fields distance and location.

Therefore, the referenced component should probably be

Suggested change
componentPresent: "Behaviours:Territory",
componentPresent: "Behaviours:TerritoryDistance",

and the referenced field below cannot be Territory (as it does not exist) but either distance or location. I suspect that we can check whether the location is set.

values: ["F Territory != null"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would try to make a lookup of a field (indicated by F) named null.

However, I believe you want to check against the value null, thus using V would be correct.

Suggested change
values: ["F Territory != null"],
values: ["V Territory != null"],

Alternatively, you can use the exists operator (basically ... != null) without an explicit value to check against:

Suggested change
values: ["F Territory != null"],
values: ["N Territory exists"],

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the comment above about the component, this should most likely be

Suggested change
values: ["F Territory != null"],
values: ["F location exists"],

"child": {
"sequence": [
{
"lookup": {
"tree": "territorialCritter.behavior"
}
}
]
}
}

// First Guard fo Selector for Territory End.
guard: { // Implementation of scared Critter
componentPresent: "Behaviors:FindNearbyPlayers",
values: ["N charactersWithinRange != null"], // Adjust for Nemesis / Scary Creatures
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this in the meeting today.

The N is a parsing directive that specifiies whether the condition has the form type fieldName operator or type fieldName operator valueOrReference.

Technically, we could use V charactersWithinRange != null to ensure that the list itself is defined and not null (checking agains the value null). However, this is not the semantics we are looking for.

Therefore, using the nonEmpty operator on the collection with no value to check against (N) is the solution:

Suggested change
values: ["N charactersWithinRange != null"], // Adjust for Nemesis / Scary Creatures
values: ["N charactersWithinRange nonEmpty"], // Adjust for Nemesis / Scary Creatures


child: {
sequence: [
{
"lookup": {
"tree": "scaredCritter.behavior"
}
}
]
}
}

// Here would be Implementation for Base Needs
guard: {
componentPresent: "CitizenNeed:Water",
value: ["F CitizenNeed:Water.value < CitizenNeed:goal"],
lookup:{
"tree": "findWater.behavior"
}
} ,
// Implementation for Water Need
guard: {
componentPresent: "CitizenNeed:Water",
value: ["F CitizenNeed:Water.value < CitizenNeed:goal"],
lookup:{
"tree": "findWater.behavior"
}
},

// Implementation for Food Need
guard: {
componentPresent: "CitizenNeed:Food",
value: ["F CitizenNeed:Food.value < CitizenNeed:goal"],
needfood == true,
}

// Implementation for Sleep Need
guard: {
componentPresent: "CitizenNeed:Sleep",
value: ["F CitizenNeed:Sleep.value < CitizenNeed:goal"],
lookup:{
"tree": "findRest.behavior"
}
}

guard:{ // From Deer Behavior
componentPresent: "fleeingComponent",
value:["N distance"],
child:{
sequence:[
check_flee_continue,
{lookup: {tree: "Behaviors:flee"}}
]
}
},

guard: {
componentPresent: "Behaviors:FindNearbyEntity", // Implementation ???
values: ["F hungerEntity < 25"],

child: {
"lookup": {"tree": "aggressiveCritter.behavior"}
}
},

guard: { // Implementation for Friendly Critter
componentPresent: "Behaviours:FindNearbyPlayers",
values: ["F itemInHand == nonEmpty"],

child: {
"lookup": {"tree": "friendlyCritter.behavior"}
}
}
},

{
lookup: {
tree: "Behaviors:stray"
}
}

]
}
132 changes: 132 additions & 0 deletions docs/AI_Tree_Concepts/Chaser.drawIo
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<mxfile host="65bd71144e">
<diagram id="ajuhjo6TS9aHFvpaHqaE" name="Page-1">
<mxGraphModel dx="1953" dy="1436" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1800" pageHeight="1600" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="25" value="" style="rounded=0;whiteSpace=wrap;html=1;labelBackgroundColor=#F5F5F5;fontSize=15;fontColor=#ffffff;fillColor=#60a917;strokeColor=#2D7600;opacity=50;" parent="1" vertex="1">
<mxGeometry x="180" y="260" width="460" height="880" as="geometry"/>
</mxCell>
<mxCell id="30" value="-&amp;gt; get Health Nemesis&lt;br&gt;-&amp;gt; Deal Damage&lt;br&gt;-&amp;gt; animation.&lt;br&gt;return new Health value" style="shape=card;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="190" y="910" width="140" height="170" as="geometry"/>
</mxCell>
<mxCell id="29" value="-&amp;gt; Get Position Nemesis&lt;br&gt;-&amp;gt;Move_Toward Vector?&lt;br&gt;-&amp;gt; return distance between?" style="shape=card;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="430" y="920" width="140" height="150" as="geometry"/>
</mxCell>
<mxCell id="2" value="" style="rounded=0;whiteSpace=wrap;html=1;fontSize=15;fillColor=#eeeeee;strokeColor=#36393d;" parent="1" vertex="1">
<mxGeometry x="370" y="510" width="100" height="60" as="geometry"/>
</mxCell>
<mxCell id="3" value="&lt;font style=&quot;font-size: 15px&quot; color=&quot;#000000&quot;&gt;?&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;" parent="1" vertex="1">
<mxGeometry x="400" y="290" width="40" height="40" as="geometry"/>
</mxCell>
<mxCell id="4" value="&lt;span style=&quot;font-size: 15px&quot;&gt;Nemesis Visibile?&lt;/span&gt;" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="320" y="330" width="200" height="90" as="geometry"/>
</mxCell>
<mxCell id="5" value="Chaser (Wolf)" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#60a917;fontColor=#ffffff;strokeColor=#2D7600;" parent="1" vertex="1">
<mxGeometry x="500" y="200" width="140" height="60" as="geometry"/>
</mxCell>
<mxCell id="6" value="" style="shape=flexArrow;endArrow=classic;html=1;fillColor=#050505;gradientColor=#191919;strokeColor=#666666;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="390" y="539.7099999999999" as="sourcePoint"/>
<mxPoint x="450" y="539.7099999999999" as="targetPoint"/>
<Array as="points">
<mxPoint x="410" y="539.7099999999999"/>
<mxPoint x="420" y="539.7099999999999"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="7" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="13" target="8" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="400" y="810" as="sourcePoint"/>
<mxPoint x="540" y="597.9999999999998" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="8" value="Attack" style="ellipse;whiteSpace=wrap;html=1;fontSize=15;fillColor=#fa6800;strokeColor=#C73500;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="240" y="900" width="100" height="60" as="geometry"/>
</mxCell>
<mxCell id="9" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="5" target="3" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="420.0000000000002" y="410" as="sourcePoint"/>
<mxPoint x="420.0000000000002" y="440" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="10" value="&lt;span style=&quot;font-size: 15px&quot;&gt;Nemesis in Range?&lt;/span&gt;" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="320" y="620" width="200" height="90" as="geometry"/>
</mxCell>
<mxCell id="11" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="13" target="12" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="410" y="810" as="sourcePoint"/>
<mxPoint x="490" y="790" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="12" value="Chase" style="ellipse;whiteSpace=wrap;html=1;fontSize=15;fillColor=#fa6800;strokeColor=#C73500;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="480" y="900" width="100" height="60" as="geometry"/>
</mxCell>
<mxCell id="13" value="" style="rounded=0;whiteSpace=wrap;html=1;fontSize=15;fillColor=#eeeeee;strokeColor=#36393d;" parent="1" vertex="1">
<mxGeometry x="370" y="740" width="100" height="60" as="geometry"/>
</mxCell>
<mxCell id="14" value="" style="shape=flexArrow;endArrow=classic;html=1;fillColor=#050505;gradientColor=#191919;strokeColor=#666666;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="390" y="769.71" as="sourcePoint"/>
<mxPoint x="450" y="769.71" as="targetPoint"/>
<Array as="points">
<mxPoint x="410" y="769.71"/>
<mxPoint x="420" y="769.71"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="15" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="4" target="2" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="590" y="330" as="sourcePoint"/>
<mxPoint x="429.9999999999998" y="340" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="16" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="2" target="10" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="429.9999999999998" y="469.9999999999998" as="sourcePoint"/>
<mxPoint x="429.9999999999998" y="519.9999999999998" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="17" value="" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="10" target="13" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="429.9999999999998" y="579.9999999999998" as="sourcePoint"/>
<mxPoint x="429.9999999999998" y="629.9999999999998" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="19" value="" style="rounded=0;whiteSpace=wrap;html=1;labelBackgroundColor=#F5F5F5;fontSize=15;fontColor=#333333;fillColor=#f5f5f5;strokeColor=#666666;opacity=50;" parent="1" vertex="1">
<mxGeometry x="640" y="260" width="210" height="110" as="geometry"/>
</mxCell>
<mxCell id="20" value="Stray" style="rounded=0;whiteSpace=wrap;html=1;fontSize=15;" parent="1" vertex="1">
<mxGeometry x="680" y="280" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="21" value="Default" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;labelBackgroundColor=#F5F5F5;fontSize=15;fontColor=#000000;opacity=50;" parent="1" vertex="1">
<mxGeometry x="710" y="340" width="60" height="30" as="geometry"/>
</mxCell>
<mxCell id="22" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.867;exitY=-0.002;exitDx=0;exitDy=0;exitPerimeter=0;" parent="1" source="25" target="20" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="570" y="300" as="sourcePoint"/>
<mxPoint x="745" y="330" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="23" value="Confi&lt;br&gt;(Nemesis)" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="210" y="470" width="60" height="90" as="geometry"/>
</mxCell>
<mxCell id="24" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;fontSize=15;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="260" y="490" as="sourcePoint"/>
<mxPoint x="420" y="490" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="27" value="Confi&lt;br&gt;(Range)" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="210" y="700" width="60" height="90" as="geometry"/>
</mxCell>
<mxCell id="28" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;fontSize=15;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="260" y="720" as="sourcePoint"/>
<mxPoint x="420" y="720" as="targetPoint"/>
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>