Skip to content

Commit b514781

Browse files
benderpremierBusyByte
authored andcommitted
Compile for scala js and update to scala 2.13.1 (#78)
* cross compile for scalaJS * update to scala 2.13.1 * update travis
1 parent 4c58f4a commit b514781

File tree

13 files changed

+49
-25
lines changed

13 files changed

+49
-25
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dist: trusty
22
language: scala
33
scala:
4-
- 2.12.8
4+
- 2.13.1
55
jdk:
66
- openjdk11
77
cache:

build.sbt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
import org.scalafmt.sbt.ScalafmtPlugin.autoImport._
2+
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
23

34
lazy val commonSettings = Seq(
45
organization := "com.github.aimacode.aima-scala",
56
version := "0.1.0-SNAPSHOT",
6-
scalaVersion := "2.12.8",
7+
scalaVersion := "2.13.1",
78
scalafmtConfig := file(".scalafmt"),
89
scalafmtOnCompile := true,
910
coverageEnabled := false,
1011
coverageMinimum := 70,
1112
coverageFailOnMinimum := false,
1213
autoCompilerPlugins := true
13-
)
14+
)
1415

15-
lazy val librarySettings = Seq(
16-
"org.specs2" %% "specs2-core" % "3.8.6" % Test,
17-
"org.specs2" %% "specs2-scalacheck" % "3.8.6" % Test,
18-
"org.scalacheck" %% "scalacheck" % "1.13.4" % Test
19-
)
20-
21-
lazy val root = (project in file(".")).settings(commonSettings: _*).aggregate(core)
16+
lazy val root = (project in file("."))
17+
.settings(commonSettings: _*)
18+
.aggregate(core.jvm, core.js)
2219

23-
lazy val core = (project in file("core"))
20+
lazy val core = crossProject(JSPlatform, JVMPlatform)
21+
.crossType(CrossType.Pure)
22+
.in(file("core"))
2423
.settings(commonSettings: _*)
2524
.settings(name := "core")
26-
.settings(libraryDependencies ++= librarySettings)
25+
.settings(dependencies.commonDependencies)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import aima.core.agent.StatelessAgent
44
import aima.core.agent.basic.LRTAStarAgent.IdentifyState
55
import aima.core.agent.basic.LRTAStarAgentState.{COST_ESTIMATES, RESULT}
66
import aima.core.search.api.OnlineSearchProblem
7+
import Ordering.Double.TotalOrdering
78

