Hi again, folks. I'm back with some news about how the project is going, in case anyone is still interested
)
I have good news and bad news. The bad news is a) I'm behind schedule and b) I'm dropping Swi-Prolog from my workflow and focusing on Win-Prolog entierly. The difference is, Swi is free, open-source and allows me to publish executables, while Win-Prolog isn't, isn't and doesn't. You can read more about the whys and wheretofore's on my blog but the short of it is that, well, I'm behind schedule and I'm cutting corners! As usual...! I'll resume the development on Swi after I've reached my deadline safely (in exactly 2 months from now, on the 28th of April). Actually, I'll have some more assignments and exams to do so I'll probably publish sometime in the summer.
Now, for the good news. The engine is mostly complete, enough that I can start working on the AI this week, hopefully. Yeah, hope dies last XD
As promised, I've written an interpreter for MGL (the Magic Gaming Language), that understands and executes Magic rules text directly, as it is on the cards. Well, OK, you have to turn it into a comma-separated list, first but that's it more or less. Here's how cards look into the program's database:
- Code: Select all
card([
card_name 'Plains',
mana_cost 0,
%illustration 'Plains'
type_line [['Basic'], ['Land'], ['Plains']],
text_box [['tap',':','add','w','to','your','mana','pool']],
power [],
toughness [],
loyalty [],
state [['untapped', 'unflipped', 'face_up', 'phased_in']]
]).
card([
card_name 'Unsummon',
mana_cost 'u',
%illustration 'Unsummon'
type_line [[], ['Instant'], []],
text_box [['Return',target,'Creature',to,its,'owner''s',hand]],
power [],
toughness [],
loyalty [],
state []
]).
card([
card_name 'Aether Adept',
mana_cost '1uu',
%illustration 'Aether Adept'
type_line [[], ['Creature'], ['Human', 'Wizard']],
text_box ['When','Aether Adept','enters','the','battlefield',(','),'return','target','creature','to','its','owner''s','hand'],
power [2],
toughness [2],
loyalty [],
state [['untapped', 'unflipped', 'face_up', 'phased_in']]
]).
(
Sorry for the wonkiness...! I can't be bovvered to fix it right now.)
Note that this is a card "class", but that's not exactly how MGL Objects (ie, cards, permanents, spells, abilities on the stack and so on) are represented. card entries store the information about the characteristics of Objects. Objects themselves have three fields, Name, Id and State.
Now, the text_box field is identified as an ability by the interpeter, then executed in terms of the game engine. For example, tapping a permanent means adding the state "tapped" to its State field, bouncing it is calling a predicate "move_to_zone" and passing it the Name and Id of the permanent and so on.
That means the syntatctic rules I've defined for the interpeter will not be directly compatible with every game engine, since each will have its own internal representation of the games' various states and transitions between them. On the other hand, the syntax follows the definitions of the Comprehensive Rules (and where it doesn't, it should so I'll just have to fix it). This means it will be possible to translate in an intermediary syntax, liek BNF, that every engine will be able to use, either to populate a database or to translate in its own internal syntax.
Of course, nothing is done by, well, magic
There's a long explanation on my blog, of how the interperter goes from MGL to state transitions in the Magic Virtual Machine. The blog link is in my signature, but really it's doing what I explain in the posts above, more or less. Currently, the only effect I'm actually implementing is bouncing (
Unsummon,
Boomerang etc) because I want to start on the AI, but the bulk of the work is done, basically. Well, at least as far as simple effects are concerned, that involve moving things around zones or altering their states and so on. As usual, more complicated stuff will take longer and will be more buggy
Oh, btw, as you can see from above, type lines are not correct MGL yet (they should be of the form "Supertype Type - Subtypes" instead of [S][T][s], but I was working with types before I started on the interpeter, for some reason. So I'll just have to fix it eventually).
OK, that's it for now, I'll go back to not having a life and sleeping three times a day by a couple of hours a time, for the next two months! Have fun and as usual feedback is welcome.
Take care