-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTORM.java
More file actions
76 lines (60 loc) · 1.98 KB
/
Copy pathSTORM.java
File metadata and controls
76 lines (60 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package storygenerator;
import planners.Planner;
import planners.RandomPlanner;
import planners.ForwardPlanner;
import planners.BackwardPlanner;
import java.util.Random;
import planners.CompetitivePlanner;
/**
*
* @author etienne
*/
public class STORM {
static Random rand = new Random();
public static void main(String[] args) {
World w = new World();
Planner p;
if (args[0].equals("RANDOM")) {
p = new RandomPlanner(w);
}
else if (args[0].equals("BACKWARD")) {
p = new BackwardPlanner(w);
}
else if (args[0].equals("FORWARD")) {
p = new ForwardPlanner(w);
}
else if (args[0].equals("COMPETITIVE")) {
p = new CompetitivePlanner(w);
}
else {
System.out.println("Need to specify planner type "
+ "(RANDOM, BACKWARD, FORWARD or COMPETITIVE) "
+ "as the first argument");
System.exit(0);
p = new RandomPlanner(w);
}
w.printCharacters();
w.printItems();
w.printCreatures();
w.printLocations();
w.printWorldState();
w.printGoals();
generateStory(w, p);
}
public static void generateStory(World w, Planner p) {
boolean success = p.makePlan();
if (success) {
w.introduction();
p.executePlan();
w.conclusion();
System.out.println();
System.out.println("Success of the main character: " + w.checkGoalCompletion());
System.out.println("Success of the villain: " + w.checkAntiGoalCompletion());
System.out.println("Length of story: " + p.getSequenceLength());
System.out.println("Uniqueness score: " + p.getUniquenessScore());
}
else {
System.out.println("Failure to find a plan.");
}
}
}