Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .classpath

This file was deleted.

13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
17 changes: 0 additions & 17 deletions .project

This file was deleted.

62 changes: 44 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
warlight2-engine
============
================

This is the game engine for Warlight AI Challenge 2 at theaigames.com

This version of our Warlight AI Challenge 2 engine has been set up for local use, for your own convenience. Note that this does *not* include the map generator and the visualizer.

To compile (Windows, untested):
Usage
-----

cd [project folder]
dir /b /s *.java>sources.txt
md classes
javac -d classes @sources.txt -cp lib/java-json.jar
del sources.txt
### Download

To compile (Linux):
You can download the latest version of the Warlight2 Engine here: [warlight2-engine-1.0.0.jar](https://github.com/theaigames/warlight2-engine/releases/download/v1.0.0/warlight2-engine-1.0.0.jar). Find the all downloads (including older versions) on the [release page](https://github.com/theaigames/warlight2-engine/releases).

cd [project folder]
mkdir bin/
javac -sourcepath src/ -d bin/ -cp lib/java-json.jar `find src/ -name '*.java' -regex '^[./A-Za-z0-9]*$'`

To run:
#### Running the jar

cd [project folder]
java -cp lib/java-json.jar:bin com.theaigames.game.warlight2.Warlight2 [map file] [your bot1] [your bot2] 2>err.txt 1>out.txt
The downloaded `.jar` file is easily run on any OS with the Java Virtual Machine (JVM) installed with the following:

[map file] is a file that contains a string representation of the map that the game will use. An example is included in this repository called "example-map.txt". For other maps, go to any Warlight AI Challenge 2 game on theaigames.com and add "/map" to the end of the URL and copy that text to a file.
```
java -jar warlight2-engine-1.0.0.jar [map file] [your bot1] [your bot2] 2>err.txt 1>out.txt
```

[your bot1] and [your bot2] could be any command for running a bot process. For instance "java -cp /home/dev/starterbot/bin/ main.BotStarter" or "node /home/user/bot/Bot.js"
- `[map file]` is a file that contains a string representation of the map that the game will use. An example is included in this repository called `example-map.txt`. For other maps, go to any Warlight AI Challenge 2 game on theaigames.com and add `/map` to the end of the URL and copy that text to a file.
- `[your bot1]` and `[your bot2]` could be any command for running a bot process. For instance `java -cp /home/dev/starterbot/bin/ main.BotStarter` or `node /home/user/bot/Bot.js`

Errors will be logged to err.txt, output dump will be logged to out.txt.
Errors will be logged to `err.txt`, output dump will be logged to `out.txt`.

### Build from source

#### Getting the source

If you have `git` installed the easiest way to get the source is to clone the repository:

```
git clone https://github.com/theaigames/warlight2-engine
```

Alternatively, you can download the repository as a [zip](https://github.com/theaigames/warlight2-engine/archive/master.zip) or [tar.gz](https://github.com/theaigames/warlight2-engine/archive/master.tar.gz) and extract using the appropriate tools for your OS.

#### Compiling the source

Compilation is made simple regardless of platform through [maven](https://maven.apache.org). As long as you have [maven installed](https://maven.apache.org/download.cgi), you should be able to build it with the following:

```
cd warlight2-engine
mvn build
```

#### Running compiled jar

After building from source, the output file will be in the `target` folder. To run you need to do the following command:

```
java -jar target/warlight2-engine-1.0.0-jar-with-dependencies.jar [map file] [your bot1] [your bot2] 2>err.txt 1>out.txt
```

For information on the run arguments, see [Run Section](#running-the-jar)
Binary file removed lib/java-json.jar
Binary file not shown.
57 changes: 57 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.theaigames</groupId>
<artifactId>warlight2-engine</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20141113</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.theaigames.game.warlight2.Warlight2</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.theaigames.game.warlight2.Warlight2</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>