Thursday, June 11, 2015

The Unicorn Battle Royale

I needed to fix my mod (Wings, Horns, and Hooves, the Ultimate Unicorn Mod) to work on the Forge Standalone Server. I worked all that out last night, and to test it, I started up a Forge Server and jumped on to play with my son. What happened next was pretty awesome.

Battle Royale

We needed to test out the different magical horse abilities, as well as the magical items that I introduced into the game. The most important things to test included flying, wing buffet attacks, horn charge attacks, and the two wands. In particular, I wanted to test the Wand of Call Lightning, because I'd had to make some non-trivial changes to how it worked.

It wasn't long until we were shooting each other with magic wands, and blowing up horses that happened to be in the blast zone.

Getting hit with my fifth fireball, I decided to take to the air. I hastily equipped my newly-bred alicorn (pegasus with a unicorn horn) with a Diamond Slotted Horse Helm and a Wand of Call Lightning, jumped on, and flew into the sky.

He did the same, and soon we were dogfighting, whirling through the air and calling lightning down in vicious forks.

Flying in from above, I targeted him and called down a mighty lightning bolt on his head. Unfortunately for me, I crossed overhead a half-second later and was struck by the same bolt!

Wheeling, I got him in my sights again, and made the first airborn kill. I watched as his horse flopped lifelessly in the air, dropping him.

But we were in Creative Mode, so he didn't die ... and was soon back in the air, calling lightning down on my head.

It didn't take long until we ran out of mounts. Poor dead horses, you served us well. *sniff*

But this was no time to cease the battle! And that's when I got creative.

Cheat Codes

Using my calculator and my knowledge of my mod, I devised some cheat codes. I wasn't sure they would work, but I tried one out, and it did! Before long, my son and I had spawned 20 to 30 new zebra-skinned flying unicorns, and the battle was back on!

Eventually, the battle wound down and we had to turn in for the night. However, I thought that I should advertise the cheat codes. I've started posting them on their own page, but decided to leave discovering how to make the cheat codes work be an exercise for the player for now. Don't worry. I plan to explain it all in the near future.

Player-Versus-Player (PVP)

Our battle solidified an idea I'd had while creating my mod. Halfway through development of version 1.0, I'd thought, "Hey, this would probably be great for PVP minigames." Having played out our battle royale, it reinforces to me just how fun the mod is when playing in a PVP fashion.

I'm going ahead with future development with this in mind. Expect cool stuff to fight your friends with (and maybe play other cool minigames).

Edit: I realize our battle wasn't technically a "Battle Royale" - you need 3+ contestants for that. Just consider all the dead horses as contestants that didn't win.

Sunday, June 7, 2015

Wings, Horns, and Hooves, the Ultimate Unicorn Mod (for Minecraft)

My latest project has been to create a Minecraft mod using the handy Minecraft Forge mod toolkit and loader. I sort of started with a scattershot approach, making items, some new block types, and a new dimension.

Then my kid said, "Hey Dad, can you make a Unicorn mod?"

And I said, "You bet I can."

After going for a few weeks, I thought to myself, "Erg, I should check to see if there are unicorn mods out there already." Sure enough, there were.

So I differentiated mine.

Two months later, I have released my mod, and I admit to being proud of it. It's called Wings, Horns, and Hooves, the Ultimate Unicorn Mod and you can get it at CurseForge.

The mod features four new magical horse types (Unicorn, Pegasus, Nightmare, and Destrier) and a bunch of new specialized equipment for them. They have their own behaviors, they can interbreed, and there are a bunch of secrets you can discover. The secrets include one secret magic item, five secret special horse types you can find through the breeding process, and an easter egg or two. Over the next few weeks I'll document all of these secrets, but until then I'll leave them for others to find!

Oh yeah, there is also a cool magical horse customization option.

I haven't quite finished the documentation part of the project, but I'm getting there. You can find out a lot more at the following links:

Monday, April 13, 2015

Getting Your Computer to Make an Awesome New Magic the Gathering Deck

In my last post, I wrote about the Magic: The Gathering article over at Channel Fireball,

Magic Math – A New Way to Determine an Aggregate Deck List: RG Dragons by Frank Karsten.

Although I thought Frank's article was great, I'm not the biggest fan of the idea of building aggregate decks.  It's not that I don't like them as a possible tool for making a better deck, but rather that I don't find them terribly interesting.  They aren't new or different, just refinements on decks that have already been created.

What really excites me is the idea that we can use automation to plow new ground and discover great decks that no one has seen before.

I've done a little thinking on trying to use a computer to make a better deck that is also original. It's a Search Problem: you have many combinations of 60 cards, with the goal to find the optimal set of 60 cards.

Constructing a deck through computer automation is not a difficult problem.

The big problem is evaluating it.

How to evaluate a deck in an automated fashion? The best way is to play it a crap-ton of times against all the best decks currently in the format (including some tier-two decks, to suss out any sort of rock-paper-scissors type relationships between multiple decks). To best do that, you would want a good automated agent ... or to hire millions of MTG players.

