Skip to content

Commit

Permalink
The agent of 2015
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanogermano committed Oct 14, 2015
1 parent 78ce131 commit 0dc555d
Show file tree
Hide file tree
Showing 133 changed files with 19,267 additions and 1 deletion.
123 changes: 123 additions & 0 deletions INSTALLATION
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
Installation for Ubuntu 13.04 on a 64-bit machine
-------------------------------------------------

The included Makefile is intended to work for the latest Ubuntu release (13.04) on a 64-bit machine.

It provides commands to do a full installation (including the dlvhex solver we rely on) with root privileges:

make install

BEFORE issuing: Please check the aptitude install command in file install-hex.sh in order to avoid unintended interference with the exiting machine setup.
Also you might wish to skip install-opencv.sh (but in this case please ensure a compliant path to the java libraries, cf. the end of this file).

Moreover there are commands that can be used to update our agent software:

make plugin

for updating the dlvhex plugin our agent uses.

make agent

to install the java agent (without rebuilding class files and Client.jar),

or

make rebuild

to install the java agent rebuilding the class files and Client.jar (using ant).


Starting the agent:
-------------------

For starting the agent please issue

./client.sh <SERVER_IP>


Additional information:
-----------------------

Find below some further information that may be of use if the installation fails or when installing on a different linux platform.


1. Please verify/make sure that the following software packages and libraries are installed:

autoconf
automake
git-core
cmake
wget
pkg-config
libtool
libcurl4-openssl-dev (libcurl-devel)
libzip-dev(el)
libbz2-dev(el)
libboost-all-dev (boost 1.47)
bmagic (bitmagic)
ant
default-jdk

on Ubuntu we use:
apt-get install aptitude
aptitude install git-core g++ autoconf automake wget cmake pkg-config libtool libcurl4-openssl-dev libzip-dev libbz2-dev libboost-all-dev bmagic libbox2d-dev libopencv-dev python-opencv


2. Install DLV: By copying the appropriate binary (x86-64-linux-elf-static for 64 bit machines) from

http://www.dlvsystem.com/dlv/#1

