No one has PM'd me, which means no one is really interested in finding out the various mood paths.
But for those who are interested about what I made, here is the source code (in Java)
Code: Select all
public class moodNode {
static int[] attend = {0,-1,-2,1};
static int[] explore = {-1,0,0,-1};
static int[] tomb = {-1,-1,0,0};
static int[] walk = {0, 1, 0, -1};
static int[] sneak = {0,0,2,-1};
static int[] play = {0,1,-1,-1};
static int[] servAng = {-1,0,0,0};
static int[] servAfr = {1,0,0,0};
static int[] servChe = {0,-1,0,0};
static int[] servDep = {0,1,0,0};
static int[] dungWil = {1,0,1,0};
static int[] dungYie = {-1,0,-1,0};
static int[] huntAng = {-2,1,0,0};
static int[] huntAfr = {2, -1, 0, 0};
static int[] sports = {1, 0, 0, 0};
static int[] ball = {0, 0, 0, 1};
static int[] treasury = {0, 0, 1, 0};
static String desiredMood;
static int maxIter;
public moodNode(){
}
public moodNode(String des){
desiredMood = des;
}
//Recursive function
public void findPath(int[] curr, int[] addition, String pth, int iter){
int[] current = addArrays(curr, addition);
current = addArrays(current, addition); //Update the current mood values
int iteration = iter;
//Output the result if you found the desired mood
if (desiredMood.equalsIgnoreCase(getCurrentMood(current))){
System.out.println(iteration + " " + pth);
}
int servFlag = 0;
int dungFlag = 0;
int huntFlag = 0;
if (Math.abs(curr[0]) > Math.abs(curr[1])){
if (curr[0] > 0)
servFlag = 1; //Anger
else
servFlag = 2; //Afraid
}
else if (Math.abs(curr[0]) < Math.abs(curr[1])){
if (curr[1] > 0)
servFlag = 3; //Cheerful
else
servFlag = 4; //Depressed
}
if (curr[2] > 0)
dungFlag = 1; //Willful
else if (curr[2] < 0)
dungFlag = 2; //Yielding
if (curr[0] > 0)
huntFlag = 1;
else if (curr[0] < 0)
huntFlag = 2;
if (++iteration <= maxIter){
findPath(current, attend, pth + " + Attend Court", iteration);
findPath(current, explore, pth + " + Explore Castle", iteration);
findPath(current, tomb, pth + " + Visit Tomb", iteration);
findPath(current, walk, pth + " + Walk in Garden", iteration);
findPath(current, sneak, pth + " + Sneak out", iteration);
findPath(current, play, pth + " + Play with Toys", iteration);
switch (servFlag){
case 1:
findPath(current, servAng, pth + " + Attend service", iteration);
break;
case 2:
findPath(current, servAfr, pth + " + Attend service", iteration);
break;
case 3:
findPath(current, servChe, pth + " + Attend service", iteration);
break;
case 4:
findPath(current, servDep, pth + " + Attend service", iteration);
break;
}
switch (dungFlag){
case 1:
findPath(current, dungWil, pth + " + Visit Dungeons", iteration);
break;
case 2:
findPath(current, dungYie, pth + " + Visit Dungeons", iteration);
break;
}
switch (huntFlag){
case 1:
findPath(current, huntAng, pth + " + Hunting", iteration);
break;
case 2:
findPath(current, huntAfr, pth + " + Hunting", iteration);
break;
}
findPath(current, treasury, pth + " + Visit Treasury", iteration);
findPath(current, sports, pth + " + Sports", iteration);
findPath(current, ball, pth + " + Attend Ball", iteration);
}
}
public int[] addArrays(int[] first, int[] second){
if (first.length != second.length){
return null;
}
int[] temp = new int[first.length];
for (int i = 0; i < first.length; i++){
temp[i] = first[i] + second[i];
if (temp[i] > 5)
temp[i] = 5;
if (temp[i] < -5)
temp[i] = -5;
}
return temp;
}
public String getCurrentMood(int[] current){
int ele = 0;
int max = 0;
for (int i = 0; i < current.length; i++){
if (Math.abs(current[i]) > max){
ele = i;
max = Math.abs(current[i]);
}
}
if (max == 0)
return "Neutral";
switch (ele){
case 0:
if (current[ele] > 0)
return "Angry";
else
return "Afraid";
case 1:
if (current[ele] > 0)
return "Cheerful";
else
return "Depressed";
case 2:
if (current[ele] > 0)
return "Willful";
else
return "Yielding";
case 3:
if (current[ele] > 0)
return "Pressured";
else
return "Lonely";
}
return "Neutral";
}
}