89
/**
910
*

core/src/main/scala/aima/core/environment/map2d/Map2DFunctionFactory.scala

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

33
import aima.core.search.CostNode
4+
import Ordering.Double.TotalOrdering
45

56
/**
67
* @author Shawn Garner

core/src/main/scala/aima/core/search/informed/RecursiveBestFirstSearch.scala

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

33
import aima.core.search.{HeuristicsNode, Problem, ProblemSearch}
4+
import Ordering.Double.TotalOrdering
45

56
import scala.annotation.tailrec
67
import scala.reflect.ClassTag

core/src/main/scala/aima/core/search/local/HillClimbing.scala

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

33
import aima.core.search.Problem
4+
import Ordering.Double.TotalOrdering
45

56
import scala.annotation.tailrec
67

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class FIFOQueueFrontier[State, Action, Node <: SearchNode[State, Action]](queue:
1414
case (leaf, updatedQueue) => (leaf, new FIFOQueueFrontier[State, Action, Node](updatedQueue, stateSet - leaf.state))
1515
}
1616
def addAll(iterable: Iterable[Node]): Frontier[State, Action, Node] =
17-
new FIFOQueueFrontier(queue.enqueue(iterable), stateSet ++ iterable.map(_.state))
17+
new FIFOQueueFrontier(queue.enqueueAll(iterable), stateSet ++ iterable.map(_.state))
1818
def contains(state: State): Boolean = stateSet.contains(state)
1919

2020
def replaceByState(node: Node): Frontier[State, Action, Node] = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ModelBasedReflexVacuumAgentSpec extends Specification {
5757
}
5858

5959
"should do nothing if low on power" in new context {
60-
val resultStream = Stream.continually(agent.agentFunction.apply(DirtyPercept))
60+
val resultStream = LazyList.continually(agent.agentFunction.apply(DirtyPercept))
6161
resultStream.take(100).last must beLike {
6262
case NoAction => ok
6363
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class TableDrivenVacuumAgentSpec extends Specification {
6666

6767
"table driven agent must persist all percepts" in new context {
6868
val rnd = new Random()
69-
val randomPerceptStream: Stream[VacuumPercept] = Stream.continually {
69+
val randomPerceptStream: LazyList[VacuumPercept] = LazyList.continually {
7070
val selector = rnd.nextInt(3)
7171
if (selector == 0)
7272
LocationPercept.randomValue

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ class VacuumMapSpec extends Specification with ScalaCheck {
5151
val agent = noopAgent
5252
val map = VacuumMap(Vector(dirtyNode, dirtyNode)).addAgent(agent)
5353

54-
map.getDirtStatus(agent) must beSome(DirtyPercept)
54+
map.getDirtStatus(agent) must beSome[VacuumPercept](DirtyPercept)
5555
}
5656

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

61-
map.getDirtStatus(agent) must beSome(CleanPercept)
61+
map.getDirtStatus(agent) must beSome[VacuumPercept](CleanPercept)
6262
}
6363

6464
"agent location of agent not on map must be none" in prop { map: VacuumMap =>
@@ -70,34 +70,38 @@ class VacuumMapSpec extends Specification with ScalaCheck {
7070
val agent = noopAgent
7171
val map = VacuumMap(Vector(agentNode(agent), cleanNode)).addAgent(agent)
7272

73-
map.getAgentLocation(agent) must beSome(LocationAPercept)
73+
map.getAgentLocation(agent) must beSome[VacuumPercept](LocationAPercept)
7474
}
7575

7676
"agent location must be B if in second spot" in {
7777
val agent = noopAgent
7878
val map = VacuumMap(Vector(cleanNode, agentNode(agent))).addAgent(agent)
7979

80-
map.getAgentLocation(agent) must beSome(LocationBPercept)
80+
map.getAgentLocation(agent) must beSome[VacuumPercept](LocationBPercept)
8181
}
8282

8383
"moving right will put in spot B" in prop { map: VacuumMap =>
8484
val agent = noopAgent
85-
map.addAgent(agent).moveAgent(agent, RightMoveAction).getAgentLocation(agent) must beSome(LocationBPercept)
85+
map.addAgent(agent).moveAgent(agent, RightMoveAction).getAgentLocation(agent) must beSome[VacuumPercept](
86+
LocationBPercept
87+
)
8688
}
8789

8890
"moving left will put in spot A" in prop { map: VacuumMap =>
8991
val agent = noopAgent
90-
map.addAgent(agent).moveAgent(agent, LeftMoveAction).getAgentLocation(agent) must beSome(LocationAPercept)
92+
map.addAgent(agent).moveAgent(agent, LeftMoveAction).getAgentLocation(agent) must beSome[VacuumPercept](
93+
LocationAPercept
94+
)
9195
}
9296

9397
"updating dirt status of dirty will return dirt percept of dirty" in prop { map: VacuumMap =>
9498
val agent = noopAgent
95-
map.addAgent(agent).updateStatus(agent, DirtyPercept).getDirtStatus(agent) must beSome(DirtyPercept)
99+
map.addAgent(agent).updateStatus(agent, DirtyPercept).getDirtStatus(agent) must beSome[VacuumPercept](DirtyPercept)
96100
}
97101

98102
"updating dirt status of clean will return clean percept of dirty" in prop { map: VacuumMap =>
99103
val agent = noopAgent
100-
map.addAgent(agent).updateStatus(agent, CleanPercept).getDirtStatus(agent) must beSome(CleanPercept)
104+
map.addAgent(agent).updateStatus(agent, CleanPercept).getDirtStatus(agent) must beSome[VacuumPercept](CleanPercept)
101105
}
102106

103107
"removing agent must have no location percept" in prop { map: VacuumMap =>

0 commit comments

Comments
 (0)