Skip to content

Commit bd9708b

Browse files
committed
Documentation improved.
1 parent f4ac4a1 commit bd9708b

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

aima-gui/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
by Ruediger Lunde ([email protected])
44

5-
This project contains graphical applications and command line demos, which
6-
demonstrate the use of some of the aima-core project features. Currently, it
7-
focuses on search algorithms and agent concepts. Application class names end
8-
with "App" and command line demo class names end with "Demo".
5+
![WumpusAgentApp Demo Application](https://github.com/aimacode/aima-java/blob/AIMA3e/aima-gui/src/main/uml/WumpusDemoApp.png)
6+
7+
This project contains graphical applications and command line demos. The command line demos show
8+
how to use selected parts of the aima-core API. The applications support interactive experiments with
9+
some of the core algorithms, especially from the search and logic area.
10+
11+
Application class names end with "App" and command line demo class names end with "Demo".
912
Simple demo command line applications can be found in package `aima.gui.demo`.
1013
Graphical demo applications are available based on JavaFX (package `aima.gui.fx.applications`) and
1114
Swing (package `aima.gui.swing.applications`). Each platform-specific root package contains an

aima-gui/src/main/java/aima/gui/fx/views/VacuumEnvironmentViewCtrl.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import aima.core.environment.vacuum.VacuumEnvironment;
88
import aima.core.environment.vacuum.VacuumEnvironment.LocationState;
99
import aima.core.environment.vacuum.VacuumEnvironmentState;
10-
import aima.core.environment.wumpusworld.Room;
11-
import aima.core.environment.wumpusworld.WumpusCave;
12-
import aima.core.environment.wumpusworld.WumpusEnvironment;
1310
import javafx.scene.Node;
1411
import javafx.scene.layout.StackPane;
1512
import javafx.scene.paint.Color;
@@ -71,7 +68,7 @@ protected void update() {
7168
Integer orientation = agentOrientations.get(agent);
7269
if (orientation == null)
7370
orientation = 0;
74-
btn.getPane().getChildren().add(createAgentRep(agentsInSuckState.contains(agent), orientation));
71+
btn.getPane().getChildren().add(createAgentSymbol(agentsInSuckState.contains(agent), orientation));
7572
}
7673
}
7774

@@ -91,7 +88,7 @@ protected void onEdit(int x, int y) {
9188

9289

9390

94-
protected Node createAgentRep(boolean suck, int orientation) {
91+
protected Node createAgentSymbol(boolean suck, int orientation) {
9592
Arc arc = new Arc();
9693
arc.radiusXProperty().bind(squareSize.multiply(0.3));
9794
arc.radiusYProperty().bind(squareSize.multiply(0.3));

aima-gui/src/main/java/aima/gui/fx/views/WumpusEnvironmentViewCtrl.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import aima.core.environment.wumpusworld.Room;
77
import aima.core.environment.wumpusworld.WumpusCave;
88
import aima.core.environment.wumpusworld.WumpusEnvironment;
9+
import javafx.scene.Node;
910
import javafx.scene.layout.Pane;
1011
import javafx.scene.layout.StackPane;
1112
import javafx.scene.paint.Color;
@@ -57,12 +58,12 @@ protected void update() {
5758
}
5859
}
5960

60-
// visualize agent position
61-
List<Agent> agents = env.getAgents();
62-
if (!agents.isEmpty()) {
63-
AgentPosition pos = wEnv.getAgentPosition(agents.get(0));
61+
// visualize agent positions
62+
for (Agent agent : wEnv.getAgents()) {
63+
AgentPosition pos = wEnv.getAgentPosition(agent);
6464
Pane pane = getSquareButton(pos.getX(), pos.getY()).getPane();
65-
addAgentMarker(pane, agents.get(0).isAlive() ? Color.RED : Color.LIGHTGRAY, pos.getOrientation());
65+
pane.getChildren().add(createAgentSymbol(pane, agent.isAlive() ? Color.RED : Color.LIGHTGRAY,
66+
pos.getOrientation()));
6667
}
6768
}
6869

@@ -74,33 +75,32 @@ protected void onEdit(int x, int y) {
7475
actionLabel.setText("Cave can only be edited after initialization.");
7576
else if (!room.equals(cave.getStart().getRoom()) && !room.equals(cave.getGold())) {
7677
if (cave.isPit(room)) {
77-
if (cave.getWumpus().equals(room)) {
78+
if (cave.getWumpus().equals(room))
7879
cave.setPit(room, false);
79-
} else {
80+
else
8081
cave.setWumpus(room);
81-
}
8282
} else {
8383
cave.setPit(room, true);
8484
}
8585
update();
8686
}
8787
}
8888

89-
private void addAgentMarker(Pane pane, Color color, AgentPosition.Orientation orientation) {
89+
private Node createAgentSymbol(Pane pane, Color color, AgentPosition.Orientation orientation) {
9090
int size = squareSize.get() / 2;
91-
Polygon marker = new Polygon(-size / 3, size, size / 3, size, 0, 0);
92-
marker.setFill(color);
91+
Polygon result = new Polygon(-size / 3, size, size / 3, size, 0, 0);
92+
result.setFill(color);
9393
switch (orientation) {
9494
case FACING_EAST:
95-
marker.setRotate(90);
95+
result.setRotate(90);
9696
break;
9797
case FACING_SOUTH:
98-
marker.setRotate(180);
98+
result.setRotate(180);
9999
break;
100100
case FACING_WEST:
101-
marker.setRotate(270);
101+
result.setRotate(270);
102102
break;
103103
}
104-
pane.getChildren().add(marker);
104+
return result;
105105
}
106106
}

0 commit comments

Comments
 (0)