Skip to content

Commit

Permalink
Merge pull request #121 from EntelectChallenge/develop
Browse files Browse the repository at this point in the history
Release 3.0.2
  • Loading branch information
Blaarkies authored Sep 6, 2018
2 parents c6a15bd + 2654d83 commit b956b2e
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 30 deletions.
2 changes: 1 addition & 1 deletion game-engine-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>za.co.entelect.challenge</groupId>
<artifactId>game-engine-interface</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>

<distributionManagement>
<repository>
Expand Down
4 changes: 2 additions & 2 deletions game-engine/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>game-engine</artifactId>
<groupId>za.co.entelect.challenge</groupId>
<version>3.0.1</version>
<version>3.0.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>za.co.entelect.challenge</groupId>
<artifactId>domain</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion game-engine/domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>game-engine</artifactId>
<groupId>za.co.entelect.challenge</groupId>
<version>3.0.1</version>
<version>3.0.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ public void damageSelfDirectly(int damageTaken, TowerDefensePlayer missileOwner)
}

private void setHealthAndAddScore(int damageTaken, TowerDefensePlayer missileOwner) {

int previousHealth = health;
health -= damageTaken;
health = Math.max(0, health);

missileOwner.addScore(damageTaken * destroyMultiplier);
missileOwner.addScore((previousHealth - health) * destroyMultiplier);
}

