Skip to content

Commit 0e1c175

Browse files
committed
Implement/close features planned: ethos setsm skills, free actions, etc.
1 parent 4580fa0 commit 0e1c175

26 files changed

+628
-203
lines changed

.settings/org.eclipse.jdt.core.prefs

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
3+
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
4+
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
5+
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
6+
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
7+
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
8+
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
9+
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
10+
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
11+
org.eclipse.jdt.core.compiler.problem.APILeak=warning
12+
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
13+
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
14+
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
15+
org.eclipse.jdt.core.compiler.problem.deadCode=warning
16+
org.eclipse.jdt.core.compiler.problem.deprecation=warning
17+
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
18+
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
19+
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
20+
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
21+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
22+
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
23+
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
24+
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
25+
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
26+
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
27+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
28+
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
29+
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
30+
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
31+
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
32+
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
33+
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
34+
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
35+
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
36+
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
37+
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
38+
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
39+
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
40+
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
41+
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
42+
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=error
43+
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
44+
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
45+
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
46+
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
47+
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
48+
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
49+
org.eclipse.jdt.core.compiler.problem.nullReference=warning
50+
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
51+
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
52+
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
53+
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
54+
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
55+
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
56+
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
57+
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
58+
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
59+
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
60+
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
61+
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
62+
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
63+
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
64+
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
65+
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
66+
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
67+
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
68+
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
69+
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
70+
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
71+
org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
72+
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
73+
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
74+
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
75+
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
76+
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
77+
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
78+
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
79+
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
80+
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
81+
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
82+
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
83+
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
84+
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
85+
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
86+
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
87+
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
88+
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
89+
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
90+
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
91+
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
92+
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
93+
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
94+
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
95+
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
96+
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
97+
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
98+
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
99+
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
100+
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
101+
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error

src/io/github/dantetam/toolbox/ListUtil.java

+33
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,37 @@ public static <T> List<T> getShuffledList(List<T> list) {
2727
return data;
2828
}
2929

30+
public static <T> Collection<T> colnsIntersection(Collection<T>... collections) {
31+
if (collections == null || collections.length <= 1) {
32+
throw new IllegalArgumentException("Collection intersection not defined for empty/null amount of collections");
33+
}
34+
35+
Collection<T> minSizeColn = null;
36+
for (Collection<T> coln: collections) {
37+
if (minSizeColn == null || coln.size() < minSizeColn.size()) {
38+
minSizeColn = coln;
39+
}
40+
}
41+
42+
Collection<T> intersection = new ArrayList<>();
43+
for (T item: minSizeColn) {
44+
boolean itemFoundAll = true;
45+
for (Collection coln: collections) {
46+
if (coln.equals(minSizeColn)) continue;
47+
if (!minSizeColn.contains(item)) {
48+
itemFoundAll = false;
49+
break;
50+
}
51+
}
52+
if (itemFoundAll) {
53+
intersection.add(item);
54+
}
55+
}
56+
return intersection;
57+
}
58+
59+
public static <T> boolean colnsHasIntersect(Collection<T>... collections) {
60+
return colnsIntersection(collections).size() > 0;
61+
}
62+
3063
}

src/io/github/dantetam/world/civhumanai/Ethos.java

+6
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ public Ethos(String name, double severity, String modsString, String effectsStri
4949
this.ethosLifetimeHappiness = 0;
5050
}
5151

52+
/**
53+
* @return A value between low and high on the sigmoid graph, at value severity
54+
*/
5255
public double getLogisticVal(double low, double high) {
5356
return new Sigmoid(low, high).value(severity);
5457
}
58+
/**
59+
* @return A value between 0 and 1 on the sigmoid graph, such that returned value = sigmoid(severity)
60+
*/
5561
public double getNormLogisticVal() {
5662
return new Sigmoid().value(severity);
5763
}

src/io/github/dantetam/world/civhumanai/EthosSet.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public EthosSet() {
5959
ethosTowardsItems = new HashMap<>();
6060
}
6161

