Incantus Programming Questions
by Incantus
Moderator: CCGHQ Admins
Re: Incantus Programming Questions
by mtgrares » 14 Nov 2008, 18:28
LOL, yeah me too. Hybrid scared me the first time I thought about programming it. I have the hybrid code working but I haven't incorporated it into the main project because of the debugging. Sometimes there isn't any bugs but other times, well, lets just say that I've killed enough bugs to qualify for my exterminaters licenseAm I the only one who's afraid when a new block's coming ? "What, now they can do that ? (like, the hybrid mana cost ? Come on, how am I gonna put that in my manacost class ???)
I love cards like Time Walk and Mana Flare but they are tough for me to add to my project and I'm not getting a good feeling about exalted. I want my exalted code to be very short, there are less errors that way.
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: Incantus Programming Questions
by frwololo » 15 Nov 2008, 04:49
Hey forge, for my project I created a test mechanism to ease debugging and make regression tests.
Of course it cannot test all aspects of the game, but it enables me to make sure a change in the code doesn't break previous features.
Basically it is a set of text files that send commands to the engine, and compare the result to an "expected" state of the game.
For example, if I want to make sure that drain life is working correctly, here's how it looks like: (1156 is the code for Drain life, and 1099 is the code for brass man)
Here is a video of the test suite running, and more information:
http://wololo.net/wagic/the-testing-suite/
Of course it cannot test all aspects of the game, but it enables me to make sure a change in the code doesn't break previous features.
Basically it is a set of text files that send commands to the engine, and compare the result to an "expected" state of the game.
For example, if I want to make sure that drain life is working correctly, here's how it looks like: (1156 is the code for Drain life, and 1099 is the code for brass man)
- Code: Select all
#Testing Drain life on a brass man
[INIT]
FIRSTMAIN
[PLAYER1]
hand:1156
manapool:{B}{B}{B}{B}{B}
[PLAYER2]
inplay:1099
life:20
[DO]
#click on drain life
1156
#target brass man
1099
[ASSERT]
FIRSTMAIN
[PLAYER1]
graveyard:1156
life:23
manapool:{0}
[PLAYER2]
graveyard:1099
life:20
[END]
Here is a video of the test suite running, and more information:
http://wololo.net/wagic/the-testing-suite/
Re: Incantus Programming Questions
by MageKing17 » 17 Nov 2008, 20:31
Hybrid was actually fairly easy, although we'd dreaded it at first. The solution wound up being the game generating the possible mana combinations (I.E. Demigod of Revenge can be "BBBBB", "BBBBR", "BBBRR", "BBRRR", "BRRRR", or "RRRRR"), presenting this in a list to the player, and then going through the normal cost-paying routines.
While Reaper King seems to not be doable with this approach (MTGO uses our approach for most cards, but not Reaper King), we found that with a sorted list of costs (I.E. "10, 8W, 8U, 8B, 8R, 8G, 6WU", etc.), it's pretty easy to find the cost you want to pay, and it doesn't overflow the screen, so we did it anyway.
As for Time Walk and Mana Flare... Time Walk is actually done (IIRC), and simply tells the GameKeeper to insert an extra turn for that player. Mana Flare, on the other hand, is still undone, because it's an example of a triggered mana ability, and we haven't yet added these to our engine (Keeper of Progenitus, from Shards of Alara, is another such undone card). We also haven't done State Triggers (triggered abilities that trigger on a game state instead of a specific event (e.g. "When you have no cards in your graveyard"), and don't trigger again until and unless the first ability leaves the stack and the state is still true).
That testing suite looks interesting, and we even sort of have our own way to do that. Incantus (the program) automatically records a replay file, which is just a list of the actions taken in the game (plus a few extra things, like the random seed, the decks being used, player names, and (now) player colors), and whenever we want to test a specific card over and over, we'll test it once, then re-use the replay every time we change the code (e.g. I play Consume Spirit, and the game crashes. So I look at the code involved, make a tweak, then tell Incantus to run through the replay. If it crashes again, back to the code. If not, it probably fixed it).
While Reaper King seems to not be doable with this approach (MTGO uses our approach for most cards, but not Reaper King), we found that with a sorted list of costs (I.E. "10, 8W, 8U, 8B, 8R, 8G, 6WU", etc.), it's pretty easy to find the cost you want to pay, and it doesn't overflow the screen, so we did it anyway.
As for Time Walk and Mana Flare... Time Walk is actually done (IIRC), and simply tells the GameKeeper to insert an extra turn for that player. Mana Flare, on the other hand, is still undone, because it's an example of a triggered mana ability, and we haven't yet added these to our engine (Keeper of Progenitus, from Shards of Alara, is another such undone card). We also haven't done State Triggers (triggered abilities that trigger on a game state instead of a specific event (e.g. "When you have no cards in your graveyard"), and don't trigger again until and unless the first ability leaves the stack and the state is still true).
That testing suite looks interesting, and we even sort of have our own way to do that. Incantus (the program) automatically records a replay file, which is just a list of the actions taken in the game (plus a few extra things, like the random seed, the decks being used, player names, and (now) player colors), and whenever we want to test a specific card over and over, we'll test it once, then re-use the replay every time we change the code (e.g. I play Consume Spirit, and the game crashes. So I look at the code involved, make a tweak, then tell Incantus to run through the replay. If it crashes again, back to the code. If not, it probably fixed it).
-
MageKing17 - Programmer
- Posts: 473
- Joined: 12 Jun 2008, 20:40
- Has thanked: 5 times
- Been thanked: 9 times
18 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 21 guests