-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlanner.java
More file actions
67 lines (51 loc) · 1.68 KB
/
Copy pathPlanner.java
File metadata and controls
67 lines (51 loc) · 1.68 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
package planners;
import actions.Action;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Random;
import storygenerator.World;
/**
*
* @author etienne
*/
public abstract class Planner {
protected Random rand = new Random();//8 for the power point /report example
//maximum number of actions in a sequence
protected final static int MAX_LENGTH = 1000;
//Action sequence that should lead to making the two lista above empty
protected LinkedList<Action> aActionSequence;
protected World aWorld;
protected Planner(World pWorld) {
aWorld = pWorld;
}
/**
* Prints the current action sequence to the console.
*/
public void printSequence() {
for (Action a : aActionSequence) {
System.out.println(a.toString());
}
System.out.println();
}
public abstract void executePlan();
public abstract boolean makePlan();
public int getSequenceLength() {
return aActionSequence.size();
}
/**
* Computes n/l, where n is the number of differently named actions
* (such as pickUp, travelTo, etc.) and l is the total number of actions
* in the sequence. The higher the ratio, the less repetition there is.
* @return
*/
public double getUniquenessScore() {
ArrayList<String> kinds = new ArrayList<String>();
for (Action a : aActionSequence) {
String name = a.getClass().getName();
if (!kinds.contains(name)) {
kinds.add(name);
}
}
return (double) kinds.size() / (double) aActionSequence.size();
}
}