Monday, September 6, 2010

Musings on Forge 2 - Less is More

I've been thinking a little about Forge 2. One of the problems when designing the "2nd version" is that you have a tendency to add every little feature that you thought of while doing version 1. This tendency is completely wrong. Less is more. Programming takes time, so you should try to maximize the final result, which means cutting features.

At first I wanted version 2 to have a better user interface (UI). The UI is what every person sees and uses. The UI affects the user's "happiness index", how hard is it to use this program? My decision is that version 2 will have the same UI, so I can work on other features. (Of course the user interface will be separate from the rules engine and could be improved later.)

After saying "no" to the UI, I decided the single most important feature of version 2 would be a smarter, nastier computer opponent. The current AI is basically a knee-jerk reaction and the computer doesn't think ahead. Hopefully in version 2 the computer will think ahead and it will be awesome.

At first the AI will only attack, block, and play cards/abilities during his main phases. This restriction is here because it is realistic. I will encounter many unforeseeable problems while coding an improved but scaled-back AI. After I have the AI working, I can make it more complete and able to respond to spells/abilities on the stack and play abilities/instants during combat.

Programming a Magic AI is hard and for proof here is an excerpt from the Moxdev blog which aims to implement Magic in C#.

[Begin Quote]

!Health Warning!

Attempting to program AIs for MTG can be dangerous to your health. If you suffer from any symptom, stop reading immediately. Symptoms may include

--Extreme fatigue, with insomnia
--Seeing min-max trees in your cereals
--Sudden urge to stop programming forever
--Starting to talk to your AI
--AI programming is not recommended for pregnant women and children under 5.

[End Quote]

That post really made me laugh because coding a good AI can be very frustrating. If you set you expectations too high, you will never get your program up and running (because you will be too exasperated and just quit). The only perfect computer program, is one that never gets written.

The good news is that even if the AI only does basic actions like attacking/blocking/playing cards during his main phases, the AI will be better because it will be thinking ahead. Hopefully the AI should be able to make good decisions like using two Shocks to kill a flying 4/4, something the current AI cannot do.

And don't worry, if I get a few cards working in Forge 2, I will post it (and probably brag on myself). My goal isn't to develop the greatest Magic program in the universe and then keep it a secret.

On a side note, people seem to want the convenience of playing Forge in the browser because you don't have download anything, so I'm keeping that in mind. Forge 2.0 will come in two flavors: browser version and a downloadable, offline version.

See you next Monday,
Same Bat-Time,
Same Bat-Channel

--mtgrares

8 comments:

Unknown said...

It's great to know that you are already working on a new version of Forge! I play it since almost 6 months and find it really enjoyable and fun! Since you are working on a new version, have you ever consider to make forge a game that can be played throu internet with other people???

P.D: Sorry for my english. I'm from Argentina!

Silly Freak said...

One of your sentences seems very important to me, but you should not restrict it to UI:

Of course the user interface will be separate from the rules engine and could be improved later.

I myself try to separate the different aspects, like core engine, UI and AI very strictly. It has the disadvantage that every step is a little slower, but it's less likely to encounter a situation where you can't step forward any more.

For example, Laterna Magica has no AI yet, but when it does, it won't be restricted to a single algorithm and could even use special AIs for combo decks. The downside (if you want to see it as such) is that the cards themselves can't contain AI code because there's not just one.

Forge said...

Forge is designed to allow you to play against the computer. Incantus lets you play against other people on the Internet.

Forge said...

"Of course the user interface will be separate from the rules engine and could be improved later."

Dividing a program into smaller parts reduces the complexity and you should design each part (or subsystem) to be as separate as possible.

Technically "Dividing a program into smaller parts reduces the complexity" is false. The overall complexity is the same but if each part is completely separate that makes understanding the individual parts much easier.

Forge said...

My best guess is a card like Shock will have two methods: one that gets all legal targets (including your own creatures) and one that gets 3 or 4 "good targets". This would decrease the amount of searching but it might miss an obscure but good play.

I don't know how useful this idea might be and it can only be tested once Forge 2 has a few cards.

Unknown said...

Everyone loves features. Give us all you can think of with a beautifully comprehensive preference panel so folks can turn things on and off as they please. i'd love to turn off many of the rounds when i'm playing solo.

also i don't know how many people use on mac but i do. i don't know if that affects any ideas you have for version 2 of this wonderful program i thank you for.

Steve said...

Please consider having Forge be able to play against itself with different decks. I've long been hoping for this, and I think your rewrite might be a great place to try it.

The reason for Forge playing against itself is the idea of later expanding that capability to creating a gauntlet.

Magic players are notorious for wanting to try a deck against many of the metagame decks, and having an ability to have a list of decks for a single deck to play hundreds (or thousands) of games against, would give some idea of performance of certain decks.

Granted, the results depend entirely on how the AI plays, but it would be a great opportunity to help in this area of study.

Forge said...

Right now the AI for Magic programs like Forge and Wagic isn't good enough for real analysis but Wagic supports AI versus AI.

Forge's AI basically just done a "legal move" and no in-depth forecasting is done.