tags:

views:

411

answers:

4
+1  Q: 

online trading bot

Hi guys! I want to code a trading bot for Magic: The Gathering Online. This bot should wait until someone offers to trade, accept, look through the cards available from the other trader (the information is shown on screen), and perform other similar functions. I have several questions:

  1. How can it know that someone is offering a trade?
  2. How can it know that the other trader has some card (the informaion is stored in pictures)?

I just cannot imagine right now how to do it, I have no experience with it, until now I've been coding only console programs for my physics neсessities...

Thanks!

+3  A: 

I'd check the site for a developer's API link and some sample code.

No Refunds No Returns
+2  A: 

This answer is constructed from my comments.

What you are trying to do is hard, any way you try and do it.
Arguably the easiest way to do it is to totally mimic the user. So the application presses buttons, moves the mouse etc. The downside with this is that it is dependant on being able to recognise the screen.
This is easier if you can alter the games files as you can then just skin ( changing the image (texture)) the required cards to a single unique colour.
The major down side is you have to have the game as the top level window or have the game running in a virtual machine. Neither of which is ideal.

Another method is to read the processes memory. You may be able to find a list of memory locations, which would make things simpler, otherwise it involves a lot of hardwork, a debugger to deduce the memory addresses. It also helps (a lot) to be able to understand assembly.

The third method is to intercept the packets, and alter them. This is easier that the method above as it (at least for me) is easier to reverse engine the protocol as you have less information to deal with. It is just a matter of setting up a packet sniffer and preforming a action with one variable different (for example, the card) and comparing the differences.

The thing you need to check are that you are not breaking the EULA. I don't know how the game works, but most of the games I have come across have a EULA that prohibits (i.e. You get banned) doing any of the things I have mentioned.

Yacoby
Thanks, I now know how to start!
lhj7362
+5  A: 

First, you should note that some online games forbid bots, as they can give certain players unfair advantages. The MTGO Terms of Service do not seem to say anything about this, though they do put restrictions on anything that might negatively impact the service. They have also said that there is a possibility they will add an API in the future, so they don't seem to be against the idea of automation, but are not supporting it at the moment. Tread carefully here, but it looks like it should be OK to write a bot as long as it is not harmful or abusive. This is not legal advice, and it would be a good idea to ask the folks who run MTGO for permission. edit since I wrote this, it has been pointed out that there are lots of bots already, so there should be no problems writing bots.

Assuming that it is not forbidden by the terms of service, but they do not have an API, you will have to find a way to detect what's going on, and control the game automatically. There's a pretty good series of articles on writing poker bots, which has some good information on how to inject a DLL into an application, scrape the screen, and control the application. That might provide you with a starting point for doing this sort of thing.

You might also want to look for tools that other people have already written for doing this. It looks like there are several existing MTGO bots, but they all seem a bit sketchy (there have been some reports of them stealing passwords), so be careful there.

Brian Campbell
Wow. Your link is amazing! Thanks for your help!
lhj7362
A: 

Yacoby,

Your first suggestion of emulating the user movements and clicks is the way current trade bots are programmed for MTGO. This does not violate the EULA of Wizards of the Coast.

I believe your other 2 suggestions would violate the EULA.

I've done some research, and it looks like the majority of existing tradebots were created with AutoIT.

I'm a web designer, and have no idea how to get started on this. I do have a script that someone posted on the AutoIT site. If it is appropriate, i could post it here. This is my 1st time here, and i don't want to break any rules.

Anyone familiar w/ AutoIT?