Skip to content

Commit 99acaf3

Browse files
committed
Documentation improved.
1 parent 84b0baf commit 99acaf3

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

aima-gui/src/main/java/aima/gui/fx/applications/search/CspNQueensApp.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
import javafx.scene.layout.Pane;
2525
import javafx.scene.layout.StackPane;
2626

27-
2827
/**
29-
* Integrable application which demonstrates how different search strategies
30-
* solve the N-Queens problem.
28+
* Integrable application which demonstrates how different CSP solution
29+
* strategies solve the N-Queens problem.
3130
*
3231
* @author Ruediger Lunde
3332
*
@@ -43,7 +42,7 @@ public static void main(String[] args) {
4342
public final static String PARAM_DEG = "deg";
4443
public final static String PARAM_AC3 = "ac3";
4544
public final static String PARAM_LCV = "lcv";
46-
45+
4746
public final static String PARAM_BOARD_SIZE = "boardSize";
4847

4948
private NQueensViewCtrl stateViewCtrl;
@@ -54,7 +53,7 @@ public static void main(String[] args) {
5453

5554
@Override
5655
public String getTitle() {
57-
return "CSP N-Queens FX App";
56+
return "CSP N-Queens App";
5857
}
5958

6059
/**
@@ -82,8 +81,7 @@ public Pane createRootPane() {
8281
}
8382

8483
protected List<Parameter> createParameters() {
85-
Parameter p1 = new Parameter(PARAM_STRATEGY,
86-
"Min-Conflicts", "Backtracking");
84+
Parameter p1 = new Parameter(PARAM_STRATEGY, "Min-Conflicts", "Backtracking");
8785
Parameter p2 = new Parameter(PARAM_MRV, true, false);
8886
Parameter p3 = new Parameter(PARAM_DEG, true, false);
8987
Parameter p4 = new Parameter(PARAM_AC3, true, false);
@@ -109,7 +107,7 @@ else if (strategy.equals("Backtracking")) {
109107
boolean deg = (Boolean) simPaneCtrl.getParamValue(PARAM_DEG);
110108
boolean ac3 = (Boolean) simPaneCtrl.getParamValue(PARAM_AC3);
111109
boolean lcv = (Boolean) simPaneCtrl.getParamValue(PARAM_LCV);
112-
solver = new ImprovedBacktrackingStrategy(mrv, deg, ac3, lcv);
110+
solver = new ImprovedBacktrackingStrategy(mrv, deg, ac3, lcv);
113111
}
114112
solver.addCSPStateListener(progressAnalyzer);
115113
progressAnalyzer.reset();
@@ -131,7 +129,7 @@ public void simulate() {
131129
}
132130
simPaneCtrl.setStatus(progressAnalyzer.getResults().toString());
133131
}
134-
132+
135133
private NQueensBoard getBoard(Assignment assignment) {
136134
NQueensBoard board = new NQueensBoard(csp.getVariables().size());
137135
for (Variable var : assignment.getVariables()) {
@@ -150,22 +148,22 @@ private void updateStateView(NQueensBoard board) {
150148
Platform.runLater(() -> stateViewCtrl.update(board));
151149
simPaneCtrl.waitAfterStep();
152150
}
153-
151+
154152
protected class ProgressAnalyzer implements CSPStateListener {
155153
private int assignmentCount = 0;
156154
private int domainCount = 0;
157-
155+
158156
@Override
159157
public void stateChanged(Assignment assignment, CSP csp) {
160158
updateStateView(getBoard(assignment));
161159
++assignmentCount;
162160
}
163-
161+
164162
@Override
165163
public void stateChanged(CSP csp) {
166164
++domainCount;
167165
}
168-
166+
169167
public void reset() {
170168
assignmentCount = 0;
171169
domainCount = 0;
@@ -179,5 +177,4 @@ public Metrics getResults() {
179177
return result;
180178
}
181179
}
182-
183180
}

0 commit comments

Comments
 (0)