Simple Unix Eclipse setup for Scalatron

69 views
Skip to first unread message

Ting Zhou

unread,
Jul 2, 2014, 1:26:56 AM7/2/14
to scal...@googlegroups.com

I've been preparing Scalatron for a upcoming course, and developed this method to work with Scalatron in Eclipse without too much digging into the complicated stuff. That said, there's still no guarantee that what I describe below will be at a comfortable difficulty level. Also this is my first post in any Google Groups, so please tolerate me if this is not how Google Groups is intended to be used.

0. Install Scala IDE. This is actually an optional step, but why use Eclipse in the first place if you don't plan on using the dedicated tools, right?
(It is optional because you should be able to use 'External Tools' in most perspectives, like C/C++)
0. Get a copy of Scalatron's bin folder in some directory you feel comfortable with. For a workshop, somewhere with write access for most users probably; otherwise, suit yourself. 

1. Get the short bash code below, (credit goes, without doubt, to Lauri Lehmijoki; I've modified it to fit the purpose), put the content into a text file and name it 'build'.
#!/bin/bash
# For compiling a Scalatron bot.
# Assumes that the MANIFEST.MF file is located in the current directory.
# Author: Lauri Lehmijoki - http://lauri.lehmijoki.net
set -e

BUILD_DIR=.build
rm -rf $BUILD_DIR && mkdir $BUILD_DIR

echo "Building the Scalatron bot..."

scalac -sourcepath users/YOURUSERNAME/src -d $BUILD_DIR `find users/YOURUSERNAME/src -name *.scala`

cd $BUILD_DIR

# MANIFEST.MF can be an empty file, but it has to exist
jar -cfm bots/YOURUSERNAME/ScalatronBot.jar ../MANIFEST.MF *.*

cd ..

echo "...ready!"
echo "Produced bots/YOURUSERNAME/ScalatronBot.jar"
These code will find your source code file(s), compile them, and put them in the folder that Scalatron will be using. You also need to make sure that
your scalatron user account name should be the same that you put up there in YOURUSERNAME. You can always go back and modify it though.

2. Create a Scala project in eclipse. In the actual folder of the project, create a 'bots' directory and a 'users' directory. Put the build file on the same level as them, and create another file called 'MANIFEST.MF' here as well.

The file structure should look like this:

- Workspace/
    - Scalatron/
        - bots/ (empty folder)
        - users/ (empty folder)
        - build
        - MANIFEST.MF

3. In Eclipse, find the "Start button with a toolbox underneath" button, click the triangle, choose 'External Tools Configurations'.

4. Click 'Program', then right-click and choose 'New'. Name this one 'Build Bot'. In 'Location', use 'Browse Workspace' to find it; for 'Working Directory', choose the project top level folder. Apply.

5. Add another configuration, this time name it 'Run Bot'. In 'Location', find your Scalatron.jar file, probably with 'Browse File System' this time. For 'Arguments', put in:
-plugins /PATH/TO/THE/BOTS/FOLDER -users /PATH/TO/THE/USERS/FOLDER
then apply and done.
(you can of course customize the above to add more options, and create even more run config with different settings)

6. Try and debug. If you are working on your own, this should suffice; First time running, you should be able to just 'Run Bot' (also from that button) first. Since there are no existing bots, this will allow you to use the web IDE to create account (use the name you put in the build file, remember?) and allow it to create subfolders in bots and users. After this point, you can just go to the eclipse project, edit your Bot.scala file in the users/YOURNAMEHERE/src folder, and use 'Build Bot' to compile. If you already have source code, you should be able to just put your source code in users/YOURNAMEHERE/src folder and do build directly. If you are working with more complicated situations, you can always use variables provided by eclipse.

Admittedly this is not elegant, but at least you get better syntax highlighting, as well as the ability to turn off the helpful parentheses-closer. Some major drawbacks include
- web IDE still pops up when you run bot.
- no debugging. I doubt there's much to do about it though - you cannot really debug the running plugin, except maybe in the terminal, which is why eclipse is somewhat better.
- no changing parameters on the fly.

Let me know what you think! Or if this does not work, and we might figure out why and how to fix it. I've tested on my school lab computers, although not extensively. I'm attaching screenshots here.



P.S. On an unrelated note, I got an 20 round freestyle average of 3,589,911. Do I submit it here?


Marco Shaw

unread,
Jul 2, 2014, 8:17:08 AM7/2/14
to scal...@googlegroups.com
Google groups is great for information sharing. 

I'm interested in what you've put together when I review it quickly. 

I think the Scalatron project is sort of "sleeping" and there isn't a lot of activity on this list, Twitter or the github web site. 

Still, I think this is an interesting way to try to learn Scala and looks like a lot of effort was put into this (it even has an IDE!). 

Marco
--
You received this message because you are subscribed to the Google Groups "scalatron" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatron+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ting Zhou

unread,
Jul 2, 2014, 9:30:50 AM7/2/14
to scal...@googlegroups.com
It is true and a pity that there are not a lot of people posting stuff actively. But still, if someone wakes up and happen to want to use Eclipse, this might help them a bit and that's good enough for me.

And yeah, Scalatron sure gave me quite some interesting time with Scala. And exploding bots XD.

Marco Shaw

unread,
Jul 2, 2014, 10:54:24 AM7/2/14
to scal...@googlegroups.com

I agree that sharing information is awesome/great.  For example, I think I discovered that Java 8 will not work.

 
If you have anything more to share, please do.  I'm a complete novice to Scala/Akka, so I'm anxious to learn/try stuff to get better at Scala.
 
Marco
Reply all
Reply to author
Forward
0 new messages