-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|540|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Misc


 
JL235
Created : 22 February 2007
Edited : 19 April 2007
Language : Monkey

Inselkampf Bot



I wondered if it were possible to make a bot for Inselkampf, and 2 hours later here it is. Now logs in itself, and finds the session id to be used. Current version posted is for use with a Ruby terminal as it has print outs of buildings it makes and fails to make.

It's essentially more of a building schedular then a bot, but I have tested it's long life usage, the idea definitely works. Progress is being made to improve functionality.

The bot also creates a file for storing the last building built. Currently the AI only builds Gold Mines, Stone Quarry and Lumber Mills in rotation. I plan to add AI so it will find out other stats (so it will build a storage building when you've built loads of gold mines), maybe draw them to a GUI or at least the terminal, and allow greater control.

Thanks to HoboBen and Flying_Cucco for their help in developing a way to log-in.

Enjoy!


 

Comments


Friday, 23 February 2007, 04:53
power mousey
hey DD,

can you make me one for my penguin
in the Penguin Club.

SO I can round up Puffles easier in the Pet Shop.
I took a job at the Pet Shop and Puffles are like Tribbles. They eat and reproduce fast. They are mischevos
and move quickly. As a pet shop employee I have 32 seconds to round up as many Puffles as I can back into the ranch box. I can play as many times as I like.
I earn coins so I buy clothes and food for me
Penguin. I'm Powermousey penguin.

the web site is at:

www.miniclip.com

I registered and joined. Then I joined into
the Penguin Club.

cheers,
power penguin mousey
Sunday, 25 February 2007, 00:09
JL235
No, not for those sorts of games mousey.

Updated!
Sunday, 25 February 2007, 02:31
power mousey
no Puffles for you!

yeah, I know. I first joined
cause it was kinda cutsey and cool.
Think of Hamtaro in the Antartica. haha

After awhile, it got kind too sugary sweet
and nauseating for my taste. I'd rather be in
one of those fantasy online games and as either
a Knight or a Monk...not one of those
robed and porridge eating figures chanting in
a monastery kind

cheers
power mousey
Thursday, 08 March 2007, 23:52
querty
I just tried this as a test to see if it would work, and it did.

I crtl-C to stop it, and now it won't work anymore.

I get:

> ruby gamebot.ruby
gamebot.ruby:30:in `initialize': Log-in failed: no session ID (RuntimeError)
from gamebot.ruby:142


But I can still log in with my web browser.
Friday, 09 March 2007, 06:56
JL235
First, it's nice to see people trying this. I am planning to improve it, and clean it up. Namely with how it retrieves the urls. I'm also not at home over the weekend so I cannot test and try to re-create your bug.

The error you are recieving, is because it is not returning the instance variable '@session_id', and if that happens I have it throw the exception that you are recieving. The following method attempts to get the session id:

The 'get_session_id' method is run in the 'run' method below, where if it fails to recieve the session id it will throw the exception.


So, why is it not returning the session id? I have no real answer, but make sure it is not being blocked (although if it worked the first time, I doubt it). Also check if your username and password are correct. If they are not, I'd presume it would still return information, only it cannot find the session id in the data that is recieved, so it does not return anything.

I also presume you have Ruby: so you could try manually running the code for only getting the session id in IRB, line by line yourself, to see specifically what is returned and what happens.

When I get back, I will try to have it check specifically if it failed to log-in and so throw an exception with a more accurate error.
Friday, 09 March 2007, 08:10
querty
ok, I manually paste:

https://www.inselkampf.com/index.php?controller=sessions&action=create&player=MYUSERNAME&password=MYPASSWORD&world=1

in replaceing MYUSERNAME and MYPASSWORD, and the website works in my browser, returning the URL:

https://213.203.194.123/us/1/index.php?s=SESSIONNUMBER

the ruby program still won't work, I doubled checked the username and password



So stupid, I accidently put a line break in the middle of a line of code, DOH! Works now, thanks.
Friday, 09 March 2007, 08:20
JL235
Try replacing the url of the line in the 'get_session_id' method: with your url (above) containing your username and password. Don't remove or change any of the ' HTTP/1.0 \n\n' section, or any text after. Just the url.

It shouldn't make a difference, but it will help indicate that the program (internally) is communicating to the correct url.

Also try re-copying from my code above. If the regular expressions I wrote in there had been alrered for some reason, then it would be that it is not reading the returned page correctly (unless they have actually changed the layout of the text returned, in which case my code is now broken).

And, is it definately not being blocked? Have you checked the Windows and all other firewalls?

|edit| I didn't see that last line of yours. Was that an edit? |edit|
Friday, 09 March 2007, 12:43
querty
Oops yeah, it was an edit. Another thing you might want to do, add a little bit of randomness to the script. The server might automatically detect someone logging in exactly every 30 minutes.
Saturday, 24 March 2007, 15:18
JL235
My Inselkampf bot has been a complete success!

I will be taking the bot off-line (for good) once the island has reached lv 20 Stone Quarry, Gold Mine and Lumber Mill, and so completing the test conditions I set out for it.

As I said above, this is made purely as proof of concept and I in no way use bots for personal gain.
Monday, 26 March 2007, 03:08
power mousey
I'm glad to hear some good news.

My island has been ravaged and destroyed.
I refused to join this alliance called the House of Pain.

I experienced the pain!
And I was doing so well too.

Yet, I don't like to play multiplayer
games that much. I'm more used to strategy and
role playing games just on the computer
and single player too.

island madness everybody,
power mousey
Monday, 26 March 2007, 10:09
HoboBen
Ouch!

Just wait till I get a fleet Mr. Mousey. I'll avenge ya
Monday, 26 March 2007, 10:27
TheMadProff
What language is this in?, and could it be ported into blitz, as i want to make a Gui app for inselkampf, which is 3d....
Monday, 26 March 2007, 10:36
JL235
This is written in Ruby. Flying Cucco posted a Blitz version, however I have not used it. His is also not a port of my code, but his own original implementation.

You could add a GUI to my code with several free GUI libraries. With Ruby the most common are Fox and the eye-bleeding TK. However I personally would recommend getting Java and use JRuby to run my code on the Java VM. Then you can make the GUI with the excellent Swing library.
Monday, 26 March 2007, 11:59
TheMadProff
When i say make a Gui, i mean add graphics to represent your island, and allow you to walk around it. E.g. when you want to build a boat, you have to go to the harbour, go inot a building, and ask a guy to build a boat (or something like that)

Also, i can't seem to find this link, is this just me being stupid?

Thanks
TheMadProff
Monday, 26 March 2007, 12:43
JL235
Flying Cucco's is here. To make graphics for mine you could use SDL or Rubygames. Rubygames is slightly simpler then SDL, but I'd say the only real improvement is the layout of the documentation and it's removed many options for you, which cleans up the code a little.
Monday, 26 March 2007, 14:27
power mousey
yeahhhhh!!!

thanks bro.
that'll show em.
Cannonball their House down!!
Pack and smack em back with the pain.

true!!

cheers
power mousey
Monday, 26 March 2007, 15:29
TheMadProff
Thanks DiabolisDevil and Flying Cucco. That'll really help

And thats a nice idea Mousey, using the outcome of a battle, it could play a little animation accordingly...

Thanks
TheMadProff
Monday, 26 March 2007, 15:41
power mousey
hey,

you're welcome.


cheers
power mousey
Wednesday, 28 March 2007, 12:12
JL235
Mousey, what are the house of pain's proper Inselkampf alliance name for lookup? I'd be interested to see their stats.
Wednesday, 28 March 2007, 14:29
flying_cucco
More to the point, what's your ik name, mousey?
Wednesday, 28 March 2007, 19:22
power mousey
its okay.
I took the pain!

I needed the kick in the butt.
To remind myself that multiplayer
games are not my cup of tea.

I just hope you all kick their butts.
If you like and want too.
Yet, you guys enjoy the game and experience
the island madness.

btw, I got a standard letter from
the owner and administrator from the place.
Stating that I haven't logged on past these
3 days and if I don't log on within 30 days
my account will be closed. What the fricks!!??
I replied back and told him that should it
matter to you that if I log on or not!??
And I also told him to go ahead and cancel
my account. Cause no worries nor concerns
with this.
Besides I have other things to be concerned
and worried about. And also other interests too.
Back into weightlifting, programming, and a ferw other
interests too.
Yet, my reply bounced back cause its a no-reply type of
message. sheesh!!! anyway, its cool everybody.

thank you,
and cheers for this

eeehyepp!!,
powerful mousey
Wednesday, 28 March 2007, 19:51
JL235
I'd still like to know the Inselkampf ID for the House of Pain.
Wednesday, 28 March 2007, 20:09
power mousey
it don't matter.