Commit 97225e72 authored by Michal Jankowski's avatar Michal Jankowski
Browse files

Code style fixes according to Tomek's review.

parent 4e09c11a
......@@ -27,7 +27,7 @@ public class MCTSSolver {
private double minTemperature;
private double maxTemperature;
private int iterations;
private final static int nodeCountLimit = 2000000;
private final static int NODE_COUNT_LIMIT = 2000000;
private OneToManyChannel<Message, UtilityMessage> messageChannel;
private SolutionBuffer solutionBuffer = new SolutionBuffer();
private AvailablePolicies policyType;
......@@ -65,7 +65,7 @@ public class MCTSSolver {
private List<Thread> startWorkers(List<MCTSWrapper> mctsWrappers) {
return IntStream.range(0, numThreads).mapToObj(pid -> {
Thread thread = new Thread( () -> {
MCTSSingleTreeSolver mctsSingleTreeSolver = new MCTSSingleTreeSolver(minTemperature , 10, iterations, nodeCountLimit / numThreads, mctsWrappers.get(pid), policyType);
MCTSSingleTreeSolver mctsSingleTreeSolver = new MCTSSingleTreeSolver(minTemperature , 10, iterations, NODE_COUNT_LIMIT / numThreads, mctsWrappers.get(pid), policyType);
WorkerThread workerThread = new WorkerThread(pid, iterations, solutionBuffer, messageChannel, mctsSingleTreeSolver, SAVE_TREE);
workerThread.workerRun();
});
......
......@@ -12,8 +12,8 @@ import static java.util.Collections.max;
public class NodeImpl implements Node {
@Getter
private Node parent = null;
@Getter
private Node parent = null;
@Getter
private List<Node> children = new ArrayList<>();
@Getter
private int value;
......
......@@ -13,13 +13,7 @@ public class Queue {
}
NodeImpl toReturn = front;
this.front = front.getQueueLinker().getNext();
toReturn.getQueueLinker().removeFromQueue();
if (front == null) {
back = null;
}
removeNodeFromQueue(front);
return toReturn;
}
......@@ -31,18 +25,7 @@ public class Queue {
public void pushBack(Node newNode) {
NodeImpl node = (NodeImpl) newNode;
if (node.getQueueLinker().isInQueue()) { // If is in queue then remove it from queue for now.
NodeImpl previous = node.getQueueLinker().getPrevious();
NodeImpl next = node.getQueueLinker().getNext();
if (front == node) {
this.front = next;
}
if (back == node) {
this.back = previous;
}
node.getQueueLinker().removeFromQueue();
removeNodeFromQueue(node);
}
// Current node is not in queue.
......@@ -58,4 +41,19 @@ public class Queue {
public boolean empty() {
return front == null;
}
private void removeNodeFromQueue(NodeImpl node) {
NodeImpl previous = node.getQueueLinker().getPrevious();
NodeImpl next = node.getQueueLinker().getNext();
if (front == node) {
this.front = next;
}
if (back == node) {
this.back = previous;
}
node.getQueueLinker().removeFromQueue();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment