Wednesday, September 17, 2008

Version 2

Talking about the future is a dangerous thing, just read George Orwell’s 1984, but I’m going to briefly talk about MTG Forge version 2. It will be written in Java and it will use the current user interface. I really suck at writing user interfaces and I was getting tired of trying to write a better one. Hopefully in the future, the user interface will be changed/updated by someone who has more skill in that area.

As I mentioned last week, all of the Magic cards are going to be encoded using plaintext so many cards can share the same Java code, so I can just write the “destroy creature” code once.

wrath of god.txt

Wrath of God
2 W W
Sorcery

Spell
Text: Destroy all creatures. They can’t be regenerated.
Resolve: destroy all creatures – no regeneration

I might have to update the card format above to tell the AI what phase is best to play the card. Like Wrath of God should be played during the computer’s Main 2 phase, while Giant Growth should be playing After Declaring Blockers.

I also plan to have an updated AI. The AI feature is the unique feature of MTG Forge and while the current AI is basic, I hope to improve its performance. I plan to use some type of algorithm that “looks ahead” and does a few actions, scores the results, and then does the best action. This is basically what you do in your head when you make a decision, you try to see all possible results and you choose the best action.

I plan to have at least a few AI personalities like the aggro or control player. This should at least keep you guessing about what personality the AI is currently using. I am also hoping for “deck specific” AIs that I can write to play a specific deck as good as possible.

I will also have an undo feature in case you make a mistake. This feature is necessary in order to let the AI look ahead. I also want to have a quest mode where you begin with a starter deck and you have to win money to improve your deck. This would make MTG Forge more like a videogame instead of just static 1-on-1 matches. You would also participate in simulated tournaments. Everything I’ve mentioned is possible and I can’t wait to play it myself.

p.s. When you would buy cards in “quest mode” I was thinking that you would only buy booster packs, since using a random collection of cards is more challenging. Maybe the card shop would sell mono-colored booster packs, so you knew that you would get something useful.

p.p.s. I was also thinking about having a player’s rating, but I’m not sure if that would really matter. The rating would be like your DCI rating, it would go up if you won and down if you lost.

