Wednesday, July 22, 2009

Computer Programming Is Boring

Much of computer programming is as interesting as watching paint dry. Yes, sometimes programming seems like a videogame where you are given constantly evolving challenges and it feels great to conquer them but then programming turns on you and spits out an onslaught of errors.

Last night I changed the zone events. Previously one event handled when a card was added or removed but I split the event into two events, add and remove. This is relatively boring and even last night I wished that I could be programming something fun but the culmination of all of these tiny decisions influences the whole project.

Currently MTG Forge stores all of the decks in one file. This makes reading and writing decks very easy. It also makes uploading and downloading decks harder. It also makes it much harder to download a whole bunch of decks at one time. (Currently MTG Forge does support uploading or downloading individual decks, the deck editor menu calls these operations export and import.) It would also be nice if each deck had an optional comment section that describes the deck but I didn't think about this and MTG Forge doesn't support it.

Computer programming is like building a house of cards, it takes a lot of work and patience. Programming takes a ton of boring code in order to do anything interesting. Programming Magic cards is interesting, programming everything else isn't.

12 comments:

willow said...

I sort of agree. I'm always overly excited when I can code new cards. Now my engine has way more cards than needed, and the AI can't compete against everything the Human player can come up with. The game is becoming unbalanced and I don't like it :(
But sometimes a painful work is the door to lots of more cool features, so there's always a meaning to the code you write ;)

Xuelynom said...

Hi ! I just wanted to ask if I can borrow some of your GUI code ?
I've build a magic engine for myself, but it's only AI vs AI for testing, and i've found yours. With all respect due, i find your way to handle cards somehow... complicated...

the CardFactory file is very hard to understand. In my project, cards have no code, just properties, so it's much easier to add one, such as this :

cm = new CardModel("Goblin Artillery", "Flavortext", CardType.Creature, 1, 3, "1RR", Rarity.Uncommon);
cm.addSubType(CardSubType.Goblin);
cm.addSubType(CardSubType.Warrior);
cm.addAbility(ActivatedAbility.getInstance(null, true, Thaum.getInstance(ThaumCible.getInstance(
Keyword.Creature,
true), Mecanique.Damage, "2"), Thaum.getInstance(
ThaumCible.getInstance(Keyword.Owner, false),
Mecanique.Damage,
"3")));

or this :

cm = new CardModel("Doom Blade", "flavortext", CardType.Sorcery, 0, 0, "1B", Rarity.Common);
ThaumCible tc = ThaumCible.getInstance(Keyword.Creature, true);
tc.addProperty(Keyword.NonBlack);
cm.addAbility(SpellAbility.getInstance(Thaum.getInstance(
tc,
Mecanique.Destroy,
null)));

With this system, cards are just numb objects, it's the DuelHandler class that handles the CIP, the restrictions on the targets and such.

I hope I don't sound too boasting...

Anonymous said...

Great to see another engine around :) (et un français en plus)

willow said...

Welcome Xuelynom. Are the French in love with MTG or is it just because WotC can't sue us for programming? :D

Xuelynom said...

Haha zetes français aussi ?

I guess it's because I want to play Magic but I've got no time to search for cards or players, and mtgo is way too expensive, the old duel is way too old, and the new duel is way too much on xbox and not on pc, and not-enough-cards and judging by the critics, there is no deck editor.

And I guess hasbro / wotc have no problem with suing french :D

Anonymous said...

Your work is amazing, I know it can seem slow (and it probably is) but what you're doing is huge for people like me. As long as you bring in a few more new top/popular cards every so often (cloudgoat ranger/windbrisk/goldmeadow *fingers crossed*) I'll be a happy camper whatever you decide to do with this project.

Forge said...

I enjoy programming more than most people and most of the time it is fun. Some of the hardest times is debugging, fixing a problem that you think you know the solution but then it doesn't work, so you have to try to understand the problem again.

Xuelynom, yes you can use as much (or little) of my code that you want to. :-)

I agree with you that CardFactory is horrible but it still makes me laugh. A 10,000 line method is just insane, I submitted it to the Guinness World Records for the world's longest method.

Xuelynom said...

haha

Today i rewrite my card code, so there will be OracleCard (for the rules) and Card (an instance of the card in a match) that points to an OracleCard. And i'm moving the rarity and expansion out of OracleCard since it can have more than one exp/rarity...

Anyway, do you think that more than 1 developper can agree on the "game" interface so one can make IA battling against each other ? the "Game" object would give all informations, inplay, stack, library and the IA would give the move (pass priority or do something)...

Silly Freak said...

If you're at it in the moment, i would suggest to make 3 layers: oracle card, printing and card. so, you could really delegate all the static content from the card and isolate only the game state.

Anonymous said...

Forge: Amazing piece of software I found here, thanks a lot, mate.

Xuelynom: is your program out in the open?
If so, can you provide a link?

Xuelynom said...

Not at the moment, I'm struggling with maven, spring, wicket to write some gui, but I think it's not a good idea to write a magic engine with a wicket (or struts or another web application framework). It sounds like writing a 3d engine with excel macros... For tests I will just develop a gatherer-like, and then a java applet (but putting all the cards and engine code in the applet will be too much so I'll have to write some webservice to do this)

Well if you want a short answer, it would be : "look at Mtg forge, its a working magic engine" :D

Forge said...

MTG Forge has the rules implemented throughout the program. Version 2 will hopefully have all of the rules in one big object MagicEngine, short for Magic Rules Engine.

Technically I can play my AI against another Magic AI's the same way you would play two chess AI's against each other. When one chess program would make a move in the other chess program.