From b004768f607e4da4d8355533db5429010009ba42 Mon Sep 17 00:00:00 2001 From: Danilo Pianini Date: Sat, 9 Dec 2023 17:59:45 +0100 Subject: [PATCH] fix: adapt the tutorial to Alchemist 29 --- build.gradle.kts | 17 ++++++++++++++--- src/main/yaml/00-minimal.yml | 3 +++ src/main/yaml/01-nodes.yml | 3 +++ src/main/yaml/02-manynodes.yml | 3 +++ src/main/yaml/03-grid.yml | 5 +++++ src/main/yaml/04-perturb-grid.yml | 3 +++ src/main/yaml/05-content.yml | 3 +++ src/main/yaml/06-program.yml | 3 +++ src/test/kotlin/RunSimulationTest.kt | 10 +++++----- 9 files changed, 42 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 56ea332..d9c6854 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -64,11 +64,22 @@ File(rootProject.rootDir.path + "/src/main/yaml").listFiles() exportsDir.mkdirs() } } - args("-y", it.absolutePath, "-e", "$exportsDir/${it.nameWithoutExtension}-${System.currentTimeMillis()}") + args("run", it.absolutePath) if (System.getenv("CI") == "true" || batch == "true") { - args("-hl", "-t", maxTime) + args( + "--override", + """ + { + launcher: { type: HeadlessSimulationLauncher, parameters: [] }, + terminate: { type: AfterTime, parameters: 2 } + } + """.trimIndent() + ) } else { - args("-g", "effects/${it.nameWithoutExtension}.json") + args( + "--override", + "{ launcher: { parameters: { graphics: \"effects/${it.nameWithoutExtension}.json\" } } }" + ) } outputs.dir(exportsDir) } diff --git a/src/main/yaml/00-minimal.yml b/src/main/yaml/00-minimal.yml index d88b5b7..6b56d16 100644 --- a/src/main/yaml/00-minimal.yml +++ b/src/main/yaml/00-minimal.yml @@ -1,3 +1,6 @@ incarnation: protelis +launcher: + type: SingleRunSwingUI + # An empty world \ No newline at end of file diff --git a/src/main/yaml/01-nodes.yml b/src/main/yaml/01-nodes.yml index c5ef490..c23392f 100644 --- a/src/main/yaml/01-nodes.yml +++ b/src/main/yaml/01-nodes.yml @@ -1,5 +1,8 @@ incarnation: protelis +launcher: + type: SingleRunSwingUI + # Link nodes that are closer than 5 distance units network-model: type: ConnectWithinDistance diff --git a/src/main/yaml/02-manynodes.yml b/src/main/yaml/02-manynodes.yml index fddc72f..6e6eb9f 100644 --- a/src/main/yaml/02-manynodes.yml +++ b/src/main/yaml/02-manynodes.yml @@ -1,5 +1,8 @@ incarnation: protelis +launcher: + type: SingleRunSwingUI + # Link nodes separated by at most 0.5 space units network-model: type: ConnectWithinDistance diff --git a/src/main/yaml/03-grid.yml b/src/main/yaml/03-grid.yml index 12fa324..fcd1f10 100644 --- a/src/main/yaml/03-grid.yml +++ b/src/main/yaml/03-grid.yml @@ -1,5 +1,10 @@ incarnation: protelis +launcher: + type: SingleRunSwingUI + parameters: + graphics: "effects/07-gradient" + network-model: type: ConnectWithinDistance parameters: [0.5] diff --git a/src/main/yaml/04-perturb-grid.yml b/src/main/yaml/04-perturb-grid.yml index 56ca178..81f6845 100644 --- a/src/main/yaml/04-perturb-grid.yml +++ b/src/main/yaml/04-perturb-grid.yml @@ -1,5 +1,8 @@ incarnation: protelis +launcher: + type: SingleRunSwingUI + network-model: type: ConnectWithinDistance parameters: [0.5] diff --git a/src/main/yaml/05-content.yml b/src/main/yaml/05-content.yml index 2b3fef8..c421555 100644 --- a/src/main/yaml/05-content.yml +++ b/src/main/yaml/05-content.yml @@ -1,5 +1,8 @@ incarnation: protelis +launcher: + type: SingleRunSwingUI + network-model: type: ConnectWithinDistance parameters: [0.5] diff --git a/src/main/yaml/06-program.yml b/src/main/yaml/06-program.yml index a5607d2..92f81b6 100644 --- a/src/main/yaml/06-program.yml +++ b/src/main/yaml/06-program.yml @@ -1,5 +1,8 @@ incarnation: protelis +launcher: + type: SingleRunSwingUI + network-model: type: ConnectWithinDistance parameters: [0.5] diff --git a/src/test/kotlin/RunSimulationTest.kt b/src/test/kotlin/RunSimulationTest.kt index 41b87cc..669114e 100644 --- a/src/test/kotlin/RunSimulationTest.kt +++ b/src/test/kotlin/RunSimulationTest.kt @@ -2,12 +2,12 @@ import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.collections.beEmpty import io.kotest.matchers.file.shouldHaveExtension import io.kotest.matchers.shouldNot -import it.unibo.alchemist.core.implementations.Engine -import it.unibo.alchemist.core.interfaces.Status -import it.unibo.alchemist.loader.LoadAlchemist -import it.unibo.alchemist.model.implementations.positions.Euclidean2DPosition +import it.unibo.alchemist.boundary.LoadAlchemist +import it.unibo.alchemist.core.Engine +import it.unibo.alchemist.core.Status +import it.unibo.alchemist.model.positions.Euclidean2DPosition +import it.unibo.alchemist.model.times.DoubleTime import java.io.File -import it.unibo.alchemist.model.implementations.times.DoubleTime import java.util.concurrent.TimeUnit class RunSimulationTest : StringSpec(