16 comments:

  1. Hi Forge. All great ideas :)

    My one suggestion would be to put the card AI "hints" (play this during computer's main phase 2, play after declaring blockers etc) into a separate file.

    That way, when the AI mechanism changes (say in MTG Forge V3(!) the ai can calculate when it's best to play a card!) you won't have to go through all the card definitions changing the hints.

    My gut feeling is that the cards definition file should strictly contain the card "rules" - not the AI information. It would be more OO. You could re-use the card definitions in a different magic game, you could swap the AI mechanism for an alternative. It would make the game / code / data more modular.

    Cheers,

    Tim

    ReplyDelete
  2. Quest! This is realy good idea! I can't wait anymore! I want to play in THIS!

    Hello from Russia

    ReplyDelete
  3. Hi Forge. I think that all are great ideas too.
    Actually I am working in a project card game doing an client - server basic protocol. In it I show how to make the logic game in the server and make the GUI in the client doing that those was a dumb terminal.

    I still think that this would be interesting to implement it in your project because you can connect with the server with several diferents client, like a console client, a GUI graphic client maked in C++ , another GUI client maked in JAVA, etc.
    And the most important, it will do possible do that the incantus engine can connet to it too, it the owner make the needed changes to permit it.
    If you want do it. I will send you my source code for that you take a look.

    ReplyDelete
  4. at you call quest mode is known as League play and is immensely popular particularly in MODO.

    ReplyDelete
  5. blah cut off the first word partially...at = what.

    ReplyDelete
  6. Also I agree with Tim's comments about making the AI knowledge base separate. Also I was thinking perhaps a deck based approach to the ai would be good since you wrath of good early and often in somedecks (any deck that is capable of giving lots of creatures haste for example) and late and carefully in others. Some decks are designed to lava axe the opponent to death and some the burn is strictly creature removal or finisher. So a deck ai approach could work at least some of the time...though I like the randomized ai approach too.

    I find being a fairly mediocre player myself that random opponents lead to more challenging games.

    ReplyDelete
  7. Sounds like you are aiming for a low budget version of Shandalar.
    I really hope you can pull it off.
    The idea of colorfixed boosters for questmode is a really good idea.
    It gives the player a choice of direction in which to take his/her deck while not letting you directly pick the cards you want.

    Good luck in making it all turn out the way you intend it.

    ReplyDelete
  8. While it seems that folks are speaking up for a quest or shandalar work-a-like and even some PvP, I will throw in that I like it just the way you have it. I am more interested in playing against a computer player and want the quick hit, play a game, and move on to something else. Nothing more involved then playing the card game. This way the development focus can be on making the AI better (hmm, say, multi-level beginner, intermediate, expert...) and making better eye candy in the user interface.

    ReplyDelete
  9. Nanocore...you may have missed some of the nuance here. There are couple things to consider. 1) Forge is doing this for fun and it is his baby. 2) Others are contributing their time and effort to code parts of it. 3) because it is open source you are more than welcome to help :) However things are going to go the way Forge wants them to. As he has said often enough UI Isnt his thing...eyecandy sounds like a job for a graphic designer, which is something Im not or I might feel compelled to do that. As far as keeping it simple I think the main client will still be fairly simple. Forge is suggesting and I think its a great idea to add on another part to the client just as it has Drafting and Constructed and Sealed now. So my vote is give it a chance before getting negative. :)

    ReplyDelete
  10. My two goals for version 2 are:
    1. Better AI
    2. Quest Mode

    You can still play a quick match if you want to but I think many people will really love the quest mode, since you earn new cards (loot) which keeps you coming back for more.

    ReplyDelete
  11. Ah, the delicate balance of posting a comment, which I figured would trigger a nerve as I typed my response. Context is probably everything. There was absolutely no intention of negative connotation stated or implied. Just a plain comment of interest for a direction, like the others. Think of it more as additional applause from the peanut gallery...

    ReplyDelete
  12. Quest mode!!! YES!!! I loved Shandalar, but it has a limited card pool. MTG Forge in quest mode would just be amazing.

    ReplyDelete
  13. Hi Forge,

    You absolutely have to leave the AI hints out of the card definition (rules and text) file! OK, *YOU* don't *HAVE* to, but you know what I mean. That would be the only sane way to make multiple AI personalities. Each AI might use a card differently, more aggressively perhaps, than the others.

    For AI look-ahead you ideally would be able to generate all possible actions at a particular point in the game, and put them into a list. You can then let the computer pick one, 'do that action', generate all possible next actions, and so on. This gives you a depth-first search, but you could do a breadth-first search instead.
    I don't know how you would generate the list of possible *player* responses. You can of course let the AI keep track of cards it has already seen the player has. Then you can generate actions for those cards, not knowing if the player still has one or not.
    If your AI is advanced enough, it would be able to guess what other cards a player is likely to have based on the cards it has seen so far.

    I can tell you've thought about this a bit. The realization that you need an Undo feature to provide AI look-ahead gave you away. :^)

    I don't know how you're going to implement the AI (sounds like you don't either yet) but I think you're going in the right direction.

    ReplyDelete
  14. I would agree with keeping the AI rules out of the definition. The multiple personalities or levels would certainly make the game play even more interesting. In a previous exercise, I was way more focused on the AI then the user interface (hence I never finished it). I was going down the path of using an embedded rules engine (jess) for the AI to process the "environment". The engine would interrogate the cards and then use the response to step through the rules defined for that AI "player". It would determine whether to take an offensive or defensive stance and do what it could with the cards available. Granted this is way more extensive then it needs to be, but it was fun to think through and went unfinished.

    ReplyDelete
  15. Well about the AI and card rules, I mean the really, really basic things like "play creatures with haste during your Main1" and play Instants during the best time. The stuff that is so basic that you don't even think about but MTG Forge actually has a list of spells that it plays before Main1 and after Main1.

    Practically you would always play Wrath of God after you attack during your Main2 phase.

    ReplyDelete
  16. I submitted some code to Forge for a Regenerate keyword. The currently implemented regenerators in MTGForge simply return false for CanPlayAI.

    I decided that since we can't play the ability during combat - the ideal time, that I'd come up with some basic rules about predicting if it might be useful to regenerate. For each test I assigned a percentage number to the favorability of regenerating. Then I averaged the "weights" and took a random number from 1-100. If it fell below the average, the computer would play the regenerate, if not, then it wouldn't.

    ReplyDelete

Note: Only a member of this blog may post a comment.