It is currently 19 Apr 2024, 19:15
   
Text Size

Incantus Programming Questions

by Incantus

Moderator: CCGHQ Admins

Re: Incantus Programming Questions

Postby mtgrares » 14 Nov 2008, 18:28

Am 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 ???)
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 license ;)

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

Postby 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)
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]
A test suite should be easy to add to your game, it is basically an AI player that gets its orders from a text file rather than clever algorithms.

Here is a video of the test suite running, and more information:
http://wololo.net/wagic/the-testing-suite/
frwololo
DEVELOPER
 
Posts: 265
Joined: 21 Jun 2008, 04:33
Has thanked: 0 time
Been thanked: 3 times

Re: Incantus Programming Questions

Postby 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).
User avatar
MageKing17
Programmer
 
Posts: 473
Joined: 12 Jun 2008, 20:40
Has thanked: 5 times
Been thanked: 9 times

Previous

Return to Incantus

Who is online

Users browsing this forum: No registered users and 11 guests


Who is online

In total there are 11 users online :: 0 registered, 0 hidden and 11 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 11 guests

Login Form