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.






Monday, February 27, 2012

Dark Ascension is Coming

I thought about posting a new version of Forge today but the most recently released version on the forums does not download the new Dark Ascension card pictures, and I know that everybody loves to use and abuse new cards. Hopefully a new version of Forge will be posted to the forums on March 2nd but that is only a tentative date and it may change. The next version will have at least 149 cards from Dark Ascension.

The Forge team is very happy to announce that Forge now supports more than 10,000 cards, which is a major milestone. Here is the announcement that they posted on the forum. (This relates to the 02-03 version which does not download the Dark Ascension card pictures.)

{begin quote}

The Forge team is very proud to announce that more than 10,000 cards are now available for play! This is an impressive amount, particularly considering that as of October 2011, the official game has produced 12,246 unique cards.

Rares, the creator of Forge, generously shared his work as an open source project about five years ago. Since then, dozens of people have contributed their talents to evolve the codebase to the point it's reached today: a game engine that can successfully juggle 10^5 10^4 unique cards, available for free.

The honor of writing the 10,000th card has gone to an unnamed hero, which is suitable since it's these brave code warriors that make the game what it is. A well-deserved thanks to anyone who has volunteered their time to script, test, maintain, report, code, suggest, debug, design, or in any way contribute to this project.

A special thanks in particular to the CCGH web site and its administrators for providing us with the Forge forum, and to the unsung team of people who quietly maintain the servers which assist this project in one fashion or another.

With this in mind, we move onward and upward. Enjoy your next game of Forge!

{end quote}

I sarcastically asked, “What will the developers do once Forge supports every card in existence?” and someone replied, “Start debugging”. That was a joke but it was very funny. Although I know Forge can be buggy, it is also awesome. (I have heard much the same thing about Elder Scrolls V: Skyrim, awesome but buggy.)

Dark Ascension
I presume most people know about magiccards.info but I will mention it anyways. Magiccards.info is similar to Gatherer but has very, high-quality scans of Magic cards. You can view a visual spoiler for Dark Ascension at magicards.info here.

If you want to download all of the card pictures and peruse them offline, link (26 MB).

Deck Forum
Forge has a separate forum just for decks and you can upload and download a ton of new/different decks. The “New Quest Deck” post allows people to post decks and then adds them to the list of opponents for Forge’s quest mode. You can also download a different set of files for sealed and draft, which is called a “cube”. Another person posted the top 8 decks from the Grand Prix Lincoln 2012 as well as 256 decks from “Building on a Budget” which is posted weekly on dailymtg.com.

That is about it. Have a grape (great) week :)

-mtgrares

p.s.
I have started to get into miniature wargaming, which is pretty cool. I love making strategic decisions and talk about a genre that really needs a good videogame. Awhile ago I played a ton of Advance Wars for Gameboy Advance. While it isn't really a “wargame”, it is still an excellent game.

Tuesday, February 21, 2012

Magic: The Gathering For iPhone and Android

