Skip to content

Commit 1a4afc5

Browse files
committed
Logic bugfix for advantaged child computation in knowledge and format
1 parent b810593 commit 1a4afc5

File tree

8 files changed

+128
-84
lines changed

8 files changed

+128
-84
lines changed

src/de/zabuza/treeflood/demo/gui/controller/LocalStorageExplorationGUIController.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ private static EStep getStepTypeByStep(final int step) {
7272

7373
}
7474

75+
/**
76+
* Sets the given edge to visited. Used for painting related logic.
77+
*
78+
* @param edgeToPaint
79+
* The edge which should be set to visited.
80+
*/
81+
private static void setEdgeVisited(final Edge edgeToPaint) {
82+
// Happens when robots try to walk edges backwards, since there is no
83+
// destination -> source mapping for the edges. Handling needs to be
84+
// implemented for animations.
85+
if (edgeToPaint == null) {
86+
return;
87+
}
88+
edgeToPaint.setVisited();
89+
}
90+
7591
/**
7692
* The current {@link LocalStorageExploration} in progress.
7793
*/
@@ -495,22 +511,6 @@ private void resetData(final RandomTreeGenerator generator) {
495511
this.mIsFinished = false;
496512
}
497513

498-
/**
499-
* Sets the given edge to visited. Used for painting related logic.
500-
*
501-
* @param edgeToPaint
502-
* The edge which should be set to visited.
503-
*/
504-
private static void setEdgeVisited(final Edge edgeToPaint) {
505-
// Happens when robots try to walk edges backwards, since there is no
506-
// destination -> source mapping for the edges. Handling needs to be
507-
// implemented for animations.
508-
if (edgeToPaint == null) {
509-
return;
510-
}
511-
edgeToPaint.setVisited();
512-
}
513-
514514
/**
515515
* Starts the algorithm. Should only be called if the algorithm is not
516516
* running, otherwise this method may not work as expected.
@@ -548,12 +548,12 @@ private void startAlgorithm() {
548548
private synchronized void updateKnowledge() {
549549
for (final ITreeNode node : this.mTree.getNodes()) {
550550
final NestedMap2<Integer, Integer, Information> map = this.mNodeStorageManager.read(node);
551-
551+
552552
for (int stepsToCount = 0; stepsToCount <= this.mStep; stepsToCount++) {
553553
for (int i = 0; i < this.mAlgorithm.getRobots().size(); i++) {
554554
final Information currentNodeInformation = map.get(Integer.valueOf(stepsToCount),
555555
Integer.valueOf(i));
556-
556+
557557
if (currentNodeInformation != null) {
558558
if (this.mNodeInformationMapping.get(node) == null) {
559559
this.mNodeInformationMapping.put(node, new ArrayList<>());

src/de/zabuza/treeflood/demo/gui/model/DrawableNodeData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ public void hideTooltip() {
325325
}
326326

327327
/**
328-
* Gets a boolean that signalizes whether the tooltip should be rendered or not.
328+
* Gets a boolean that signalizes whether the tooltip should be rendered or
329+
* not.
329330
*
330331
* @return The boolean mentioned.
331332
*/

src/de/zabuza/treeflood/demo/gui/model/Edge.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public int getDescriptionX() {
8585
valueToAdd += (int) (5 * this.getSlope());
8686
}
8787
}
88-
88+
8989
return valueToAdd + (Math.abs(this.getStartX() - this.getEndX()) / 2);
9090
}
9191

@@ -129,8 +129,8 @@ public int getEndY() {
129129
}
130130

131131
/**
132-
* Gets the slope of this edge. Returns {@link Double#MAX_VALUE} if the slope
133-
* is infinite.
132+
* Gets the slope of this edge. Returns {@link Double#MAX_VALUE} if the
133+
* slope is infinite.
134134
*
135135
* @return The slope of this edge.
136136
*/
@@ -145,7 +145,7 @@ public double getSlope() {
145145
if (x_1 - x_2 == 0) {
146146
return Double.MAX_VALUE;
147147
}
148-
148+
149149
return (float) (y_2 - y_1) / (float) (x_2 - x_1);
150150
}
151151

src/de/zabuza/treeflood/demo/gui/model/InformationPanel.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public int getX() {
112112
if (this.mX + this.mWidth > this.mWindow.getTreePanelSize().width) {
113113
this.mX = this.mX - this.mWidth - this.mNodeData.getRadius() * 2;
114114
}
115-
115+
116116
return this.mX;
117117
}
118118

@@ -127,7 +127,7 @@ public int getY() {
127127
if (this.mY < 0) {
128128
this.mY = 0;
129129
}
130-
130+
131131
return this.mY;
132132
}
133133

@@ -177,9 +177,9 @@ private void adjustWidth() {
177177
}
178178

179179
if (line.wasEnteredFromParent()) {
180-
informationString += line.getStep() + ", [" + line.getRobotId() + "], " + line.getPort();
180+
informationString += line.getStep() + ", [" + line.getRobotId() + "], \u2193 " + line.getPort();
181181
} else {
182-
informationString += line.getStep() + ", [" + line.getRobotId() + "], " + line.getPort();
182+
informationString += line.getStep() + ", [" + line.getRobotId() + "], \u2191 " + line.getPort();
183183
}
184184