public void decreaseCooldown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ public void deconstructBuilding(Building building) {

public void removeBuilding(Building building) {
buildings.remove(building);
try {
getPlayerOpponent(building.getPlayerType()).addScore(building.getDestroyMultiplier());
} catch (Exception e) {
log.error(e);
}
}

private Direction getDirectionAndUpdateBuilding(Building b) {
Expand Down
4 changes: 2 additions & 2 deletions game-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>za.co.entelect.challenge</groupId>
<artifactId>game-engine</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
<modules>
<module>domain</module>
<module>core</module>
Expand All @@ -16,7 +16,7 @@

<properties>
<java.version>1.8</java.version>
<game.engine.interfaces.version>3.0.1</game.engine.interfaces.version>
<game.engine.interfaces.version>3.0.2</game.engine.interfaces.version>
<junit.version>4.12</junit.version>
<apache.commons.configuration.version>2.2</apache.commons.configuration.version>
<gson.version>2.8.2</gson.version>
Expand Down
6 changes: 3 additions & 3 deletions game-runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<groupId>za.co.entelect.challenge</groupId>
<artifactId>game-runner</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>

<properties>
<java.version>1.8</java.version>
<reflections.version>0.9.11</reflections.version>
<gson.version>2.8.2</gson.version>
<game.engine.interface.version>3.0.1</game.engine.interface.version>
<game.engine.core.version>3.0.1</game.engine.core.version>
<game.engine.interface.version>3.0.2</game.engine.interface.version>
<game.engine.core.version>3.0.2</game.engine.core.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.commons.exec.ExecuteWatchdog;
import org.apache.commons.exec.PumpStreamHandler;
import za.co.entelect.challenge.entities.BotMetaData;
import za.co.entelect.challenge.entities.BotArguments;
import za.co.entelect.challenge.game.contracts.exceptions.TimeoutException;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -37,6 +38,8 @@ public String getBotFileName() {
return botMetaData.getBotFileName();
}

public BotArguments getArguments() { return botMetaData.getArguments(); }

protected String RunSimpleCommandLineCommand(String line, int expectedExitValue) throws IOException, TimeoutException {
CommandLine cmdLine = CommandLine.parse(line);
DefaultExecutor executor = new DefaultExecutor();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package za.co.entelect.challenge.botrunners;

import za.co.entelect.challenge.entities.BotMetaData;
import za.co.entelect.challenge.entities.BotArguments;
import za.co.entelect.challenge.game.contracts.exceptions.TimeoutException;

import java.io.IOException;
Expand All @@ -13,12 +14,20 @@ public HaskellBotRunner(BotMetaData botMetaData, int timeoutInMilliseconds) {

@Override
protected String runBot() throws IOException, TimeoutException {
String runTimeArguments;
if (this.getArguments() != null) {
int coreCount = this.getArguments().getCoreCount();
runTimeArguments = " +RTS -N" + Integer.toString(coreCount) + " -RTS";
} else {
runTimeArguments = "";
}

String line;

if(System.getProperty("os.name").contains("Windows")) {
line = "cmd /c \"" + this.getBotFileName() + "\"";
line = "cmd /c \"" + this.getBotFileName() + runTimeArguments + "\"";
} else {
line = "\"./" + this.getBotFileName() + "\"";
line = "./" + this.getBotFileName() + runTimeArguments;
}

return RunSimpleCommandLineCommand(line, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package za.co.entelect.challenge.entities;

import com.google.gson.annotations.SerializedName;

public class BotArguments {
@SerializedName("coreCount")
private int coreCount;

public BotArguments(int coreCount) {
this.coreCount = coreCount;
}

public int getCoreCount() {
return this.coreCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.annotations.SerializedName;
import za.co.entelect.challenge.enums.BotLanguage;
import za.co.entelect.challenge.entities.BotArguments;

import java.nio.file.Paths;

Expand All @@ -19,6 +20,8 @@ public class BotMetaData {
private String botLocation;
@SerializedName("botFileName")
private String botFileName;
@SerializedName("arguments")
private BotArguments arguments;

public BotMetaData(BotLanguage language, String botLocation, String botFileName){
this.botLanguage = language;
Expand Down Expand Up @@ -57,4 +60,8 @@ public BotLanguage getBotLanguage(){
public String getBotDirectory() {
return Paths.get(getBotLocation()).toAbsolutePath().normalize().toString();
}

public BotArguments getArguments() {
return this.arguments;
}
}
36 changes: 36 additions & 0 deletions starter-bots/haskell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,39 @@ Haskell creates native binaries so you can simply run:
```

from the command line to invoke the bot program.

## Running the Bot with Multiple Threads
In order to run the Haskell bot with multiple threads (and possibly
cores) you need to change the bot configuration to inform the runner
to supply the appropriate runtime arguments. The following is an
example "bot.json" for launching the bot with 2 threads:

```
{
"author": "John Doe",
"email": "[email protected]",
"nickName": "a-bot",
"botLocation": "/bin",
"botFileName": "EntelectChallenge2018-exe",
"botLanguage": "haskell",
"arguments": {
"coreCount": 2
}
}
```

You should also ensure that the executable is built with the
"-rtsopts" and "-threaded" compile time flags. These are supplied
under the "executables" section in "package.yaml". e.g.

```
executables:
EntelectChallenge2018-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
dependencies:
- EntelectChallenge2018
```
5 changes: 4 additions & 1 deletion starter-bots/haskell/bot.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"nickName": "Bill",
"botLocation": "/bin",
"botFileName": "EntelectChallenge2018-exe",
"botLanguage": "haskell"
"botLanguage": "haskell",
"arguments": {
"coreCount": 2
}
}
14 changes: 7 additions & 7 deletions starter-pack/ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
| |____| | | |/ ____ \| |____| |____| |____| |\ | |__| | |____
\_____|_| |_/_/ \_\______|______|______|_| \_|\_____|______|

____ ___ __
|___ \ / _ \ /_ |
__) | | | | | | |
|__ < | | | | | |
___) | _ | |_| | _ | |
|____/ (_) \___/ (_) |_|
____ ___ ___
|___ \ / _ \ |__ \
__) | | | | | ) |
|__ < | | | | / /
___) | _ | |_| | _ / /_
|____/ (_) \___/ (_) |____|


Welcome to the starter pack for the 2018 Entelect Challenge!
Here you will find all that you'll need to run your first bot and compete in this year's challenge.
Expand Down
4 changes: 2 additions & 2 deletions starter-pack/makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default:
java -jar tower-defence-runner-3.0.1.jar
java -jar tower-defence-runner-3.0.2.jar

run:
java -jar tower-defence-runner-3.0.1.jar
java -jar tower-defence-runner-3.0.2.jar
2 changes: 1 addition & 1 deletion starter-pack/run.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
java -jar tower-defence-runner-3.0.1.jar
java -jar tower-defence-runner-3.0.2.jar
pause
36 changes: 36 additions & 0 deletions starter-pack/starter-bots/haskell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,39 @@ Haskell creates native binaries so you can simply run:
```

from the command line to invoke the bot program.

## Running the Bot with Multiple Threads
In order to run the Haskell bot with multiple threads (and possibly
cores) you need to change the bot configuration to inform the runner
to supply the appropriate runtime arguments. The following is an
example "bot.json" for launching the bot with 2 threads:

```
{
"author": "John Doe",
"email": "[email protected]",
"nickName": "a-bot",
"botLocation": "/bin",
"botFileName": "EntelectChallenge2018-exe",
"botLanguage": "haskell",
"arguments": {
"coreCount": 2
}
}
```

You should also ensure that the executable is built with the
"-rtsopts" and "-threaded" compile time flags. These are supplied
under the "executables" section in "package.yaml". e.g.

```
executables:
EntelectChallenge2018-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
dependencies:
- EntelectChallenge2018
```
5 changes: 4 additions & 1 deletion starter-pack/starter-bots/haskell/bot.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"nickName": "Bill",
"botLocation": "/bin",
"botFileName": "EntelectChallenge2018-exe",
"botLanguage": "haskell"
"botLanguage": "haskell",
"arguments": {
"coreCount": 2
}
}
Binary file not shown.

0 comments on commit b956b2e

Please sign in to comment.