- to the path (/usr/local/bin),
- making sure that it is executable on the system ("chmod +x" it!), and
- renaming it to `dlv' or creating a corresponding softlink to it.


3. Install dlvhex with dlv support: Building the latest version from the github

github.com/hexhex

as follows:

- cd /tmp
- git clone --recursive https://github.com/hexhex/core.git
- cd core
- ./bootstrap.sh
- ./configure
- make
- make install


4. Build opencv for java support (if not yet done, otherwise please ensure a compliant path to the java libraries, cf. the end of this file).

- git clone https://github.com/Itseez/opencv.git
- cd opencv
- git checkout 2.4
- cmake -DBUILD_SHARED_LIBS=OFF
- make
- make install


5. Build Box2D version 2.2.1:

- wget http://box2d.googlecode.com/files/Box2D_v2.2.1.zip
- unzip Box2D_v2.2.1.zip
- cd Box2D_v2.2.1/Box2D/Build
- cmake -D BOX2D_INSTALL=ON -D BOX2D_BUILD_SHARED=ON -D BOX2D_BUILD_STATIC=OFF ..
- make
- make install


6. For installing our agent we use script files (enclosed) that are prepared according to the following assumptions (on paths of the above installations). Please in case let us know any deviations of your installation.

- python2.7 installed to /usr/lib
(path we use /usr/lib/pymodules/python2.7)
- Box2D installed to /usr
(path we use /usr/lib)
- OpenCV installed to /usr/lib
(paths we use /usr/lib and /usr/local/share/OpenCV/java)
- dlvhex installed to /usr/local
(paths we use /usr/local/include and /usr/local/bin/dlvhex2)
- dlvhex plugin directory exists with write permissions:
/usr/local/lib/dlvhex/plugins


8 changes: 8 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Angry-HEX - an artificial player for Angry Birds based on declarative knowledge bases
Copyright (C) 2012-2015 Francesco Calimeri, Michael Fink, Stefano Germano, Andreas Humenberger, Giovambattista Ianni, Christoph Redl, Daria Stepanova, Andrea Tucci, Anton Wimmer. <[email protected]>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PYTHONLIBS=/usr/lib/pymodules/python2.7
OPENCVLIBS=/usr/local/share/OpenCV/java
OPENCVJAR=/usr/local/share/OpenCV/java
BOX2DLIBS=/usr/local/lib

.PHONY: all java plugin clean

all: java plugin

java:
ant -lib framework/external/:${PYTHONLIBS}/:${OPENCVJAR}/opencv-246.jar:${OPENCVLIBS}/:${BOX2DLIBS}/ -f build.xml jar

plugin:
make -C src/angrybirds-box2dplugin install

clean:
ant -f build.xml clean
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Angry-HEX
An artificial player for the popular video game Angry Birds
Angry-HEX is an artificial player for the popular video game Angry Birds; it participated in the 2013, 2014 and 2015 [Angry Birds AI Competition](http://aibirds.org).

The agent is based on declarative knowledge bases, and features a combination of traditional imperative programming and declarative programming that allows to achieve high flexibility in strategy design and knowledge modelling. In particular, it relies on the use of *Answer Set Programming* (*ASP*) and [*HEX programs*](http://www.kr.tuwien.ac.at/research/systems/dlvhex).

*Logic programming* is used for decision tasks such as which target to hit at each shot (*tactic gameplay*) or which level to play at each turn, and which way (*strategic gameplay*).
77 changes: 77 additions & 0 deletions angryhex.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

#-------------------------------------------------------------------------------

SCR_ANGRYHEX=dev.angryhex.sh
ZIP_ANGRYHEX=angryhex.zip
DIR_ANGRYHEX=angryhex
URL_ANGRYHEX=https://www.dropbox.com/s/svg2rofn3m7t03m/angryhex.zip

#-------------------------------------------------------------------------------

B=`tput bold`
N=`tput sgr0 tput rmul`
U=`tput smul`

usage() {
echo
echo "${B}SYNOPSIS${N}"
echo " ${B}./$(basename $0)${N} command [argument]"
echo
echo "${B}COMMANDS${N}"
echo
echo " ${B}install${N} [${U}all${N},dlv,dlvhex,box2d,agent]"
echo
echo " ${B}run${N}"
echo
echo " ${B}update${N}"
echo

exit $1
}

#-------------------------------------------------------------------------------

downloadAgent() {
rm -rf ${SCR_ANGRYHEX}
rm -rf ${ZIP_ANGRYHEX}
rm -rf ${DIR_ANGRYHEX}
apt-get -y install wget unzip
wget ${URL_ANGRYHEX} -O ${ZIP_ANGRYHEX}
unzip ${ZIP_ANGRYHEX}
chmod +x ${SCR_ANGRYHEX}
}

ensureAgent() {
if [ ! -e ${SCR_ANGRYHEX} ]; then
downloadAgent
fi
}

#-------------------------------------------------------------------------------

CMD=$1
ARG=$2

if [ -z $CMD ]; then
usage 1
elif [ -z $ARG ]; then
case $CMD in
"install") ARG=all ;;
esac
fi

case $CMD in
"install")
case $ARG in
"all" | "dlv" | "dlvhex" | "box2d" | "opencv" | "agent")
ensureAgent
./${SCR_ANGRYHEX} $CMD $ARG
;;
*) echo "Unknown argument $ARG" && usage 1
esac
;;
"update") downloadAgent && ./${SCR_ANGRYHEX} install all ;;
"run") ./${SCR_ANGRYHEX} run client ;;
*) echo "Invalid command: $CMD" && usage 1
esac
38 changes: 38 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project AB1.32 with Jar-in-Jar Loader">
<!--ANT 1.7 is required -->
<property name="lib.dir" value="external"/>

<path id="classpath">
<fileset dir="${lib.dir}" includes="**/"/>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<pathelement location="${lib.dir}"/>
</path>
<target name="clean">
<delete dir="src" includes = "**/*.class"/>
</target>

<target name="compile">
<mkdir dir="src"/>
<javac srcdir="src" destdir="src" classpathref="classpath"/>
</target>

<target name="jar" depends="compile">
<jar destfile="Client.jar">
<manifest>
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
<attribute name="Rsrc-Main-Class" value="angryhexclient.HexMainEntry"/>
<attribute name="Class-Path" value="."/>
<attribute name="Rsrc-Class-Path" value="./ external/Jama-1.0.2.jar external/json-simple-1.1.1.jar external/WebSocket.jar external/commons-codec-1.7.jar external/opencv-246.jar"/>
</manifest>
<zipfileset src="external/jar-in-jar-loader.zip"/>
<fileset dir="src/"/>
<zipfileset dir="external" includes="Jama-1.0.2.jar"/>
<zipfileset dir="external" includes="json-simple-1.1.1.jar"/>
<zipfileset dir="external" includes="WebSocket.jar"/>
<zipfileset dir="external" includes="commons-codec-1.7.jar"/>
<zipfileset dir="external" includes="opencv-246.jar"/>
</jar>
</target>
</project>

19 changes: 19 additions & 0 deletions config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
opencvnativepath=/usr/local/share/OpenCV/java/libopencv_java249.so
hexpath=dlvhex2
usedlv=yes
hexaditionalarguments=
calibrationmode=no
reasoningfilename=algorithm-new.dlv
reasoningWhitefilename=algorithm-white.dlv
speedRatio=1.6
speedRatio.red=1.9
speedRatio.yellow=1.4
speedRatio.blue=1.2
speedRatio.black=1.35
speedRatio.white=1.65
targetyoffset=0.50
teamID=27008
tournamentmode=true
debug=true
fastshootthreshold=512
shotmagnitude=10
19 changes: 19 additions & 0 deletions config.properties.tournament
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
opencvnativepath=/usr/local/share/OpenCV/java/libopencv_java249.so
hexpath=dlvhex2
usedlv=yes
hexaditionalarguments=
calibrationmode=no
reasoningfilename=algorithm-new.dlv
reasoningWhitefilename=algorithm-white.dlv
speedRatio=1.6
speedRatio.red=1.9
speedRatio.yellow=1.4
speedRatio.blue=1.2
speedRatio.black=1.35
speedRatio.white=1.65
targetyoffset=0.50
teamID=27008
tournamentmode=true
debug=false
fastshootthreshold=512
shotmagnitude=10
Loading

0 comments on commit 0dc555d

Please sign in to comment.