(I don't have much to say this week.)

The Wagic project lets you play Magic on your iPhone or Android.

Wagic works on Windows, Linux, the nokia N900 (maemo), the Nokia N9 (meego), Android (tablets and phones), iOS(iPhone/iPad/iPad2) and the Sony PSP (Wagic does not require you to hack your PSP).

Wagic Link

Saturday, February 11, 2012

Browsing Forge’s Source Code – Part Deux

Similar to the line that Morpheus said in the Matrix, “Some things changes and some things don’t.” Much of Forge has been changed and improved but the core foundation is the same. Card objects, hold one or more SpellAbility objects. Today I will be looking through the “creature cardfactory” that handles the weird, oddball abilities that are not scripted. (Scripting only cares about multiple cards with the same ability.)

The creature cardfactory is relatively small, only 2,600 lines including blank lines, and handles around 69 creatures. (You can view the Java source code here.) The first creature is one that I recognize “Force of Savagery”. It is an enigmatic 8/0 creature that only costs 2G. Obviously the key is that it needs to be pumped up by Glorious Anthem or similar cards.

The code below is just for the AI and checks to see if Glorious Anthem or its green cousin Gaea's Anthem is in play. The problem is that checking for specific cards is that new cards are added/created all of the time.
if (cardName.equals("Force of Savagery")) 
{
  final SpellAbility spell = new SpellPermanent(card) 
  {
    public boolean canPlayAI() 
    {
      final CardList list = AllZone.getComputerPlayer().
          getCardsIn(Zone.Battlefield);

      return list.containsName("Glorious Anthem") 
          || list.containsName("Gaea's Anthem");
    }
  };

  card.clearFirstSpell();
  card.addSpellAbility(spell);
}

Drekavac is the next card that I recognize. I originally added it but the code has been updated as Forge has changed. Drekavac (2B, 3/3) the drawback is that you must discard a non-creature card. In the code that tells the AI not to play this card I see this comment.

I could never get the AI to work correctly, it always played the same card 2 or 3 times

This takes me back because that is my original comment. Now I know how to fix the problem but the AI probably should not play cards with a drawback anyways, since it cannot tell when the drawback is tactically prudent or not. I always liked using Drekavac for some reason.

The next card is Phylactery Lich. It is a pretty cool rare that gets you a 5/5 indestructible creature for only BBB if you own an artifact. The code here only deals with letting the player choose an artifact. Elsewhere, where static or state effects are checked, the code checks to see if the artifact with the phylactery counter is destroyed. The AI for this card is simple and just makes a “sanity check” to see if the computer has an artifact on the battlefield.
public boolean canPlayAI() 
{
return (!AllZone.getComputerPlayer()
  .getCardsIn(Zone.Battlefield)
  .getType("Artifact")
  .isEmpty() 
  
  && 
  
  AllZone.getZoneOf(this.getSourceCard()).
  is(Constant.Zone.Hand));
}
Sky Swallower is another card that I coded back in the day. Sky Swallower is another situational card that the AI plays badly. I thought it might be a good card but I don’t think I have ever won a game with it. I know it could win a game. In the code there is my original comment that has not been updated.

// TODO - this needs to be targeted

Technically Sky Swallower’s ability is targeted and Forge does not target the opponent because it makes the code a few lines shorter. I know that Magic has a few cards that give protection to a player but years ago, I knew that Forge did not have any of those cards. I used Forge’s excellent deck editor to search for cards that give protection to players and I could not find any but I could be wrong.

While these were just small snippets of code, it felt good to look at actual source code.

Huzzah,
mtgrares

p.s.
“Part deux” is taken from one of my favorite movies, “Hots Shots: Part Deux”. Deux is French for “two”.

Tuesday, February 7, 2012

Just a Bit of Humor

I can't think of anything to write about, so here is something to distract you. Dork Tower is great. The picture is a little small but you can see it full size here.

Monday, January 30, 2012

Browsing Forge’s Source Code

Source code is great. Similar to a the relation between a cooking recipe and a cake, source code “creates” a program. I like the think of source code as the secret internal guts of a program that you never get to see. I have not looked at Forge’s source code in a long, long time, so I’m just going to randomly pursue it. (You can view the source code yourself here.)


(A class is just a bunch of related Java statements.)

I’m always drawn to the class Card but I see the class ColorChanger so I’m going to look at that first. ColorChanger is very basic but it lets you change the color of any card. ColorChanger also uses a time stamp to keep track of the color changes. Below is the most important method. I understand most of the code but bIncrease is interesting because it changes the time stamp. I think the time stamp is important because two cards may change all of the other card colors in the game but the card that is played last takes priority and “overrides” any previous cards.
public final long addColorChanges(final String s, final Card c, final boolean addToColors, final boolean bIncrease) 
{
   if (bIncrease) 
   {
      CardColor.increaseTimestamp();
   }

   this.globalColorChanges.add(new CardColor(new ManaCost(s), c, addToColors, false));
   return CardColor.getTimestamp();
}
The Card class is used everywhere in Forge and I have fond memories of creating it from scratch. Currently the Card class is 8,800 lines long (including blank lines) and you can view it here. The most important methods are:

getName() : returns String
isSick() : returns boolean – Does this creature have summoning sickness?

getOwner() : return Player – Who owns this card?
getController() : return Player – Who is currently using this card?

getManaCost(): returns String represent the cost of this card. Even though not every card has a mana cost, most cards do.

One of the longest methods is hasProperty() which covers many additional sources of information like does this card have one color or multiple colors? Is this card double-faced? Is this card a flip card? Is this card enchanted? Is this card haunted by any other cards?

hasProperty(final String property, final Player sourceController, final Card source)

And finally I will look at IPlayerZone, which implements all of the zones in Magic: battlefield, graveyards, exiled, in hand, or in your library. IPlayerZone is technically an interface and just outlines what methods it need and does not contain any working code. IPlayerZone is just a thin wrapper for ArrayList and has the regular, boring methods like add(Card), remove(Card), size(), isEmpty(), and contains(Card) : boolean. I did not directly create IPlayerZone but I indirectly created it. To easily filter cards I created a different, yet similar class named CardList which easily lets you do common task such as find all elves or Forests in play.

Much of Forge has changed since I worked on it and just browsing through the source code, Forge looks very impressive. Just looking at individual classes is just a glimpse of the program’s overall form and structure but it shows just how many details have to be laboriously spelled out so the computer can process them. And yes I do understand that Forge has its share of errors but Forge really is a work of art.

Forge is the best videogame ever created. (Well next to Minecraft…)

Humble scribe,
mtgrares

p.s.
Just in case my previous link doesn't work, you can view Forge's Java source code here.