Skip to content

Commit ef40944

Browse files
committed
formatting source
1 parent 694eed6 commit ef40944

9 files changed

+41
-75
lines changed

core/src/test/scala/aima/core/environment/vacuum/ModelBasedReflexVacuumAgentSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ModelBasedReflexVacuumAgentSpec extends Specification {
4242
case LeftMoveAction => ok
4343
}
4444
}
45-
45+
4646
"should assume dirty after moving to location A" in new context {
4747
agent.agentFunction.apply(LocationBPercept)
4848
agent.agentFunction.apply(CleanPercept)

core/src/test/scala/aima/core/environment/vacuum/ReflexVacuumAgentProgramSpec.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@ class ReflexVacuumAgentProgramSpec extends Specification with ScalaCheck {
1616

1717
"should eventually clean environment" in prop { env: VacuumEnvironment =>
1818
val agentProgram = new AgentProgram {
19-
lazy val agent = new SimpleReflexVacuumAgent
19+
lazy val agent = new SimpleReflexVacuumAgent
2020
lazy val actuators = Seq[Actuator](new SuckerActuator(agent), new MoveActuator(agent))
21-
lazy val sensors = Seq[Sensor](new DirtSensor(agent), new AgentLocationSensor(agent))
21+
lazy val sensors = Seq[Sensor](new DirtSensor(agent), new AgentLocationSensor(agent))
2222
}
2323

2424
@tailrec def eventuallyClean(currentEnv: Environment): Boolean = {
2525
currentEnv match {
2626
case ve: VacuumEnvironment if ve.isClean() => true
27-
case _ => eventuallyClean(agentProgram.run(currentEnv))
27+
case _ => eventuallyClean(agentProgram.run(currentEnv))
2828
}
2929
}
3030

3131
eventuallyClean(env.addAgent(agentProgram.agent)) must beTrue
3232
}
3333

34-
3534
}

core/src/test/scala/aima/core/environment/vacuum/TableDrivenVacuumAgentSpec.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,44 @@ class TableDrivenVacuumAgentSpec extends Specification {
2323
invokeAgent(List(LocationBPercept, CleanPercept)) must_== List(NoAction, LeftMoveAction)
2424
}
2525

26-
2726
"second level dirty sucks" in new context {
28-
val givenPercepts = List.fill(2)(NoPercept) ++ List(NoPercept, DirtyPercept)
27+
val givenPercepts = List.fill(2)(NoPercept) ++ List(NoPercept, DirtyPercept)
2928
val expectedActions = List.fill(2)(NoAction) ++ List(NoAction, Suck)
3029
invokeAgent(givenPercepts) must_== expectedActions
3130
}
3231

3332
"second level A and Clean moves Right" in new context {
34-
val givenPercepts = List.fill(2)(NoPercept) ++ List(LocationAPercept, CleanPercept)
33+
val givenPercepts = List.fill(2)(NoPercept) ++ List(LocationAPercept, CleanPercept)
3534
val expectedActions = List.fill(2)(NoAction) ++ List(NoAction, RightMoveAction)
3635
invokeAgent(givenPercepts) must_== expectedActions
3736
}
3837

3938
"second level B and Clean moves Right" in new context {
40-
val givenPercepts = List.fill(2)(NoPercept) ++ List(LocationBPercept, CleanPercept)
39+
val givenPercepts = List.fill(2)(NoPercept) ++ List(LocationBPercept, CleanPercept)
4140
val expectedActions = List.fill(2)(NoAction) ++ List(NoAction, LeftMoveAction)
4241
invokeAgent(givenPercepts) must_== expectedActions
4342
}
4443

4544
"fourth level dirty sucks" in new context {
46-
val givenPercepts = List.fill(6)(NoPercept) ++ List(NoPercept, DirtyPercept)
45+
val givenPercepts = List.fill(6)(NoPercept) ++ List(NoPercept, DirtyPercept)
4746
val expectedActions = List.fill(6)(NoAction) ++ List(NoAction, Suck)
4847
invokeAgent(givenPercepts) must_== expectedActions
4948
}
5049

5150
"fourth level A and Clean moves Right" in new context {
52-
val givenPercepts = List.fill(6)(NoPercept) ++ List(LocationAPercept, CleanPercept)
51+
val givenPercepts = List.fill(6)(NoPercept) ++ List(LocationAPercept, CleanPercept)
5352
val expectedActions = List.fill(6)(NoAction) ++ List(NoAction, RightMoveAction)
5453
invokeAgent(givenPercepts) must_== expectedActions
5554
}
5655

5756
"fourth level B and Clean moves Right" in new context {
58-
val givenPercepts = List.fill(6)(NoPercept) ++ List(LocationBPercept, CleanPercept)
57+
val givenPercepts = List.fill(6)(NoPercept) ++ List(LocationBPercept, CleanPercept)
5958
val expectedActions = List.fill(6)(NoAction) ++ List(NoAction, LeftMoveAction)
6059
invokeAgent(givenPercepts) must_== expectedActions
6160
}
6261

6362
"twenty dirty percepts is undefined because out of table definition range" in new context {
64-
val givenPercepts = List.fill(20)(NoPercept)
63+
val givenPercepts = List.fill(20)(NoPercept)
6564
val expectedActions = List.fill(20)(NoAction)
6665
invokeAgent(givenPercepts) must_== expectedActions
6766
}
@@ -70,9 +69,9 @@ class TableDrivenVacuumAgentSpec extends Specification {
7069
val rnd = new Random()
7170
val randomPerceptStream: Stream[Percept] = Stream.continually {
7271
val selector = rnd.nextInt(3)
73-
if(selector == 0)
72+
if (selector == 0)
7473
LocationPercept.randomValue
75-
else if(selector == 1)
74+
else if (selector == 1)
7675
DirtPercept.randomValue
7776
else
7877
NoPercept

core/src/test/scala/aima/core/environment/vacuum/VacuumMapSpec.scala

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,96 +49,79 @@ class VacuumMapSpec extends Specification with ScalaCheck {
4949

5050
"dirt status of agent must be dirty if all dirty" in {
5151
val agent = noopAgent
52-
val map = VacuumMap(Vector(dirtyNode, dirtyNode)).addAgent(agent)
52+
val map = VacuumMap(Vector(dirtyNode, dirtyNode)).addAgent(agent)
5353

5454
map.getDirtStatus(agent) must beSome(DirtyPercept)
5555
}
5656

5757
"dirt status of agent must be clean if all clean" in {
5858
val agent = noopAgent
59-
val map = VacuumMap(Vector(cleanNode, cleanNode)).addAgent(agent)
59+
val map = VacuumMap(Vector(cleanNode, cleanNode)).addAgent(agent)
6060

6161
map.getDirtStatus(agent) must beSome(CleanPercept)
6262
}
6363

64-
6564
"agent location of agent not on map must be none" in prop { map: VacuumMap =>
6665
val agent = noopAgent
6766
map.getAgentLocation(agent) must beNone
6867
}
6968

7069
"agent location must be A if in first spot" in {
7170
val agent = noopAgent
72-
val map = VacuumMap(Vector(agentNode(agent), cleanNode)).addAgent(agent)
71+
val map = VacuumMap(Vector(agentNode(agent), cleanNode)).addAgent(agent)
7372

7473
map.getAgentLocation(agent) must beSome(LocationAPercept)
7574
}
7675

7776
"agent location must be B if in second spot" in {
7877
val agent = noopAgent
79-
val map = VacuumMap(Vector(cleanNode, agentNode(agent))).addAgent(agent)
78+
val map = VacuumMap(Vector(cleanNode, agentNode(agent))).addAgent(agent)
8079

8180
map.getAgentLocation(agent) must beSome(LocationBPercept)
8281
}
8382

8483
"moving right will put in spot B" in prop { map: VacuumMap =>
8584
val agent = noopAgent
86-
map.addAgent(agent)
87-
.moveAgent(agent, RightMoveAction)
88-
.getAgentLocation(agent) must beSome(LocationBPercept)
85+
map.addAgent(agent).moveAgent(agent, RightMoveAction).getAgentLocation(agent) must beSome(LocationBPercept)
8986
}
9087

9188
"moving left will put in spot A" in prop { map: VacuumMap =>
9289
val agent = noopAgent
93-
map.addAgent(agent)
94-
.moveAgent(agent, LeftMoveAction)
95-
.getAgentLocation(agent) must beSome(LocationAPercept)
90+
map.addAgent(agent).moveAgent(agent, LeftMoveAction).getAgentLocation(agent) must beSome(LocationAPercept)
9691
}
9792

98-
9993
"updating dirt status of dirty will return dirt percept of dirty" in prop { map: VacuumMap =>
10094
val agent = noopAgent
101-
map.addAgent(agent)
102-
.updateStatus(agent, DirtyPercept)
103-
.getDirtStatus(agent) must beSome(DirtyPercept)
95+
map.addAgent(agent).updateStatus(agent, DirtyPercept).getDirtStatus(agent) must beSome(DirtyPercept)
10496
}
10597

10698
"updating dirt status of clean will return clean percept of dirty" in prop { map: VacuumMap =>
10799
val agent = noopAgent
108-
map.addAgent(agent)
109-
.updateStatus(agent, CleanPercept)
110-
.getDirtStatus(agent) must beSome(CleanPercept)
100+
map.addAgent(agent).updateStatus(agent, CleanPercept).getDirtStatus(agent) must beSome(CleanPercept)
111101
}
112102

113103
"removing agent must have no location percept" in prop { map: VacuumMap =>
114104
val agent = noopAgent
115-
map.addAgent(agent)
116-
.removeAgent(agent)
117-
.getAgentLocation(agent) must beNone
105+
map.addAgent(agent).removeAgent(agent).getAgentLocation(agent) must beNone
118106
}
119107

120108
"removing agent must have no status percept" in prop { map: VacuumMap =>
121109
val agent = noopAgent
122-
map.addAgent(agent)
123-
.removeAgent(agent)
124-
.getDirtStatus(agent) must beNone
110+
map.addAgent(agent).removeAgent(agent).getDirtStatus(agent) must beNone
125111
}
126112

127113
"adding an agent and then removing them should be the original input, eg f'(f(x)) = x" in prop { map: VacuumMap =>
128114
val agent = noopAgent
129-
map.addAgent(agent)
130-
.removeAgent(agent) must_== map
115+
map.addAgent(agent).removeAgent(agent) must_== map
131116
}
132117

133-
134-
135118
def noopAgent = new Agent {
136-
def agentFunction: AgentFunction = {_ => NoAction}
119+
def agentFunction: AgentFunction = { _ =>
120+
NoAction
121+
}
137122
}
138123

139-
140-
141124
def agentNode(agent: Agent = noopAgent) = VacuumMapNode(maybeAgent = Some(agent))
142-
def dirtyNode = VacuumMapNode(DirtyPercept, None)
143-
def cleanNode = VacuumMapNode(CleanPercept, None)
125+
def dirtyNode = VacuumMapNode(DirtyPercept, None)
126+
def cleanNode = VacuumMapNode(CleanPercept, None)
144127
}

core/src/test/scala/aima/core/search/problems/RomaniaRoadMapSpec.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package aima.core.search.problems
22

33
import org.specs2.mutable.Specification
44
import Romania._
5+
56
/**
67
* @author Shawn Garner
78
*/

core/src/test/scala/aima/core/search/uninformed/RomaniaBreadthFirstSearchSpec.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ class RomaniaBreadthFirstSearchSpec extends Specification {
1717
search(new RomaniaRoadProblem(In(Arad), In(Bucharest))) must_== List(GoTo(Sibiu), GoTo(Fagaras), GoTo(Bucharest))
1818
}
1919

20-
trait context extends Scope with BreadthFirstSearch {
21-
22-
23-
}
24-
25-
20+
trait context extends Scope with BreadthFirstSearch {}
2621

2722
}

core/src/test/scala/aima/core/search/uninformed/RomaniaDepthLimitedTreeSearchSpec.scala

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,22 @@ class RomaniaDepthLimitedTreeSearchSpec extends Specification {
1818

1919
"going from Arad to Bucharest must return a list of actions with depth 19" in new context {
2020
search(new RomaniaRoadProblem(In(Arad), In(Bucharest)), 19) must beSuccessfulTry.like {
21-
case Solution(GoTo(Sibiu)::GoTo(RimnicuVilcea)::GoTo(Pitesti)::GoTo(Bucharest)::Nil) => ok
21+
case Solution(GoTo(Sibiu) :: GoTo(RimnicuVilcea) :: GoTo(Pitesti) :: GoTo(Bucharest) :: Nil) => ok
2222
}
2323
}
2424

2525
"going from Arad to Bucharest must return a list of actions with depth 9" in new context {
2626
search(new RomaniaRoadProblem(In(Arad), In(Bucharest)), 9) must beSuccessfulTry.like {
27-
case Solution(GoTo(Sibiu)::GoTo(RimnicuVilcea)::GoTo(Pitesti)::GoTo(Bucharest)::Nil) => ok
27+
case Solution(GoTo(Sibiu) :: GoTo(RimnicuVilcea) :: GoTo(Pitesti) :: GoTo(Bucharest) :: Nil) => ok
2828
}
2929
}
3030

3131
"going from Arad to Bucharest must return a Cuttoff with depth 1" in new context {
3232
search(new RomaniaRoadProblem(In(Arad), In(Bucharest)), 1) must beSuccessfulTry.like {
33-
case CutOff(GoTo(Zerind)::Nil) => ok
33+
case CutOff(GoTo(Zerind) :: Nil) => ok
3434
}
3535
}
3636

37-
38-
trait context extends Scope with DepthLimitedTreeSearch {
39-
40-
41-
}
42-
43-
37+
trait context extends Scope with DepthLimitedTreeSearch {}
4438

4539
}

core/src/test/scala/aima/core/search/uninformed/RomaniaIterativeDeepeningSearchSpec.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ class RomaniaIterativeDeepeningSearchSpec extends Specification {
1717

1818
"going from Arad to Bucharest must return a list of actions" in new context {
1919
search(new RomaniaRoadProblem(In(Arad), In(Bucharest))) must beSuccessfulTry.like {
20-
case Solution(GoTo(Sibiu)::GoTo(Fagaras)::GoTo(Bucharest)::Nil) => ok
20+
case Solution(GoTo(Sibiu) :: GoTo(Fagaras) :: GoTo(Bucharest) :: Nil) => ok
2121
}
2222
}
2323

24-
2524
trait context extends Scope with IterativeDeepeningSearch {
2625

2726
lazy val depthLimitedTreeSearch = new DepthLimitedTreeSearch {}
2827
}
2928

30-
31-
3229
}

core/src/test/scala/aima/core/search/uninformed/RomaniaUniformCostSearchSpec.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ class RomaniaUniformCostSearchSpec extends Specification {
1414
}
1515

1616
"going from Arad to Bucharest must return a list of actions" in new context {
17-
search(new RomaniaRoadProblem(In(Arad), In(Bucharest))) must_== List(GoTo(Sibiu), GoTo(RimnicuVilcea), GoTo(Pitesti), GoTo(Bucharest))
17+
search(new RomaniaRoadProblem(In(Arad), In(Bucharest))) must_== List(GoTo(Sibiu),
18+
GoTo(RimnicuVilcea),
19+
GoTo(Pitesti),
20+
GoTo(Bucharest))
1821
}
1922

20-
trait context extends Scope with UniformCostSearch {
21-
22-
23-
}
24-
25-
23+
trait context extends Scope with UniformCostSearch {}
2624

2725
}

0 commit comments

Comments
 (0)