Wicked Strategery

Where servers serve, routers route, and configulators configulate

jSettlers Bash Script

Written by: Doug Jenkinson

Article

I don't know about the rest of you, but I love to play Settlers of Catan. I downloaded a copy of jSettlers, and whipped up this quick Bash script to run it.

It's pretty simple, but it takes care of starting three computer players, as well as cleaning up after you quit. You'll need to have jSettlers and all its prerequisites installed in order for this work correctly.

Here's the code for it (some word-wrapping may occur), or you can download the script and an icon.

Source Code

catan.sh

#! /bin/bash
 
JSettlersDir="/usr/games/jsettlers-1.0.6" #Change this for your path to jSettlers.
NUM_PLAYERS=3
 
if ! [ -e /var/run/mysqld/mysqld.sock ]; then
  sudo mysqld &
fi
 
java -jar ${JSettlersDir}/JSettlersServer.jar 8880 10 root "" &
server_proc_id=$!
echo "Server Process ID: $server_proc_id"
 
sleep 5s
 
for ((num=1; num<=NUM_PLAYERS; num++)); do
  java -cp ${JSettlersDir}/JSettlersServer.jar soc.robot.SOCRobotClient localhost 8880 "Computer"${num} "" &
  CATANID[$num]=$!
  echo "Computer${num} Process ID: ${CATANID[$num]}"
done
 
java -jar ${JSettlersDir}/JSettlers.jar localhost 8880
 
for ((num=1; num<=NUM_PLAYERS; num++)); do
  echo "Cleaning up: killing ${CATANID[$num]}"
  kill ${CATANID[$num]};
done
echo "Cleaning up: killing $server_proc_id"; kill $server_proc_id;
exit 0

Downloads

You can download the script and an icon.

To Do:

Currently, this script uses a poor choice for authentication to the server for the computer players. Eventually, I'll add some sort of dialog boxes to prompt for that.


Metadata


Revisions

  • v1.1 (27 Aug 2005) - Code section added, no longer limited to a download.
  • v1.0 (25 Aug 2005) - Article published.

About the Author

Doug Jenkinson is an avid technology aficionado and Software Engineer with Hyland Software, Inc. / entrepreneur in Copley, OH.

Read More...

Linquistory

"The Wørd" of the Night: Truthiness, courtesy of Stephen Colbert

Wikiality

Breadcrumbs

Impressions of Scrum

Pre-compiling ASP.NET

DragonStar Galaxy Map

Really Simple Syndication at Last!

jSettlers Bash Script

Personal Links

LinkedIn

Google Profile

My del.icio.us

twitter

My flickr

My ClaimID

Projects

twitlbl

Site Updates

I've added some spiffy new features to my site. You can read all about them in the changelog.

Internet Quote

"Yeah man, I tell ya what, man. That dang ol' Internet, man. You just go on there and point and click. Talk about W-W-dot-W-com. An' lotsa nekkid chicks on there, man. Click. Click. Click. Click. Click. It's real easy, man." - Boomhauer, King of the Hill

Feeds

RSS OPML