Tuesday, April 17, 2012

Deck Editor and Schlemiel’s Algorithm

Years ago I wrote Forge’s first deck editor. It didn’t do anything fancy and you couldn’t search for anything. You really didn’t need to “search” much because Forge only had a couple hundred cards. I did work hard on the deck editor’s “sort” feature which let you sort cards by name, type (instant, creature, etc…), mana cost, power or toughness. (In my mind “sort” was good enough, so a separate search function wasn’t really needed.)

(From the upcoming set Avacyn Restored)

But there was a problem. As more cards were added, the deck editor’s sort function became slower and slower. At first I guessed that it was a problem with Java but it wasn’t. I thought I was implementing “sort” correctly and that was as fast as it could be. (Later, I learned the correct way to sort things using Java’s JTable.) This “slow sort” problem plagued Forge for a couple of years until the nice developers totally revamped the deck editor and now it is awesome. The new deck editor is actually fun to use because it works so well.

The old deck editor basically used a “n squared” solution that grows very quickly. For example, to sort 100 cards it might take 2 seconds, 200 cards - 10 seconds. But to sort 300 cards took 15 seconds. As you can see, the sort times grows fast very rapidly. For a funny explanation of the same thing, real Joel Spolsky’s explanation of Shlemiel the painter below.

(Begin Quote)

Shlemiel gets a job as a street painter, painting the dotted lines down the middle of the road. On the first day he takes a can of paint out to the road and finishes 300 yards of the road. "That's pretty good!" says his boss, "you're a fast worker!" and pays him a kopeck.

The next day Shlemiel only gets 150 yards done. "Well, that's not nearly as good as yesterday, but you're still a fast worker. 150 yards is respectable," and pays him a kopeck.

The next day Shlemiel paints 30 yards of the road. "Only 30!" shouts his boss. "That's unacceptable! On the first day you did ten times that much work! What's going on?"

"I can't help it," says Shlemiel. "Every day I get farther and farther away from the paint can!"

(End Quote)

Basically it is hard to know if you have the “right solution” when you code. A program can be fine until you add that one feature that just breaks everything. Life and computer programming are both comprises. The perfect solution does not exist.

Excelsior,
mtgrares

p.s.
Joel Spolsky is great and each article has more computer info than my 4 years in college studying computers. Read his blog and be enlightened. For those people who can follow some short code segments in C, Joel talks more about C and Shlemiel here.

Joel Spolsky’s book’s “Joel on Software” and “More Joel on Software” are the best things that I have ever read. They are more readable (and edited) than his blog.

Joel Spolsky’s Blog

Tuesday, April 10, 2012

New Version

Forge has 500 new cards for a total grand total of 10,524 cards. Over 10,000 cards is just insanely crazy but it is more fun than a 100 pound ice cream.


Some of the new cards include:

Mirror Strike (3W, Instant) – “All combat damage that would be dealt to you this turn by target unblocked creature is dealt to its controller instead.” The card sounds cool and should win a few games.

Pulse of the Forge (1RR, Instant) – “Pulse of the Forge deals 4 damage to target player. Then if that player has more life than you, return Pulse of the Forge to its owner's hand.” The “pulse cycle” is great and repeatedly dealing damage is fabulous. This card has “card advantage” written all over it.

Fist of Suns (3, Artifact) – Let’s you pay WUBRG for any card. This card screams screams, “Please build a deck around me.”

Gomazoa (2U, 0/3, Creature) – “Defender, flying and Tap: Put Gomazoa and each creature it's blocking on top of their owners' libraries, then those players shuffle their libraries.” A blue creature that just won’t die and lets you skip combat phases, cool.

The extra crispy avenger,
mtgrares

-----------------------------------------------------------------
Downloads

Forge version 1.2.6

Download (45 MB) – Windows and Linux

Download (46 MB) – Mac

Forge requires Java

To uncompress bz2 files you can use Winzip or the free, open source program 7z.

----------------------------------------------------------------

Many people helped with this version. A special thank you goes out to them.