62-
public Collection<Ethos> getAllHumanEthos() {
62+
public Collection<Ethos> getAllEthos() {
6363
return ListUtil.getColns(
6464
this.greatEthos.values(),
6565
this.ethosPersonalityTraits.values(),
@@ -68,4 +68,13 @@ public Collection<Ethos> getAllHumanEthos() {
6868
);
6969
}
7070

71+
public Map<String, Ethos> getEthosMapping() {
72+
Collection<Ethos> allEthos = this.getAllEthos();
73+
Map<String, Ethos> ethosMap = new HashMap<>();
74+
for (Ethos ethos: allEthos) {
75+
ethosMap.put(ethos.name, ethos);
76+
}
77+
return ethosMap;
78+
}
79+
7180
}

src/io/github/dantetam/world/civhumanrelation/HumanHumanRel.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class HumanHumanRel extends HumanRelationship {
2424
public boolean isPersonalHostileOneWay; //Note, this is only for personal disputes and fights, not for wars between societies
2525
public HumanHumanRelType relationshipType;
2626

27-
TODO;
2827
public enum HumanHumanRelType {
2928
NEUTRAL, FAMILY, MARRIAGE, FRIEND
3029
//TODO: Initialize, implement, set to correct data field
@@ -44,7 +43,7 @@ public double reevaluateOpinion(Date date) {
4443
double opinionSum = 0;
4544

4645
//Personality traits effect on human relationships
47-
for (Ethos ethos: human.brain.ethosSet.getAllHumanEthos()) {
46+
for (Ethos ethos: human.brain.ethosSet.getAllEthos()) {
4847
if (ethos.name.equals("Kind")) {
4948
emotionGamut.addEmotion("Kindness", 20.0);
5049
emotionGamut.addEmotion("Honor", 10.0);
@@ -86,7 +85,7 @@ else if (attractGender == otherPersonGender) {
8685
}
8786
emotionGamut.addEmotion("Attraction", baseAttraction);
8887

89-
for (Ethos ethos: human.brain.ethosSet.getAllHumanEthos()) {
88+
for (Ethos ethos: human.brain.ethosSet.getAllEthos()) {
9089
if (ethos.name.equals("Greedy") || ethos.name.equals("Ambitious")) {
9190
double diffWealth = targetHuman.getTotalWealth() / human.getTotalWealth();
9291
if (diffWealth > 0.75) {

src/io/github/dantetam/world/civhumansocietyai/FreeActionsHumans.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import java.util.Date;
55
import java.util.List;
66
import java.util.Map;
7+
import java.util.Set;
78
import java.util.Map.Entry;
89
import java.util.HashMap;
910

11+
import io.github.dantetam.vector.Vector3i;
1012
import io.github.dantetam.world.civilization.Household;
1113
import io.github.dantetam.world.civilization.Society;
1214
import io.github.dantetam.world.grid.LocalGrid;
@@ -18,13 +20,13 @@ public class FreeActionsHumans {
1820
public static Map<String, FreeAction> freeActionsListHuman = new HashMap<String, FreeAction>() {{
1921
put("formNewHouseMarriage", new FreeAction("formNewHouseMarriage", null, 30));
2022
put("tryToHaveChild", new FreeAction("tryToHaveChild", null, 15));
23+
put("claimNewLand", new FreeAction("claimNewLand", null, 15));
2124
}};
2225

23-
TODO
2426
//Implement more human to human interactions, and for all interactions, take into account
2527
//the situation, the relationships, and relevant personality traits.
2628

27-
public static void considerAllFreeActionsHumans(WorldGrid world,
29+
public static void considerAllFreeActionsHumans(WorldGrid world, LocalGrid grid,
2830
List<Human> humans, Date date) {
2931
for (Entry<String, FreeAction> entry: freeActionsListHuman.entrySet()) {
3032
if (!entry.getValue().fireChanceExecute()) continue;
@@ -65,6 +67,10 @@ public static void considerAllFreeActionsHumans(WorldGrid world,
6567
}
6668
}
6769
}
70+
else if (name.equals("claimNewLand")) {
71+
Map<Human, Set<Vector3i>> humanClaimUtil = SocietalHumansActionsCalc
72+
.possibleNewLandClaims(grid, humans);
73+
}
6874
}
6975
}
7076

src/io/github/dantetam/world/civhumansocietyai/FreeActionsSociety.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public class FreeActionsSociety {
2020

21-
TODO
21+
//TODO
2222
//Use leadership, ethos of society, and ethos of people factoring into decisions
2323

2424
public static Map<String, FreeAction> freeActionsInterSociety = new HashMap<String, FreeAction>() {{

src/io/github/dantetam/world/civhumansocietyai/SocietalActionsCalc.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
public class SocietalActionsCalc {
1010

1111
//See EmergentSocietyCalc.java
12-
TODO //Use societal/human ethos in calc. Add more unique actions with consequences.
12+
//TODO //Use societal/human ethos in calc. Add more unique actions with consequences.
1313

1414
}

src/io/github/dantetam/world/civhumansocietyai/SocietalHumansActionsCalc.java

+28-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.util.Set;
1010

1111
import io.github.dantetam.toolbox.MapUtil;
12+
import io.github.dantetam.vector.Vector3i;
13+
import io.github.dantetam.world.civhumanai.Ethos;
1214
import io.github.dantetam.world.civhumanrelation.HumanHumanRel;
1315
import io.github.dantetam.world.civilization.Household;
1416
import io.github.dantetam.world.civilization.Society;
@@ -17,6 +19,7 @@
1719
import io.github.dantetam.world.life.Human;
1820
import io.github.dantetam.world.process.LocalJob;
1921
import io.github.dantetam.world.process.LocalProcess;
22+
import io.github.dantetam.world.process.priority.SoldierPriority;
2023

2124
/**
2225
*
@@ -90,8 +93,13 @@ public static List<Human[]> possibleMarriagePairs(List<Human> humans, Date date)
9093
return pairs;
9194
}
9295

93-
public static Map<Human, GridRectInterval> possibleNewLandClaims(LocalGrid grid, List<Human> humans) {
94-
TODO
96+
//Figure out a system for people claiming land in a world
97+
//More powerful people get first choice? Followed by those who desparately want land and have the power
98+
//to obtain/maintain land
99+
public static Map<Human, Set<Vector3i>> possibleNewLandClaims(LocalGrid grid, List<Human> humans) {
100+
Map<Human, Set<Vector3i>> humanClaimUtil = new HashMap<>();
101+
//TODO;
102+
return humanClaimUtil;
95103
}
96104

97105
/**
@@ -100,8 +108,24 @@ public static Map<Human, GridRectInterval> possibleNewLandClaims(LocalGrid grid,
100108
* @param humans Humans in question from the host society
101109
* @return The possible raid party (groups of humans) for use in free actions
102110
*/
103-
public static List<Human[]> possibleRaidingParties(Society host, List<Human> humans) {
104-
TODO
111+
public static Map<Human, Double> possibleRaidingPartyUtil(Society host, List<Human> humans) {
112+
Map<Human, Double> fightMilitaryUtil = new HashMap<>();
113+
for (Human human: humans) {
114+
double util = 0;
115+
116+
double baseEquipScore = human.body.getNumMainBodyParts() * 2;
117+
double weaponReq = SoldierPriority.weaponAmtRequired(human);
118+
double armorReq = SoldierPriority.armorAmtRequired(human);
119+
util += (baseEquipScore - weaponReq - armorReq) / baseEquipScore;
120+
121+
double ethosScore = 0;
122+
Ethos warEthos = human.brain.ethosSet.getEthosMapping().get("Belligerent");
123+
ethosScore += warEthos.getNormLogisticVal();
124+
util += ethosScore;
125+
126+
fightMilitaryUtil.put(human, util);
127+
}
128+
return fightMilitaryUtil;
105129
}
106130

107131
/**

src/io/github/dantetam/world/civilization/SkillBook.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
public class SkillBook {
77

8-
private static final int MAX_LEVEL = 30;
8+
public static final int MAX_LEVEL = 30;
99
private static int[] experienceNeeded = new int[MAX_LEVEL+2];
1010
public static String[] allSkills = {"build", "cook", "cloth", "craft", "farm",
1111
"fight", "process", "smelt", "stone", "woodcut"};
1212

1313
private Map<String, Skill> skillMapping;
1414

15-
TODO //Use skill in implementing process efficiency/competency/quality,
15+
//Use skill in implementing process efficiency/competency/quality,
1616
//i.e. ability to do so, quality, time, wasted resources, etc.
1717

1818
public static void init() {
@@ -50,6 +50,12 @@ public void addExperienceToSkill(String skillName, int experience) {
5050
}
5151
}
5252

53+
public void setSkillLevel(String skillName, int level) {
54+
Skill skill = skillMapping.get(skillName);
55+
skill.level = level;
56+
skill.allExp = experienceNeeded[level + 1];
57+
}
58+
5359
private static class Skill {
5460
public String name;
5561
public int level, allExp;

0 commit comments

Comments
 (0)