Please Help me get Started!

170 views
Skip to first unread message

Daniel Bahamon

unread,
Aug 7, 2009, 12:10:21 AM8/7/09
to Mario Competition
Hello, first of all, thanks for this contest, I think it is a great
idea and hopefully we can come up with a nice AI algorithm for mario,

Unfortunatelly I have zero knowledge of Java, so I have no idea what
to do, I downloaded eclipse, but I don't see a file to open or
anything...

Fortunatelly I program in C++ and C# so it shouldn't be hard to learn
java, but could anyone please help me doing the following...

1) Setting up the project so that I can compile it.

2) showing me how I could play the game and perhaps look at some of
the basic AI's.


Thanks for the help in advance,

Good Luck to everyone!

Jesse

unread,
Aug 7, 2009, 12:27:54 AM8/7/09
to Mario Competition
Ok, I'll go step by step up to setting up to compilation. You must
have a JDK to do this so I'm just going to assume you have one. First
open eclipse and pick a workspace. This can be any empty folder. Then
right click on the package explorer work area and create a new
project, or alternatively create a new project using the pull down
menus. Name it whatever.

Next using right clicking or the pull down menus find the import
option. A window comes up. Select Filesystem under general for the
import type. Find the src file from the marioai folder you downloaded
from the site here. Select the ch and wox folders and import them. Now
drag them into your src folder in your project if they aren't there by
default.

Next right click on your project in the package explorer area and
create a new folder. Name it Libs. Find the jdom.jar file in the
marioai folder and drag it or import it into this folder. I just drag
from the filesystem to the eclipse window and it works. Then right
click on that jdom.jar in eclipse and select "add to build path" under
build path in the right click menu.

Next under the src folder in the project exlorer find the Play.java
file under ch.idsia.scenarios. Right click it select "run as" -> "java
application" this will result in a window with lots of red text appear
showing errors. Now we get to the fun part of moving resources.

In your actual filesystem find your workspace and project folder. In
that find the bin folder. also find the img folder in the main
subfolder in marioai.

move all the items from the img folder into /bin/ch/idsia/mario/engine

There are like 5 other work around for this but they all involve
changing the code and quite frankly you just want it up and running. I
would suggest mirroring all those files in the src directory tree as
well. That is putting them all in, /src/ch/idsia/mario/engine . If
you do do that then go to eclipse and select your project and press F5
to refresh the project with the filesystem. Then again Right click
Play.java->"run as"->"java application" and you are ready to go.

.. yeah its a lot, but I like eclipse a lot and this project wasn't
made to work with it easily.

To change command line arguments click on the arrow next to the play
button and select run configurations, there you can change the command
line arguments, which is necessary to select the class you want the
game to use for the AI to control mario

By default it uses a human ai. controls are left right down (don't
press up it causes an error last i checked) s is jump a is speed/
fireball

best of luck

ferr

unread,
Aug 7, 2009, 12:33:48 AM8/7/09
to Mario Competition
I'm in the same situation, I'm a C++/C# programmer. This is what I
did (after a couple of hours of screwing around):
- In Eclipse, go to File -> New -> Java Project
- Select the Create from Existing Project radio button and browse to
the root marioai directory
- If your setup is like mine, you will need to copy tiles.dat from the
src/ch/idsia/mario/engine/level/ folder to the src/ch/idsia/mario/
engine/ folder. Different IDEs handle resources differently, I'm
assuming, and something gets loose in Eclipse versus what the original
devs used.

- You should now see a lot of tan-ish colored boxes with crosses in
the Package Explorer on the left. These are similar to namespaces
in .Net, and if you drill down within them, you will see .java files,
which I guess are equivalent to .cs files.
- To get started with seeing pixels on your screen, go to the
ch.idsia.scenarios library on the package explorer, expand it. Right
click on Play.java and select Run As -> Java Application. This should
allow you to play Mario with human controls.
- The next thing you can do, for sake of just diving in, I guess, is
modify the Play.java file (double click Play.java to see the source),
and set the controller variable (the Agent type) to one of the pre-set
agent classes,
i.e. controller = RegisterableAgent.load
("ch.idsia.ai.agents.ai.ForwardAgent");
RegisterableAgent.registerAgent (controller);
Make sure you do this before the options.SetAgent(controller); line.
You should then be able to run Play.java with pretty dumb AI. Feel
free to check out the ForwardAgent source under
ch.idsia.ai.agents.ai.ForwardAgent.java.

- After that, read through the rest of the source files.

Daniel Bahamon

unread,
Aug 7, 2009, 2:08:17 AM8/7/09
to Mario Competition
Wow Jesse, Thank you very much, you really helped me a lot, it works
perfectly, and honestly I would have never been able to do half of the
steps by myself. Thank you very much, and by the way, your
instructions where perfect. anyways, I wish you good luck on the
project.

Thanks

-Daniel Bahamon

Arthur

unread,
Aug 8, 2009, 10:02:08 AM8/8/09
to Mario Competition
Thanks Jesse for this explanation! Thanks to your help I have the
HumanKeyboardAgent and the ForwardAgent working.

However when I launch the java ch.idsia.scenarios.Evolve, I get a
NullPointerException at the very beginning.

In Evolve, a SimpleMLPAgent is created with
Evolvable initial = new SimpleMLPAgent();

(This set initial.name=null)

And then calls:
options.setAgent((Agent)initial);

This setAgent calls RegistrableAgent.getAgentByName() that has the
following code:
public static Agent getAgentByName(String agentName)
{
// There is only one case possible;
Agent ret = AgentsPool.agentsHashMap.get(agentName);
if (ret == null)
ret = AgentsPool.agentsHashMap.get(agentName.split(":")
[0]);
return ret;
}

In this piece of code, agentName and ret are = null.
This does not seems to be normal because calling agentName.split(":")
gives a NullPointerException.

I do not know a lot of Java, maybe I have a configuration problem, b/c
it does not seems to be possible at this point of the code to have an
agent name = null.

Any help would be very welcomed.

Thanks,
Arthur

Terlisimo

unread,
Aug 9, 2009, 1:28:22 PM8/9/09
to Mario Competition
In Evolve.java, the initial agent is hard-coded to SimpleMLPAgent.

The problem with SimpleMLPAgent() is that its name returns null
whereas it should return SimpleMLPAgent.

in SimpleMLPAgent.java find:
private String name;

and replace with:
private String name = "SimpleMLPAgent";

This will make this agent work.

To run some other agent, in Evolve.java find:
Evolvable initial = new SimpleMLPAgent();

..and replace with the agent of your choice. Command line arguments
should take care of this but something's broken, looking into it...

Reply all
Reply to author
Forward
0 new messages