Page 1 of 1

Re: [engine limitation]Sorin Markov

PostPosted: 28 Mar 2014, 16:47
by gmzombie
So a side question Korath then do u think there will ever be a time that we won't need the rules engine card? I know it does a lot but is this something that you guys by your recoding of all of these cards and Api's would be able to someday not need?

Re: [engine limitation]Sorin Markov

PostPosted: 28 Mar 2014, 18:53
by BAgate
That would probably need a major interface change. If there was no Rules Engine, how would you use flashback or dredge?

Re: [engine limitation]Sorin Markov

PostPosted: 28 Mar 2014, 22:05
by gmzombie
that is why i asked. i dont really understand how the game uses the card to do the flashback and dredge and whatnot. But this is why im not a coder im just the useful tester.

Re: [engine limitation]Sorin Markov

PostPosted: 29 Mar 2014, 04:17
by BAgate
Think of it this way. I cast a Dream Twist (that has flashback). Two turns later I want to use that flashback, so what do I do? There is no card in my hand or the bf to click and Manalink doesn't allow clicking on specific cards in the gy, so what do you do? The Rules Engine is always in play so is always available to be clicked on. While it could theoretically be possible to handle things like cycling w/o the Rules Engine, the interface alone kind of necessitates it for some cards.

Re: [engine limitation]Sorin Markov

PostPosted: 29 Mar 2014, 06:08
by Korath
(Off topic. Can someone split this, probably into Development?)

Over half of the cards that currently need a Rules Engine - everything that has 1 in their cc[2] column in ct_all.csv - won't generate a Rules Engine as of next patch; all they did was make it possible for us to cast spells without charging their mana cost, and I've moved the function that does that into C so we can just suppress it directly.

As for eliminating the Rules Engine completely, well, it could be done. Data stored on it can just be stored directly in memory - it needs to be backed up and restored by the AI (the functions to do so are already in C, so easy), and saved and loaded (which I happen to be working on currently, though not specifically for Rules Engine data). Things we use the rules engine to trigger for, we can create temporary effect cards, like how madness or death triggers work. For flashback and other in-graveyard activation, click on graveyard to fan it out, then click on a card in the graveyard to activate it. For cycling and other in-hand activation, click on the card.

But we'd have to understand how the AI picks things to cast or activate a whole lot better than we currently do in order to give it more options like that - it can activate the Rules Engine because it sees it as just another activateable card on the battlefield. (Or at least, it would if we didn't force it not to. There's an experimental config option in the next patch that lets it do so, though I think it'll still only ever pick the first option.) Plus, all of the UI uses direct win32api calls, which are absolutely miserable to work with even if you have source code.

I don't think it's worth the development time right now. I know I for one just want to get duel stable enough that I can work on getting Shandalar working, without knowing that there'd be at least one totally unusably buggy card in every deck I put together.

Re: [engine limitation]Sorin Markov

PostPosted: 29 Mar 2014, 06:54
by Aswan jaguar
In the version you gave me with the experimental config.txt option I tested AI using flashback and unearth and AI didn't have problems using them at least in casual play.(non combo decks)

Towards no RulesEngine-Deadbox Cards

PostPosted: 29 Mar 2014, 07:01
by Aswan jaguar
Postby Korath ยป 28 Mar 2014, 13:53
Probably easier than Deflection. A lot of it we can do already, or do pretty easily:

override who_chooses in select_target_impl().
override who_chooses in do_dialog().
override who_chooses in show_deck() and its front ends.
show opponent's hand.
choose attackers and blockers.

Selecting spells to play and permanents to activate, both spontaneously and during charge_mana(), is more difficult, but not insurmountable.

The biggest stumbling block is all the places in C where a choice is forbidden to the AI - it doesn't just forbid them to the AI, it forbids them to player #1, even if that's a human in a multiplayer game, or a human's controlling the choice. (Probably the largest reason why multiplayer is broken; one of the cards doing this is the Rules Engine.) I've been replacing these by an IS_AI() macro as I've noticed them, but there's still hundreds of instances to go.

Re: Towards no RulesEngine-Deadbox Cards

PostPosted: 29 Mar 2014, 18:35
by gmzombie
well this is awesome news to hear at least we are stepping in the right direction. I for one totally agree with a stable duel as i would love to see some shandalar action someday. i kinda think there is still some shandalar code inside of magic.exe due to the nature of how the original game progressed. back when the game first came out there was just one magic.exe and a duel.exe and deck.exe. shandalar wasent an additional exe if i recall.

Re: Towards no RulesEngine-Deadbox Cards

PostPosted: 19 Apr 2014, 16:12
by gmzombie
hah when i originally read this i believed i understood but now i totally do. what would need to be recoded and redesigned would be the interactions with the graveyard. i dont know why it took me so long to get this but now i do. so then is the rules engine only for dredge, scavenge, flashback, unearth and anything that is graveyard related correct?

Re: Towards no RulesEngine-Deadbox Cards

PostPosted: 20 Apr 2014, 00:05
by Korath
Pretty much anything that needs to let a card trigger or activate while it's not already in play. So also madness, miracle, leylines, cycling, and forecast, for example.

We also use it to store global data that needs to be backed up and restored while the AI speculates, and put in savegames and such. The most obvious examples are the various conditions for Trap cards in Zendikar block. Those'll probably be the next to go.