To some extent, millions of MTG players are already doing this, which is how we find our tier one decks.  However, I think there are areas in the search space of all possible decks that are not being explored, and are in effect getting missed by our human blind spots.  We see the obvious synergies between certain cards, but there have to be some that we miss.  That's why I think this is so interesting.

No one wants to pay for a million MTG players to test thousands of computer-generated decks, some of which are bound to be losers.  We need an automated way to do it.

Possible Automated Solutions


1.  Find a heuristic or set of heuristics to evaluate the deck

"Heuristic" is just a fancy computer science word that means, "A simple rule to find an answer that is close enough, because doing it the correct, hard way would be too slow."

I love heuristics as much as the next guy, and I think developing a few simple ones could be useful for weeding out bad decks.  I'm thinking of things like checking the mana costs of your cards and comparing them to the land composition in your deck.  However, some of this stuff can just be programmed into your process in the first place.

Ultimately, I believe this approach fails because MTG rules are too complex.  When every card can have its own rules text, heuristics are going to miss too many opportunities for deck synergy.  In effect, I'm saying, "You can't simplify and expect to get a good deck."  Maybe you could get a good basic aggro or control deck, but I don't think you need a computer for that.

Also, you really just don't know how good a deck is unless you play that deck and get an actual win or loss out of it.

2.  Make an automated MTG game-playing agent

Making a good automated Magic player agent would be hard, but do-able.  You could write it to interface with Magic: The Gathering Online (MTGO) or another system.  You could even rig up some fancy learning Artificial Intelligence, or basic game-playing logic.

The hardest part would be coding up all of the game rules, and that would be a big task.  Your early attempts would surely infuriate many players with how badly they sucked (And I don't just mean sucks as in "loses the game," but sucks as in "stops playing altogether when it can't figure out Chains of Mephistopheles."

The second hardest part would be making it good, because MTG strategy ain't easy, especially when the number of different cards available is as large as it is.  This is somewhat mitigated if you choose a format with a reduced card pool, like Standard, but it's still hard.  Also, with so much hidden info, writing a piece of software to guess at card-draw probabilities, know about different deck archetypes (including the possible new territory that it is forging itself!) would be a real pain.

With much work, you could probably get something that approximated a human player, maybe even a pro.

However, even if you went to all that trouble, it's not the best (and by that I mean easiest) solution, even if it would be an interesting and worthwhile project.

3.  Make an automated agent THAT CHEATS!

An automated agent that can see all parts of the game state (thus being a big Cheatyface) would allow us an easier avenue to simulate absoluate perfect play.  Now when I write "all parts of the game state," I mean:

  • Hand contents of both players
  • Composition and ordering of both decks

Furthermore, if you wanted to simulate slightly more realistic play, you could hide some state, such as the deck contents of one or both decks.  This would help make the problem easier to solve (i.e. "tractable" in computer-ese), as opposed to trying to program in knowledge of deck archetypes, or something else that is inherently harder.  You could generate different sets of win-loss data based on how much cheaty knowledge was allowed, and this could enhance your analysis, including possibly informing you how "hard" a deck was to play (the more psychic knowledge it requires to consistently win, the harder it is to play).

And you could play two such agents against each other!

A large part of the effort would be implementing the MTG rules engine, and including the custom rules for all the cards in a given format. This is important, but not because you want the agent to be able to play the game.  It's important because you want the agent to be able to look ahead at future states of the game (life totals, permanents on the board, etc.), and pick the best one (i.e. the one that scores the best, based on optimal play by your opponent, and the resulting possible future game state).  Of course, choosing how to score a game state is another challenge, but not a terribly tough one.

Now, if I can just get Wizards of the Coast to give me programmatic access to their rules engine for Magic: The Gathering Online, I'll be most of the way there!

Hey Wizards, what do you say?!

Sunday, April 12, 2015

Magic: the Gathering and Computer Automation

I am an avid Magic: The Gathering (MTG) player.  A few days ago, a friend pointed me to an interesting article that combines MTG and math, and relatedly computers, which is what really interests me.

The article describes a process for generating a deck list based on all the best deck lists of a given type.  The idea is to use the crowd of the best examples to make a deck that is even better.  Check it out if you're into that sort of thing:

Magic Math – A New Way to Determine an Aggregate Deck List: RG Dragons by Frank Karsten

One cool thing about Frank's process is that it can be automated, and that's the part that really gets me going (and some people in the comments of the article have already done so, in fact).  That's because although I think his process is a neat idea, as with anything new, it can be refined and made better.

Automation can help with this refining.  Once automated, you can play with some of the rules of Frank's process (let's call it Process #1).  One such rule is a rule for breaking ties if you have two cards competing for a spot in the deck.  Frank states in his article that he just picked something easy to break these ties, which is to choose the card that comes first alphabetically.  Changing this rule is a refinement to the process, and creates Process #2.  For example, say you change the tie-break condition to be whichever card has a lower casting cost.  It's an arbitrary rule, and probably not a great one, but possibly better than the alphabetical rule.

And now we have a new process, Process #2, to compare against Process #1.  Since both are automated, we can use them to quickly make many new decks to compare and contrast against each other.  All that's left is to figure out which one is better, admittedly not always an easy task, but still we're one step closer to the best deck in the land (cue evil laugh)!

Automation is so great.