185185
if (informationString.length() > mostChars) {
@@ -189,10 +189,10 @@ private void adjustWidth() {
189189
if (this.mInformationsAsString.contains(informationString)) {
190190
continue;
191191
}
192-
192+
193193
this.mInformationsAsString.add(informationString);
194194
}
195-
195+
196196
this.mWidth = mostChars * 8 + 5;
197197
}
198198
}

src/de/zabuza/treeflood/demo/gui/view/MainFrame.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public int getTreeSize() {
184184

185185
/*
186186
* (non-Javadoc)
187+
*
187188
* @see java.awt.Component#repaint()
188189
*/
189190
@Override

src/de/zabuza/treeflood/demo/gui/view/util/StyleManager.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public Color getButtonColor() {
193193
} else if (this.mCurrentStyle == EStyle.DARK) {
194194
return StyleManager.BUTTON_COLOR_DARK;
195195
}
196-
196+
197197
// Couldn't find a color for the given style.
198198
throw new AssertionError();
199199
}
@@ -209,7 +209,7 @@ public Color getDefaultFontColor() {
209209
} else if (this.mCurrentStyle == EStyle.DARK) {
210210
return StyleManager.DEFAULT_FONT_COLOR_DARK;
211211
}
212-
212+
213213
// Couldn't find a color for the given style.
214214
throw new AssertionError();
215215
}
@@ -225,7 +225,7 @@ public Color getFringeColor() {
225225
} else if (this.mCurrentStyle == EStyle.DARK) {
226226
return StyleManager.FRINGE_COLOR_DARK;
227227
}
228-
228+
229229
// Couldn't find a color for the given style.
230230
throw new AssertionError();
231231
}
@@ -241,7 +241,7 @@ public Color getOptionPanelColor() {
241241
} else if (this.mCurrentStyle == EStyle.DARK) {
242242
return StyleManager.OPTIONPANEL_COLOR_DARK;
243243
}
244-
244+
245245
// Couldn't find a color for the given style.
246246
throw new AssertionError();
247247
}
@@ -257,7 +257,7 @@ public Color getSeparatorColor() {
257257
} else if (this.mCurrentStyle == EStyle.DARK) {
258258
return StyleManager.SEPARATOR_COLOR_DARK;
259259
}
260-
260+
261261
// Couldn't find a color for the given style.
262262
throw new AssertionError();
263263
}
@@ -273,7 +273,7 @@ public Color getSliderColor() {
273273
} else if (this.mCurrentStyle == EStyle.DARK) {
274274
return StyleManager.SLIDER_COLOR_DARK;
275275
}
276-
276+
277277
// Couldn't find a color for the given style.
278278
throw new AssertionError();
279279
}
@@ -289,7 +289,7 @@ public Color getTextAreaColor() {
289289
} else if (this.mCurrentStyle == EStyle.DARK) {
290290
return StyleManager.TEXT_AREA_COLOR_DARK;
291291
}
292-
292+
293293
// Couldn't find a color for the given style.
294294
throw new AssertionError();
295295
}
@@ -305,7 +305,7 @@ public Color getTextPaneColor() {
305305
} else if (this.mCurrentStyle == EStyle.DARK) {
306306
return StyleManager.TEXT_PANE_COLOR_DARK;
307307
}
308-
308+
309309
// Couldn't find a color for the given style.
310310
throw new AssertionError();
311311
}
@@ -321,7 +321,7 @@ public Color getToolTipFillColor() {
321321
} else if (this.mCurrentStyle == EStyle.DARK) {
322322
return StyleManager.TOOLTIP_FILL_COLOR_DARK;
323323
}
324-
324+
325325
// Couldn't find a color for the given style.
326326
throw new AssertionError();
327327
}
@@ -337,7 +337,7 @@ public Color getTreepanelColor() {
337337
} else if (this.mCurrentStyle == EStyle.DARK) {
338338
return StyleManager.TREEPANEL_COLOR_DARK;
339339
}
340-
340+
341341
// Couldn't find a color for the given style.
342342
throw new AssertionError();
343343
}
@@ -353,7 +353,7 @@ public Color getUnvisitedEdgeColor() {
353353
} else if (this.mCurrentStyle == EStyle.DARK) {
354354
return StyleManager.UNVISITED_EDGE_COLOR_DARK;
355355
}
356-
356+
357357
// Couldn't find a color for the given style.
358358
throw new AssertionError();
359359
}
@@ -369,7 +369,7 @@ public Color getUnvisitedNodeColor() {
369369
} else if (this.mCurrentStyle == EStyle.DARK) {
370370
return StyleManager.UNVISITED_NODE_COLOR_DARK;
371371
}
372-
372+
373373
// Couldn't find a color for the given style.
374374
throw new AssertionError();
375375
}
@@ -385,7 +385,7 @@ public Color getVisitedEdgeColor() {
385385
} else if (this.mCurrentStyle == EStyle.DARK) {
386386
return StyleManager.VISITED_EDGE_COLOR_DARK;
387387
}
388-
388+
389389
// Couldn't find a color for the given style.
390390
throw new AssertionError();
391391
}
@@ -401,7 +401,7 @@ public Color getVisitedNodeColor() {
401401
} else if (this.mCurrentStyle == EStyle.DARK) {
402402
return StyleManager.VISITED_NODE_COLOR_DARK;
403403
}
404-
404+
405405
// Couldn't find a color for the given style.
406406
throw new AssertionError();
407407
}

0 commit comments

Comments
 (0)