...
 
Commits (16)
# CI Config for helloword with davis / gitlab
# Global runner/docker image definition
image: openjdk:8
# Global caching
cache:
key: "cache"
paths:
# gradle
- .gradle
- build
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle && mkdir -pv $GRADLE_USER_HOME
# Main build
build:
stage: build
tags:
- docker
script:
- ./gradlew clean
- ./gradlew downloadAndUnzipFile
- ./gradlew assemble
- ./gradlew helloNoX
......@@ -4,7 +4,6 @@
```
./gradlew downloadAndUnzipFile
./gradlew getJBotsim
```
## Getting started without IDE
......@@ -12,11 +11,11 @@
1. Write your java algorithm into the `src` folder : `MyAlgo.java`
2. Configure your `PATH` variable
```
export PATH=$PATH:`pwd`/davis/bin
export PATH=$PATH:`pwd`/build/install/davis-beta/bin
```
3. Execute in the `src` directory
```
udavis <networkGeneratorFile> <scheme> <size> <algoFile : MyAlgo.java>
udavis -n <networkGeneratorFile> -i <ids> -s <size> -al <algoFile : MyAlgo.java>
```
......@@ -25,15 +24,15 @@ udavis <networkGeneratorFile> <scheme> <size> <algoFile : MyAlgo.java>
1. Modify `commandLine` parameters for task `davis` in `build.gradle`.
3. Run
```
./gradlew davis
./gradlew hello
```
You can also collect all your examples in a `scenario` file
1. Open `scr/scenario` file and add a line with 5 parameters :
`<scenarioName> <networkGeneratorFile> <scheme> <size> <algoFile : MyAlgo.java>`
3. Execute in a terminal with `./gradlew runscenarioName`
`[<scenarioName>] -n <networkGeneratorFile> -i <scheme> -s <size> -al <algoFile : MyAlgo.java>`
3. Execute in a terminal with `./gradlew run[scenarioName]`
## Getting started with Intellij
......@@ -50,14 +49,20 @@ Choose the `basic-example` folder and click ok for *auto-import*.
1. Write your java algorithm into the `src` folder : `MyAlgo.java`
2. Open `src/scenario` file and add a line with 5 parameters :
`<testName> <networkGeneratorFile> <scheme> <size> <algoFile : MyAlgo.java>`
`[<scenarioName>] -n <networkGeneratorFile> -i <scheme> -s <size> -al <algoFile : MyAlgo.java>`
3. Refresh gradle panel.
4. In `Tasks/application` of the gradle panel you should see your testName as a
gradle task named "runtestName"
4. In `Tasks/application` of the gradle panel you should see your scenario as a
gradle task named `run[<scenarioName>]`.
5. Click to execute.
## Docs
See also the [documentation for davis](https://gitlab.lis-lab.fr/davis/davis/tree/master/doc).
......@@ -9,32 +9,27 @@ apply plugin: "java"
apply plugin: "idea"
apply plugin: "application"
// Install jbotsim locally in davis/lib
task installJBotsim(type: Copy, group: "distribution", description: "Install jbotsim locally"){
dependsOn installDist
from 'build/install/basic-example/lib/'
include 'jbotsim-*'
into 'davis/lib'
}
// Basic task to launch davis with appropriate arguments :
// <network> <id> <size> <algo>
task davis(type: Exec, group: "Application", description: "Run default Davis") {
commandLine 'davis/bin/udavis','src/RingAnon2AgentsSym.java','RandomIds','18','src/randomWalkRing.java'
dependsOn installJBotsim
// -n <network> -i <id> -s <size> -al <algo>
task hello(type: Exec, group: "Application", description: "Run default Davis") {
commandLine davisInstall + File.separator + 'davis-beta/bin/udavis','-n','src/RingAnon2AgentsSym.java','-i', 'RandomIds','-s', '18','-al', 'src/RandomWalkRing.java'
}
def davisFiles = "${projectDir}/davis/"
// Basic task to launch davis with appropriate arguments without GUI:
// -n <network> -i <id> -s <size> -al <algo>
task helloNoX(type: Exec, group: "Application", description: "Run default Davis without GUI") {
commandLine davisInstall + File.separator + 'davis-beta/bin/udavis-nogui','-n','src/RingAnon2AgentsSym.java','-i', 'RandomIds','-s', '18','-al', 'src/RandomWalkRing.java'
}
def davisFiles = "${projectDir}/davis-beta/"
println("${davisFiles}")
repositories {
jcenter()
maven {
name = "jbotsim-repo"
url = "https://repo1.maven.org/maven2/io/jbotsim/"
}
mavenCentral()
flatDir {
dirs "davis/lib"
dirs davisInstall + File.separator + "davis-beta/lib"
}
}
......@@ -43,14 +38,14 @@ repositories {
* contents to the build directory
*/
task downloadZipFile(type: Download) {
src 'http://pageperso.lif.univ-mrs.fr/~emmanuel.godard/udavis-0.7rc2.zip'
dest new File('davis', 'udavis-0.7rc2.zip')
src 'http://pageperso.lif.univ-mrs.fr/~emmanuel.godard/davis-beta-' + davisVersion
dest new File(davisInstall, 'davis-beta-' + davisVersion + '.zip')
overwrite false // to download only once
}
task downloadAndUnzipFile(dependsOn: downloadZipFile, type: Copy) {
from zipTree(downloadZipFile.dest)
into 'davis'
into davisInstall
}
defaultTasks 'downloadAndUnzipFile'
......@@ -63,8 +58,8 @@ dependencies {
compile name: 'antlr4-annotations-4.2'
compile name: 'antlr4-runtime-4.2'
compile name: 'commons-cli-1.4'
compile name: 'davis-core-0.5.2-93-g2a88e16'
compile name: 'davis-ui-0.5.2-93-g2a88e16'
compile name: 'davis-core-' + davisVersion
compile name: 'davis-ui-' + davisVersion
compile name: 'digraph-parser-1.0'
compile name: 'org.abego.treelayout.core-1.0.1'
compile name: 'tools'
......
# Define jbotsim dependency version
jbotsimVersion = 1.0.0
# Define davis version
davisVersion = 0.8
# Define davis install directory
davisInstall = build/install
public class Main{
public static void main(String[] args) {
System.out.println("Hello");
}
}
\ No newline at end of file
import davis.core.agents.rendez_vous.RDVRingAgent;
import davis.core.agents.rendez_vous.RDVRectangularAgent;
import davis.core.model.RectangularAgent;
import java.util.ArrayList;
import java.util.Random;
public class RandomWalkWaitRing extends RDVRingAgent {
public class RandomWalkPath extends RDVRectangularAgent {
Random random;
public void init() {
......@@ -11,10 +13,10 @@ public class RandomWalkWaitRing extends RDVRingAgent {
}
public void randomWalk(Object Board) {
if (random.nextBoolean()) stay();
else {
if (random.nextBoolean()) goLeft();
else goRight();
if (random.nextBoolean()) {
if (!goRight()) goLeft();
} else {
if (!goLeft()) goRight();
}
}
}
......@@ -2,7 +2,7 @@ import davis.core.agents.rendez_vous.RDVRingAgent;
import java.util.Random;
public class randomWalkRing extends RDVRingAgent {
public class RandomWalkRing extends RDVRingAgent {
Random random;
public void init() {
......@@ -11,11 +11,10 @@ public class randomWalkRing extends RDVRingAgent {
}
public void randomWalk(Object board) {
if (random.nextBoolean()) goLeft();
else goRight();
}
public void rdv(Object board) {
super.rdv(board);
if (random.nextBoolean()) {
goLeft();
} else if (random.nextBoolean()) {
goRight();
} else stay();
}
}
import davis.core.idscheme.IdScheme;
import davis.core.model.RectangularAgent;
import davis.core.model.RectangularPlace;
import davis.core.network.AgentFactory;
import davis.core.network.RectangularGridGenerator;
import io.jbotsim.core.Topology;
public class RectangularTwoAgents<B> extends RectangularGridGenerator<RectangularPlace<B>> {
@Override
public void generate(Topology topo, IdScheme id) {
Class defaultNode = topo.getDefaultNodeModel();
topo.setDefaultNodeModel(RectangularPlace.class);
super.generate(topo, id);
topo.setDefaultNodeModel(defaultNode);
AgentFactory.<RectangularAgent<B>, B>nAgentsAtRandomPlace(topo, 2);
}
}
test1 RingAnon2AgentsSym.java RandomIds 18 randomWalkRing.java
test2 RingAnon2AgentsSym.java RandomIds 18 RandomWalkWaitRing.java
[RandomWalkRing2agents] -n RingAnon2AgentsSym.java -i RandomIds -s 16 -al RandomWalkRing.java
[RandomWalkPath] -n RectangularTwoAgents.java -i RandomIds -s 18*1 -al RandomWalkPath.java