tag:blogger.com,1999:blog-889604442512373664.post1120010803300777505..comments2023-10-31T08:28:52.391-07:00Comments on Computer Programming and Magic: The Gathering: 2 Headed DragonForgehttp://www.blogger.com/profile/15838286606081721333noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-889604442512373664.post-23056655924486951712008-05-15T08:50:00.000-07:002008-05-15T08:50:00.000-07:00Hehe, I've implemented about 600 magic cards in In...Hehe, I've implemented about 600 magic cards in Incantus, although besides most of 10e, all the other cards are vanilla/french vanilla cards. It helps to have a program to import oracle text and automatically convert it into card code :)<BR/><BR/>Leo, I'm really interested in your minimax implementation for MtG. How did you design your board evaluation function? If you don't make a full copy of the game state, is everything reversible in the game? For Incantus, it's looking like the easiest thing to do is making copies of the game state, but i haven't tested it to see if it's fast enough (I already make lots of copies during the course of the game). But the one thing I haven't figured out is a good eval function.<BR/><BR/>As the next thing to implement in Incantus, I'm trying to decide either between a rudimentary AI, or some sort of mental poker protocol so that 2 people can play without a server and no chance of cheating.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-39704651372603060932008-05-14T10:33:00.000-07:002008-05-14T10:33:00.000-07:00Lee, Not too many people in the world can say that...Lee, Not too many people in the world can say that they have programmed 800 Magic cards, lol, not even me. Version 2.0, which will probably be written in Python, will definitely include a "look ahead" function like minimax or alpha-beta pruning. I'll code everything so that it is able to be copied. <BR/><BR/>I need to be careful of performance issues, so I shouldn't just copy all the game data each time. Maybe each action, like playing a card, could be saved individually, so only a minimal amount of data will have to be copied.<BR/><BR/>All this is pretty new to me and hopefully I don't get over my head. ;)Forgehttps://www.blogger.com/profile/15838286606081721333noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-12295779037234321302008-05-13T10:52:00.000-07:002008-05-13T10:52:00.000-07:00and a game state consists of more data some people...and a game state consists of more data some people would think of. there are cards that care about damage dealt one turn, the number of turns and maaany more. also the cards with "when .. comes into play, choose ..".<BR/><BR/>Fortunately, the "timestamps" that are mentioned in the CRs could be used to identify a game state; every action done alters the current timestamp, which makes restoring (a little) easier.Silly Freakhttps://www.blogger.com/profile/09963238585847993157noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-28161700630826349952008-05-12T20:09:00.000-07:002008-05-12T20:09:00.000-07:00I went through all these questions so I just want ...I went through all these questions so I just want to drop my 2 cents here.<BR/><BR/>First of all you shouldn't aim for the number of cards at this stage. Your goal is to build an engine to support a small number of cards. You need to then implement your AI strategy (most probably a variant of minimax) with this core.<BR/><BR/>In my opinion you really have no choice but to use some form of search algorithm to accomplish the AI part. There are just two many cards in MTG and you couldn't implement AI on each one. I personally has implemented more than 800 cards in DeckBot. There are still exceptions to this rule but those are uncommon, e.g. cards involving coin tosses, peeking at another player's hand.<BR/><BR/>Now with a search algorithm, your engine needs to build in such a way that the game state can be restored at will so that searches can be continued from an earlier 'node.' Chess' game state is easy, MTG's game state is not easy. That means you couldn't pass the whole game's state between calls as stack variables. You couldn't make copy of the whole game state also because that will kill your performance. You need to really think about how to implement this 'undo' thing early on. Java has its only advantage to other languages, e.g. C++, in automatically collecting unused objects so you are in the right path.Anonymousnoreply@blogger.com