Monday, May 18, 2009

Version 2 Goals

MTG Forge version 2 is just gigantic so I have been trying to figure out what is the most important feature that version 2 will have that version 1 doesn’t? The two main contenders are more cards and a better AI. Hopefully version 2 will have both more cards and a better AI but sometimes you have to make difficult choices.

Having more cards is a fairly simple. Cards could be programmed using text instead of Java. The targeting and resolve code could be separated into separate blocks of code and used over and over again. (Currently much of the card code is copy and pasted.)

Implementing a better AI could be at odds with having more cards. Improving the AI might hinder other parts of the program since the AI influences everything. Having a better AI might mean having fewer cards. (And when I say “fewer cards” I mean having the current number of cards which is about 1,600 instead of 5,000.)

The AI is really interesting so I’m going to work on it first. I’m going to get a few cards working and see how much better I can make the AI. I know the AI could really improve the basic creature combat but I’m not sure how well the AI will handle combat in a full-blown game of Magic with activated abilities and instants.

I’m hoping that the AI will be very competitive and will help you improve as a Magic player. (Let’s also hope that I can find a good Java implementation of the alpha-beta algorithm.)

p.s.
I tried using Google for about 15 minutes to find a good Java alpha-beta algorithm but I didn't have any luck. If you have any ideas please let me know, thanks.

p.s.s.
I think I found a good implementation by downloading the source code from a Java algorithm book. I would like to find an optimized version though.

6 comments:

moxdev said...

Alpha-beta itself is very simple (couple of methods). The root of the problem is enumerating/simulating efficiently the different choices a player can make. This part is entirely dependent on your code, not the alpha-beta code.

I know, for example, that for alpha-beta, enumeration is more efficient if you can find a way to "try" better choices first. Trying better choices first allows the algorithm to often cutoff earlier and "try" less bad choices. That means having some intelligence too in the method that computes what choices to try and in what order. It then becomes a balance issue between completely random enumeration (faster to enumerate, more choices to try) and completely ordered enumeration (slower to enumerate, less choices to try).

Rob Cashwalker said...

I think the more important goal for v2 is a stable platform for the whole structure of magic. In other words, all phases and stops need to be accessible by both the AI and the human. The cards and zones need to behave consistently. Static effects need to be handled appropriately, not a constant flurry of adding and removing a +1/+1 bonus from Glorious Anthem.... Any hacks that have been added to work around the v1 limitations need to be addressed by v2 such that we don't have to work around them.

If the AI is still a little dumb, and cards still need explicit code, but v2 is a stable platform that allowed the rules to work properly, then the AI can be fixed later, the text parsing can be perfected later.

Think of how many people have been turned off of the program, and maybe magic on general, if this is their introduction to it, when the computer does dumb things, or when they can't respond to attackers.... Gando has walked away from the game a number of times (or so he says on the forum) because of the stupid parts of the program.

Eliminate the stupid stuff, plan for as many interactions between cards, zones, abilities, effects, etc as possible to make sure that v2 is a stable base. Then and only then should you worry about AI, text parsing or GUI stuff.

Anonymous said...

AI is much more important than cards. There is already enough cards, but often times when new cards are added they only make it even easier to beat the AI. It is rare that the AI gets an improvement, and it needs it!

FranAvalon said...

Hi, Forge.

I hope that you can do a good AI for the game. As anonymous saids a good Ai is more important than a Ton of cards (Botarena is a good example of it)

I also agree with Rob, do a good engine, then add a good AI and the app will be awesome.

Go ahead!!!

Regards

Fran

buy magic cards said...

Nice post. I like the alpha-beta enumeration topic.

Forge said...

I'm trying to use alpha-beta for just simple creature combat, the creatures don't have any abilities, and it is hard enough. I wanted the algorithm to search very deep but the options become enormous with just 2 attackers and 3 blockers, the options become exponential which is very bad. I'll probably write more about this next week.

Version 2 has alot of good code written for it and maybe it should just be an extension of version 1, as in v2 just cleans up the ideas of v1. I know I have made v2 too big but it is hard to know what to cut.

(I know I need to fix CardFactory, lol. 30,000 lines is too long for a single method, ha.)