Skip to content

Commit 0f84c08

Browse files
ssoloffron-murhammer
authored andcommittedSep 15, 2018
Add sample scripts for running a bot (#4046)
1 parent 1347981 commit 0f84c08

File tree

4 files changed

+266
-0
lines changed

4 files changed

+266
-0
lines changed
 

‎.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text=auto
2+
*.bat text eol=crlf

‎game-headless/build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.apache.tools.ant.filters.FixCrLfFilter
2+
import org.apache.tools.ant.filters.ReplaceTokens
3+
14
plugins {
25
id 'application'
36
id 'com.github.johnrengelman.shadow' version '2.0.4'
@@ -27,6 +30,11 @@ task headlessGameArchive(type: Zip, group: 'release', dependsOn: shadowJar) {
2730
from(project(':game-core').file('assets')) {
2831
into 'assets'
2932
}
33+
from file('scripts/run_bot')
34+
from(file('scripts/run_bot.bat')) {
35+
filter(ReplaceTokens, tokens: [version: version])
36+
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance("crlf")) // workaround for https://github.com/gradle/gradle/issues/1151
37+
}
3038
from(shadowJar.outputs) {
3139
into 'bin'
3240
}

‎game-headless/scripts/run_bot

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/bash
2+
#
3+
# This is a sample script for running a TripleA bot on a Unix-like system.
4+
#
5+
# THIS SCRIPT MAY NOT RUN CORRECTLY UNLESS YOU CUSTOMIZE SOME OF THE VARIABLES
6+
# BELOW! Please read each variable description carefully and modify them, if
7+
# appropriate.
8+
#
9+
# To run this script, change to the directory in which you unpacked the
10+
# headless game server archive, and type "./run_bot".
11+
#
12+
13+
###############################################################################
14+
# VARIABLES THAT YOU MAY CUSTOMIZE BEGIN HERE
15+
###############################################################################
16+
17+
#
18+
# The folder from which the bot will load game maps.
19+
#
20+
# The default value is the folder in which the TripleA game client stores
21+
# maps that it downloads. Under normal circumstances, you will not have to
22+
# change this variable. However, if you customized the settings in your
23+
# TripleA client to use a different maps folder, you should change this
24+
# variable to refer to the same location.
25+
#
26+
readonly MAPS_FOLDER="$HOME/triplea/downloadedMaps"
27+
28+
#
29+
# The port on which the bot will listen for connections. This port must be
30+
# reachable from the Internet, so you may have to configure your firewall
31+
# appropriately.
32+
#
33+
# Under normal circumstances, you will not have to change this variable.
34+
# However, if you choose to run multiple bots on your system, you need to
35+
# select a different available port for each bot.
36+
#
37+
readonly BOT_PORT=3300
38+
39+
#
40+
# The name of the bot as displayed in the lobby. Each bot must have a unique
41+
# name.
42+
#
43+
# The default value uses a combination of your username and the local port
44+
# you selected above on which the bot will run. Under normal circumstances,
45+
# you will not have to change this variable.
46+
#
47+
readonly BOT_NAME="Bot_${USER}_${BOT_PORT}"
48+
49+
#
50+
# The password used to secure access to games running on your bot. Users
51+
# attempting to start a new game or connect to an existing game on your bot
52+
# will be prompted for this password. If the password is an empty string,
53+
# the user will not be prompted, and any lobby user will be able to use your
54+
# bot.
55+
#
56+
# The default value is an empty password. You should change this to a
57+
# non-empty string if you do not want arbitrary users to use your bot. For
58+
# example, you may wish to run a private game for you and some friends. In
59+
# that case, set the password to a non-empty string and communicate it to
60+
# your friends in some manner (e.g. via email).
61+
#
62+
readonly BOT_PASSWORD=
63+
64+
#
65+
# The hostname of the lobby to which the bot will connect.
66+
#
67+
# The default value is the hostname for the TripleA community's public lobby.
68+
# Under normal circumstances, you will not have to change this variable.
69+
#
70+
readonly LOBBY_HOST=lobby.triplea-game.org
71+
72+
#
73+
# The port on which the lobby to which the bot will connect listens for
74+
# connections.
75+
#
76+
# The default value is the port for the TripleA community's public lobby.
77+
# Under normal circumstances, you will not have to change this variable.
78+
#
79+
readonly LOBBY_PORT=3304
80+
81+
#
82+
# The email address at which you can be contacted. Lobby moderators will
83+
# communicate with you using this email address if they notice problems with
84+
# your bot, or if they need to perform remote maintenance on your bot (e.g.
85+
# to shut down your bot).
86+
#
87+
# The default value is meaningless. IT IS STRONGLY RECOMMENDED THAT YOU
88+
# CHANGE THIS VARIABLE TO A VALID EMAIL ADDRESS THAT YOU CONTROL.
89+
#
90+
readonly LOBBY_SUPPORT_EMAIL="${USER}@localhost.localdomain"
91+
92+
#
93+
# The password used to secure remote maintenance of your bot. A lobby
94+
# moderator who wishes to perform remote maintenance on your bot will be
95+
# required to enter this password in order to complete any maintenance
96+
# action. If the password is an empty string, a lobby moderator will be able
97+
# to perform remote maintenance on your bot without your permission.
98+
#
99+
# The default value is an empty password. You should change this to a
100+
# non-empty string if you do not want lobby moderators to interfere with the
101+
# operation of your bot. Note that a lobby moderator that cannot perform
102+
# remote maintenance of your bot may choose to boot your bot from the lobby.
103+
#
104+
readonly LOBBY_SUPPORT_PASSWORD=
105+
106+
###############################################################################
107+
# VARIABLES THAT YOU MAY CUSTOMIZE END HERE
108+
#
109+
# DO NOT MODIFY ANYTHING BELOW THIS LINE!
110+
###############################################################################
111+
112+
java \
113+
-server \
114+
-Xmx256M \
115+
-Djava.awt.headless=true \
116+
-jar bin/triplea-game-headless-*-all.jar \
117+
-Ptriplea.game= \
118+
-Ptriplea.lobby.game.comments=automated_host \
119+
-Ptriplea.lobby.game.hostedBy="$BOT_NAME" \
120+
-Ptriplea.lobby.game.supportEmail="$LOBBY_SUPPORT_EMAIL" \
121+
-Ptriplea.lobby.game.supportPassword="$LOBBY_SUPPORT_PASSWORD" \
122+
-Ptriplea.lobby.host="$LOBBY_HOST" \
123+
-Ptriplea.lobby.port="$LOBBY_PORT" \
124+
-Ptriplea.map.folder="$MAPS_FOLDER" \
125+
-Ptriplea.name="$BOT_NAME" \
126+
-Ptriplea.port="$BOT_PORT" \
127+
-Ptriplea.server=true \
128+
-Ptriplea.server.password="$BOT_PASSWORD"

‎game-headless/scripts/run_bot.bat

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
@ECHO OFF
2+
REM
3+
REM This is a sample batch file for running a TripleA bot on a Windows system.
4+
REM
5+
REM THIS SCRIPT MAY NOT RUN CORRECTLY UNLESS YOU CUSTOMIZE SOME OF THE
6+
REM VARIABLES BELOW! Please read each variable description carefully and
7+
REM modify them, if appropriate.
8+
REM
9+
REM To run this script, change to the directory in which you unpacked the
10+
REM headless game server archive, and type "run_bot.bat".
11+
REM
12+
13+
REM ###########################################################################
14+
REM VARIABLES THAT YOU MAY CUSTOMIZE BEGIN HERE
15+
REM ###########################################################################
16+
17+
REM
18+
REM The folder from which the bot will load game maps.
19+
REM
20+
REM The default value is the folder in which the TripleA game client stores
21+
REM maps that it downloads. Under normal circumstances, you will not have to
22+
REM change this variable. However, if you customized the settings in your
23+
REM TripleA client to use a different maps folder, you should change this
24+
REM variable to refer to the same location.
25+
REM
26+
SET MAPS_FOLDER=%USERPROFILE%\triplea\downloadedMaps
27+
28+
REM
29+
REM The port on which the bot will listen for connections. This port must be
30+
REM reachable from the Internet, so you may have to configure your firewall
31+
REM appropriately.
32+
REM
33+
REM Under normal circumstances, you will not have to change this variable.
34+
REM However, if you choose to run multiple bots on your system, you need to
35+
REM select a different available port for each bot.
36+
REM
37+
SET BOT_PORT=3300
38+
39+
REM
40+
REM The name of the bot as displayed in the lobby. Each bot must have a unique
41+
REM name.
42+
REM
43+
REM The default value uses a combination of your username and the local port
44+
REM you selected above on which the bot will run. Under normal circumstances,
45+
REM you will not have to change this variable.
46+
REM
47+
SET BOT_NAME=Bot_%USERNAME%_%BOT_PORT%
48+
49+
REM
50+
REM The password used to secure access to games running on your bot. Users
51+
REM attempting to start a new game or connect to an existing game on your bot
52+
REM will be prompted for this password. If the password is an empty string,
53+
REM the user will not be prompted, and any lobby user will be able to use your
54+
REM bot.
55+
REM
56+
REM The default value is an empty password. You should change this to a
57+
REM non-empty string if you do not want arbitrary users to use your bot. For
58+
REM example, you may wish to run a private game for you and some friends. In
59+
REM that case, set the password to a non-empty string and communicate it to
60+
REM your friends in some manner (e.g. via email).
61+
REM
62+
SET BOT_PASSWORD=
63+
64+
REM
65+
REM The hostname of the lobby to which the bot will connect.
66+
REM
67+
REM The default value is the hostname for the TripleA community's public lobby.
68+
REM Under normal circumstances, you will not have to change this variable.
69+
REM
70+
SET LOBBY_HOST=lobby.triplea-game.org
71+
72+
REM
73+
REM The port on which the lobby to which the bot will connect listens for
74+
REM connections.
75+
REM
76+
REM The default value is the port for the TripleA community's public lobby.
77+
REM Under normal circumstances, you will not have to change this variable.
78+
REM
79+
SET LOBBY_PORT=3304
80+
81+
REM
82+
REM The email address at which you can be contacted. Lobby moderators will
83+
REM communicate with you using this email address if they notice problems with
84+
REM your bot, or if they need to perform remote maintenance on your bot (e.g.
85+
REM to shut down your bot).
86+
REM
87+
REM The default value is meaningless. IT IS STRONGLY RECOMMENDED THAT YOU
88+
REM CHANGE THIS VARIABLE TO A VALID EMAIL ADDRESS THAT YOU CONTROL.
89+
REM
90+
SET LOBBY_SUPPORT_EMAIL=%USERNAME%@localhost.localdomain
91+
92+
REM
93+
REM The password used to secure remote maintenance of your bot. A lobby
94+
REM moderator who wishes to perform remote maintenance on your bot will be
95+
REM required to enter this password in order to complete any maintenance
96+
REM action. If the password is an empty string, a lobby moderator will be able
97+
REM to perform remote maintenance on your bot without your permission.
98+
REM
99+
REM The default value is an empty password. You should change this to a
100+
REM non-empty string if you do not want lobby moderators to interfere with the
101+
REM operation of your bot. Note that a lobby moderator that cannot perform
102+
REM remote maintenance of your bot may choose to boot your bot from the lobby.
103+
REM
104+
SET LOBBY_SUPPORT_PASSWORD=
105+
106+
REM ###########################################################################
107+
REM VARIABLES THAT YOU MAY CUSTOMIZE END HERE
108+
REM
109+
REM DO NOT MODIFY ANYTHING BELOW THIS LINE!
110+
REM ###########################################################################
111+
112+
java^
113+
-server^
114+
-Xmx256M^
115+
-Djava.awt.headless=true^
116+
-jar bin\triplea-game-headless-@version@-all.jar^
117+
-Ptriplea.game=^
118+
-Ptriplea.lobby.game.comments=automated_host^
119+
-Ptriplea.lobby.game.hostedBy=%BOT_NAME%^
120+
-Ptriplea.lobby.game.supportEmail=%LOBBY_SUPPORT_EMAIL%^
121+
-Ptriplea.lobby.game.supportPassword=%LOBBY_SUPPORT_PASSWORD%^
122+
-Ptriplea.lobby.host=%LOBBY_HOST%^
123+
-Ptriplea.lobby.port=%LOBBY_PORT%^
124+
-Ptriplea.map.folder="%MAPS_FOLDER%"^
125+
-Ptriplea.name=%BOT_NAME%^
126+
-Ptriplea.port=%BOT_PORT%^
127+
-Ptriplea.server=true^
128+
-Ptriplea.server.password=%BOT_PASSWORD%

0 commit comments

Comments
 (0)
Please sign in to comment.