Agetian
Catatafish
Chris H
Dave
Doublestrike
Fnoed
Friar Sol
Jeff Wadsworth
Marc
Max mtg
SBeauchamp
Skiera
Slapshot5
Sloth
Squee1968
WompWomp
Xitax

Monday, April 2, 2012

Playtesting and Forge

A while ago a reader mentioned that he used Forge to playtest new decks. I thought it was an interesting comment because I never considered that idea. Forge has around 75% of all of the cards in standard (75% is just a guess) but I see how it could be a good playtesting tool. Any cards that Forge did not have, you use the developer menu and change mana and life points as needed.

(Dark Ascension token)

Forge is a good playtesting tool because you can see a variety of game situations. It is hard to look at a card at face value and say, “This card is good” or “This card is bad”. Your experience with other similar cards may make you think that a card is good or bad but without using that specific card in a game, you cannot be sure. I have built decks around cards that I thought were great but the playtesting showed me the truth.

Forge lets you test and build decks very quickly which helps you playtest many different decks. Since the AI is very basic, you can play whole games in 5 or 10 minutes. A real life 1-on-1 game would usually take 30 minutes or longer.

On a side note, Magic has a very influential pro-tour and there could be a market for a program that lets players playtest decks. The application could be stupid and only a “virtual tabletop” that did not understand the rules. The application would allow users to make decisions for both players and at the most basic level the application would not need any AI. A simple AI like Forge would not be too difficult to code but it would need to be able to use all of the cards in standard.

Just a humble guy,
mtgrares

Monday, March 26, 2012

Should the AI Bluff When Attacking?

Bluffing is not a major part of Magic but it is still exists. By “bluffing” I mean attacking as if you held a card like Giant Growth. You can even bluff with cards like Shock by attacking your opponent’s 4/4 with your lowly 2/2. Usually I would wait until the 4/4 attacks and then block it with your 2/2 and kill it with Shock but every game as different specific tactics and situations.


“When should you bluff?” I tend to never bluff when attacking because I never know if the AI will block or not. Obviously if I think that a bluff would win me the game, I will try it. Otherwise I might only bluff with small creatures if I had plenty of other creatures on the board.

The AI is interesting because it plays multiple matches and it could keep track of the number of times that a bluff failed or succeeded. The AI could bluff more or less as needed. In order for the AI to act like a human player the bluff should work 50 to 75 percent of the time (although this is just a rough guess). The AI could bluff all of the time but that would be very stupid. (The goal of the AI is to make it act like a human player and force you to make hard combat decisions.)

Right now the AI never bluffs on purpose. The AI may bluff accidentally because combat is very complicated (but very fun). I am just happy that the AI can play instants during combat, so players are surprised some of the time. For many years I attacked like a madman because I knew the AI never used instants during combat. The AI can also use Counterspell which is always stuns me and makes me momentarily panic.

Feedback Question:
When (and if) should you bluff when playing Magic?

--mtgrares

p.s.
Some games like poker are almost exclusively based on bluffing, which explains why I am so bad at it.

Because of my programming background I never have to ask myself, “Will computers ever evolve, like in the Terminator movies?” because computers are really, really stupid. A computer is just a very fast calculator.

Saturday, March 17, 2012

Nothing New

I usually have a fabulous article to post every Monday but sometimes the well runs dry, aka. I have no idea in the whole universe about what to write. Usually ideas just randomly float into my head, which I think are gold, but other people may have (very) different opinions.

Read some Dork Tower and have a great week.

Monday, March 12, 2012

Cooperation and Why Forge Doesn’t Have Flame Wars

Forge is one big collaboration with people from different countries and languages. All of these people are united in their love for Magic: The Gathering. I am guessing that Forge has had at least 100 people submit Java code to the project and at least 50 have made substantial contributions.


I presume most people add a card or two that they really wanted. Forge is a random collection of cards, so you can never be sure which cards Forge has or doesn’t have. Most people also have a favorite card, or three, or a card that they enjoy using. Even if the card is usually crappy but has the chance to win the game once in a while. Crappy cards aren’t crappy 100% of the time, so it is ok for Forge to incorporate them.

