Skip to content

Commit ea2b209

Browse files
authored
trying out open jdk 11 (#73)
* trying out open jdk 11 * bump sbt version which supports jdk11 * updated plugins to work with jdk 11; reformatted source * changing formating to do more alignment
1 parent ed13fc4 commit ea2b209

File tree

16 files changed

+110
-76
lines changed

16 files changed

+110
-76
lines changed

.scalafmt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
style = defaultWithAlign
2-
maxColumn = 120
1+
align = most
2+
maxColumn = 120
3+
version = 2.0.0-RC5

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: scala
33
scala:
44
- 2.12.8
55
jdk:
6-
- oraclejdk8
6+
- openjdk11
77
cache:
88
directories:
99
- $HOME/.m2/repository

build.sbt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import org.scalafmt.sbt.ScalaFmtPlugin.autoImport._
1+
import org.scalafmt.sbt.ScalafmtPlugin.autoImport._
22

33
lazy val commonSettings = Seq(
44
organization := "com.github.aimacode.aima-scala",
55
version := "0.1.0-SNAPSHOT",
66
scalaVersion := "2.12.8",
7-
scalafmtConfig := Some(file(".scalafmt")),
7+
scalafmtConfig := file(".scalafmt"),
8+
scalafmtOnCompile := true,
89
addCompilerPlugin("org.psywerx.hairyfotr" %% "linter" % "0.1.16"),
910
coverageEnabled := false,
1011
coverageMinimum := 70,
1112
coverageFailOnMinimum := false,
1213
autoCompilerPlugins := true
13-
) ++ reformatOnCompileSettings
14+
)
1415

