-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
182 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package lib.gecom.stuff; | ||
|
||
import lombok.*; | ||
|
||
import java.util.HashMap; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class GeGoal implements Comparable<GeGoal> { | ||
|
||
@NonNull | ||
@Builder.Default | ||
private final HashMap<String, Integer> statesToReach = new HashMap<>(); | ||
|
||
@Setter | ||
@Builder.Default | ||
public boolean intendedToRemoveAfterSatisfaction = true; | ||
|
||
@Setter | ||
@NonNull | ||
@Builder.Default | ||
private Integer priority = 0; | ||
|
||
|
||
@Override | ||
public int compareTo(@NonNull final GeGoal other) { | ||
final Integer mine = this.priority; | ||
final Integer theirs = other.priority; | ||
|
||
return mine.compareTo(theirs); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package lib.gecom; | ||
|
||
import lib.gecom.action.GeAction; | ||
import lombok.NonNull; | ||
|
||
public class TestAction extends GeAction { | ||
|
||
public TestAction(@NonNull final String name) { | ||
super(name); | ||
} | ||
|
||
public TestAction(@NonNull final String name, @NonNull final Float cost) { | ||
super(name, cost); | ||
} | ||
|
||
@Override | ||
public boolean prePerform() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean postPerform() { | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package lib.gecom.agent; | ||
|
||
import lib.gecom.TestAction; | ||
import lib.gecom.action.GeAction; | ||
import lib.gecom.plan.GePlanner; | ||
import lib.gecom.stuff.GeGoal; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class GeAgentTest { | ||
|
||
@Test | ||
public void test() { | ||
// Arrange | ||
final TestAction eat = new TestAction("eat"); | ||
eat.getPreconditions().put("hungry", 1); | ||
eat.getEffects().put("hungry", 0); | ||
|
||
final List<GeAction> listOfPossibleActions = List.of(eat); | ||
|
||
final GeGoal getFull = GeGoal.builder().build(); | ||
getFull.getStatesToReach().put("hungry", 0); | ||
|
||
final GePlanner gePlanner = new GePlanner(); | ||
|
||
final GeAgent agentToTest = new GeAgent(gePlanner); | ||
agentToTest.getPossibleActions().add(eat); | ||
agentToTest.getAgentsBelieves().put("hungry", 1); | ||
agentToTest.getGoals().add(getFull); | ||
|
||
// Act | ||
agentToTest.start(); | ||
agentToTest.update(); | ||
|
||
// Assert | ||
assertEquals(1, agentToTest.getAgentsBelieves().get("hungry")); | ||
} | ||
|
||
} |
Oops, something went wrong.