Forge also does not have forum flame wars. Everybody acts like an adult (which is rare of the internet) and avoids the usual, “I’m right and you’re wrong” arguments that are never ending. This subject reminds me of an old joke about two guys who both moved. One guy says, “My new neighbors are nice but my old neighbors were nice also.” The other guy says, “I hate my new neighbors because they are just like my old neighbors.” Basically if you are nice, people will respond nicely and vice versa if you are angry.

All open source software is a testament to cooperation and the joy of working with your fellow man. Other types of media such as books and movies do not lend themselves to collaboration as well as software (for whatever reason). And many types of open source projects are not videogames. Maybe amateur videogames tend to be not very good or maybe open source videogames need more of a singular vision to be successful, who knows?

I am still surprised that people want to work on Forge because it was started by an amateur programmer using an old PC. Truthfully I started Forge because it was cheaper for me to code new cards versus buying them and I still get a thrill when I use rares like Darksteel Colossus, Elvish Piper, and Wrath of God because I never owned them in real life.

I am also happy that Forge’s simple AI does not detract from the fun factor. Making that early decision was a tough one.

--mtgrares

Monday, March 5, 2012

New Version – Dark Ascension and 10,000+ cards

Forge is awesome. It has 154 Dark Ascension cards and a total of 10,382 cards, which is crazy. The new user interface looks great and when you start Forge, it has a nice, modern menu (which is shown below).


And here is a screenshot of the actual game. (Click to see a larger image.)


To get to the deck editor, choose Utilities from the left-hand menu and then you will see the Deck Editor. Most people will also want to use the Import Pictures (also found in Utilities) which imports cards pictures from a previous version of Forge. You can use the Import Pictures feature if you don’t want to move the files yourself.

I do not have much to add, so here is what Chris. H. posted:

(Begin Quote)
We have reached a new milestone. All Modern legal sets are at least 80% complete and all Extended legal sets are at least 90% complete.

A number of bugs were found and fixed. The mana pool bug which caused crash reports was fixed. We also have a performance fix relating to static abilities. These reported bugs were also fixed: Avatar index bug, Quest opponent refresh, Avatar switch bug and Win streak (stats) not refreshing.

The UI has a few new features including the option to pick an avatars from a collection of pictures. This can be accessed from the Settings -> Avatars tab.

The organizational structure of the /res/decks/ folder has been improved and we now have these four subdirectories:

/decks/constructed/
/decks/cube/
/decks/draft/
/decks/sealed/

You can now buy PreCon decks, Starter packs, Tournament packs and Fat packs from the quest mode card shop.

The Forge archive includes a readme.txt file and we ask that you spend a few minutes reading this file as it contains some information that may prove usefull. We do tend to update this file at times and you should quickly read this file and look for new information for each and every new release. Thank you.

We have changed the archival format used for the Forge distributions from ".zip" to ".tar.bz2". There are utilities for Windows, Mac OS and the various *nix's that can be used to decompress these ".tar.bz2" archives. We recommend that you decompress the Forge archive into a new and unused folder.

Some people use the Windows application 7zip. This utility can be found at http://www.7-zip.org/download.html. Mac users can double click on the archive and the application Archive Utility will launch and extract the archive. Mac users do not need to download a separate utility.

(End Quote)

Just another Pro-Tour wannabee,
mtgrares

------------------------------------------------------------------
Downloads

forge-1.2.4.tar.bz2 (33.2 MB, at cardforge.org) - for Windows, Linux

forge-1.2.4-osx.tar.bz2 (34.2 MB, at cardforge.org) - for Mac

Forge Forum – in case you need to ask questions or confess your addiction to Forge :)

Download Java - Forge requires Java 6
------------------------------------------------------------------

p.s.
Many people helped with this version. A special thank you goes out to them. (Attempted to list names alphabetically):

Agetian
ArsenalNut
Chris H
Corwin72
Dave
Doublestrike
Friar Sol
Hellfish
Jeff Wadsworth
Marc
Max mtg
NicoAndCo
Rob Cashwalker
Roujin
Slapshot5
Sloth
Squee1968
Timmermac
WompWomp

p.p.s.
Magic has some great artwork. Here are a few Dark Ascension cards that Forge has.