1516
lazy val librarySettings = Seq(
1617
"org.specs2" %% "specs2-core" % "3.8.6" % Test,

core/src/main/scala/aima/core/agent/basic/OnlineDFSAgent.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import aima.core.agent.basic.OnlineDFSAgentState.{RESULT, UNBACKTRACKED, UNTRIED
2727
*
2828
* @author Shawn Garner
2929
*/
30-
final class OnlineDFSAgent[PERCEPT, ACTION, STATE](identifyStateFor: IdentifyState[PERCEPT, STATE],
31-
onlineProblem: OnlineSearchProblem[STATE, ACTION],
32-
stop: ACTION)
33-
extends StatelessAgent[PERCEPT, ACTION, OnlineDFSAgentState[ACTION, STATE]] {
30+
final class OnlineDFSAgent[PERCEPT, ACTION, STATE](
31+
identifyStateFor: IdentifyState[PERCEPT, STATE],
32+
onlineProblem: OnlineSearchProblem[STATE, ACTION],
33+
stop: ACTION
34+
) extends StatelessAgent[PERCEPT, ACTION, OnlineDFSAgentState[ACTION, STATE]] {
3435

3536
import OnlineDFSAgentState.Implicits._
3637

@@ -56,7 +57,8 @@ final class OnlineDFSAgent[PERCEPT, ACTION, STATE](identifyStateFor: IdentifySta
5657
case (Some(_s), Some(_a)) if !priorAgentState.result.get(_s).flatMap(_.get(_a)).contains(sPrime) =>
5758
val resultOrigActionToState: Map[ACTION, STATE] =
5859
priorAgentState.result.getOrElse(_s, Map.empty[ACTION, STATE])
59-
val updatedResultActionToState: Map[ACTION, STATE] = resultOrigActionToState.put(_a, sPrime) // TODO: could be less verbose with lense
60+
val updatedResultActionToState
61+
: Map[ACTION, STATE] = resultOrigActionToState.put(_a, sPrime) // TODO: could be less verbose with lense
6062
(
6163
priorAgentState.result.put(_s, updatedResultActionToState),
6264
priorAgentState.unbacktracked.transformValue(sPrime, fv => fv.fold(List(_s))(st => _s :: st))
@@ -118,7 +120,7 @@ final case class OnlineDFSAgentState[ACTION, STATE](
118120
result: RESULT[ACTION, STATE],
119121
untried: UNTRIED[ACTION, STATE],
120122
unbacktracked: UNBACKTRACKED[STATE],
121-
previousState: Option[STATE], // s
123+
previousState: Option[STATE], // s
122124
previousAction: Option[ACTION] // a
123125
)
124126

core/src/main/scala/aima/core/environment/vacuum/ModelBasedReflexVacuumAgent.scala

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,30 @@ object ModelBasedReflexVacuumAgent {
1313
*/
1414
class ModelBasedReflexVacuumAgent extends ModelBasedReflexAgent {
1515

16-
case class VacuumWorldState(locationA: Boolean = false,
17-
locationB: Boolean = false,
18-
dirty: Boolean = true,
19-
batteryLife: Int = 100)
16+
case class VacuumWorldState(
17+
locationA: Boolean = false,
18+
locationB: Boolean = false,
19+
dirty: Boolean = true,
20+
batteryLife: Int = 100
21+
)
2022

2123
type State = VacuumWorldState
2224

2325
lazy val model: Model = {
2426
case (currentState, RightMoveAction) =>
25-
currentState.copy(locationA = false,
26-
locationB = true,
27-
dirty = true,
28-
batteryLife = currentState.batteryLife - MOVE_BATTERY_COST)
27+
currentState.copy(
28+
locationA = false,
29+
locationB = true,
30+
dirty = true,
31+
batteryLife = currentState.batteryLife - MOVE_BATTERY_COST
32+
)
2933
case (currentState, LeftMoveAction) =>
30-
currentState.copy(locationA = true,
31-
locationB = false,
32-
dirty = true,
33-
batteryLife = currentState.batteryLife - MOVE_BATTERY_COST)
34+
currentState.copy(
35+
locationA = true,
36+
locationB = false,
37+
dirty = true,
38+
batteryLife = currentState.batteryLife - MOVE_BATTERY_COST
39+
)
3440
case (currentState, Suck) =>
3541
currentState.copy(dirty = false, batteryLife = currentState.batteryLife - SUCK_BATTERY_COST)
3642
case (currentState, NoAction) => currentState

core/src/main/scala/aima/core/environment/vacuum/VacuumEnvironment.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ case class VacuumMap(nodes: Vector[VacuumMapNode] = Vector.fill(2)(VacuumMapNode
6464
}
6565

6666
private[this] def indexToLocationPercept(index: Int): Percept = {
67-
if (index == 0) { LocationAPercept } else { LocationBPercept }
67+
if (index == 0) {
68+
LocationAPercept
69+
} else {
70+
LocationBPercept
71+
}
6872
}
6973
private[this] def directionToMapIndex(direction: MoveAction): Int =
7074
direction match {
@@ -73,8 +77,9 @@ case class VacuumMap(nodes: Vector[VacuumMapNode] = Vector.fill(2)(VacuumMapNode
7377
}
7478

7579
def moveAgent(agent: Agent, direction: MoveAction): VacuumMap = {
76-
removeAgent(agent).updateByIndex(directionToMapIndex(direction))(vacuumMapNode =>
77-
vacuumMapNode.copy(maybeAgent = Some(agent)))
80+
removeAgent(agent).updateByIndex(directionToMapIndex(direction))(
81+
vacuumMapNode => vacuumMapNode.copy(maybeAgent = Some(agent))
82+
)
7883
}
7984

8085
private[this] def updateByAgent(target: Agent)(f: VacuumMapNode => VacuumMapNode): VacuumMap = {

core/src/main/scala/aima/core/search/ProblemSearch.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ sealed trait SearchNode {
2323

2424
case class StateNode(state: State, action: Action, parent: Option[StateNode]) extends SearchNode
2525
case class CostNode(state: State, cost: Int, action: Action, parent: Option[CostNode]) extends SearchNode
26-
case class HeuristicsNode(state: State,
27-
gValue: Double,
28-
hValue: Option[Double],
29-
fValue: Option[Double],
30-
action: Action,
31-
parent: Option[CostNode])
32-
extends SearchNode
26+
case class HeuristicsNode(
27+
state: State,
28+
gValue: Double,
29+
hValue: Option[Double],
30+
fValue: Option[Double],
31+
action: Action,
32+
parent: Option[CostNode]
33+
) extends SearchNode
3334

3435
/**
3536
* @author Shawn Garner

core/src/main/scala/aima/core/search/contingency/AndOrGraphSearch.scala

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ trait AndOrGraphSearch[ACTION, STATE] {
3535
def andOrGraphSearch(problem: NondeterministicProblem[ACTION, STATE]): ConditionPlanResult =
3636
orSearch(problem.initialState(), problem, Nil)
3737

38-
def orSearch(state: STATE, problem: NondeterministicProblem[ACTION, STATE], path: List[STATE]): ConditionPlanResult = {
38+
def orSearch(
39+
state: STATE,
40+
problem: NondeterministicProblem[ACTION, STATE],
41+
path: List[STATE]
42+
): ConditionPlanResult = {
3943
if (problem.isGoalState(state)) {
4044
ConditionalPlan.emptyPlan
4145
} else if (path.contains(state)) {
@@ -57,9 +61,11 @@ trait AndOrGraphSearch[ACTION, STATE] {
5761
}
5862
}
5963

60-
def andSearch(states: List[STATE],
61-
problem: NondeterministicProblem[ACTION, STATE],
62-
path: List[STATE]): ConditionPlanResult = {
64+
def andSearch(
65+
states: List[STATE],
66+
problem: NondeterministicProblem[ACTION, STATE],
67+
path: List[STATE]
68+
): ConditionPlanResult = {
6369

6470
@tailrec def recurse(currentStates: List[STATE], acc: List[(STATE, ConditionalPlan)]): ConditionPlanResult =
6571
currentStates match {
@@ -95,9 +101,11 @@ final case class ConditionalPlan(steps: List[Step]) extends ConditionPlanResult
95101

96102
object ConditionalPlan {
97103
val emptyPlan = ConditionalPlan(List.empty)
98-
def show[STATE, ACTION](conditionalPlan: ConditionalPlan,
99-
showState: STATE => String,
100-
showAction: ACTION => String): String = {
104+
def show[STATE, ACTION](
105+
conditionalPlan: ConditionalPlan,
106+
showState: STATE => String,
107+
showAction: ACTION => String
108+
): String = {
101109

102110
@tailrec def recurse(steps: List[Step], acc: String, lastStepAction: Boolean): String = steps match {
103111
case Nil => acc
@@ -110,9 +118,7 @@ object ConditionalPlan {
110118
case ConditionedSubPlan(_, subPlan) :: ActionStep(a) :: rest =>
111119
recurse(ActionStep(a) :: rest, acc + s" else ${show(subPlan, showState, showAction)}", false)
112120
case ConditionedSubPlan(state: STATE, subPlan) :: rest =>
113-
recurse(rest,
114-
acc + s" else if State = ${showState(state)} then ${show(subPlan, showState, showAction)}",
115-
false)
121+
recurse(rest, acc + s" else if State = ${showState(state)} then ${show(subPlan, showState, showAction)}", false)
116122
}
117123

118124
recurse(conditionalPlan.steps, "[", true) + "]"

core/src/main/scala/aima/core/search/problems/romania.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ object Romania {
7070
Road(Urziceni, Bucharest, 85),
7171
Road(Urziceni, Vaslui, 142),
7272
Road(Urziceni, Hirsova, 98), //Urziceni Edges
73-
Road(Neamt, Iasi, 87), //Neamt Edges
73+
Road(Neamt, Iasi, 87), //Neamt Edges
7474
Road(Iasi, Neamt, 87),
7575
Road(Iasi, Vaslui, 92), //Iasi Edges
7676
Road(Vaslui, Iasi, 92),
7777
Road(Vaslui, Urziceni, 142), //Vaslui Edges
7878
Road(Hirsova, Urziceni, 98),
7979
Road(Hirsova, Eforie, 86), //Hirsova Edges
80-
Road(Eforie, Hirsova, 86) //Eforie Edges
80+
Road(Eforie, Hirsova, 86) //Eforie Edges
8181
).foldLeft(Map.empty[City, List[Road]]) { (acc, road) =>
8282
val from = road.from
8383
val listForEdge = acc.getOrElse(from, List.empty[Road])

core/src/main/scala/aima/core/search/uninformed/GraphSearch.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait GraphSearch extends ProblemSearch with FrontierSearch {
2020
case Some((leaf, updatedFrontier)) =>
2121
val updatedExploredSet = exploredSet + leaf.state
2222
val childNodes = for {
23-
action <- problem.actions(leaf.state)
23+
action <- problem.actions(leaf.state)
2424
childNode = newChildNode(problem, leaf, action)
2525
if !(updatedExploredSet.contains(childNode.state)
2626
|| updatedFrontier.contains(childNode.state))

0 commit comments

Comments
 (0)