SQLite Data Engine
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
28 posts
• Page 2 of 2 • 1, 2
Re: SQLite Data Engine
by Braids » 24 Jul 2011, 00:40
`zerker2000 wrote:Ah, they were being passed through getCard. Do we actually need to do that?
lots of things call CardFactory.iterator() {often by treating AllZone.getCardFactory() as an Iterable}. many if not all assume that the Card objects are results of getCard.
`zerker2000 wrote:The way I see it, the only thing needed outside the game(and that may exclude libraries) is oracle text(and other characteristics), and that should be parseable in ReadCard using Description tags.
possibly so. i don't want to put oracle text in our txt cards if we can help it.
`zerker2000 wrote:Even if we don't want to create a separate UnparsedCard class, I'm fairly certain that could be added to Card as a boolean, and checked in e.g. DefaultPlayerZone.add.
i'd advocate for a separate class. it's easier to understand. though i think the name could use some work. then again, i could be swayed toward using a relational db for oracle information. notice the pun? maybe it's not a pun. i somehow doubt it's a coincidence that the official card text is called "Oracle" when that is also the name of a popular relational database management system.
would a relational database be faster or more memory efficient than Generators? we would need hard evidence to be certain.
`zerker2000 wrote:By "fleshed out" cards I meant Card Objects, in the MTG Rulebook sense, but yes, the existence of hand/grave abilities does require slightly earlier parsing.
i know that Forge checks for static abilities on cards in libraries. i'm not sure why, though. i would tend to think that only cards in hands, exile, battlefield, graveyards, and command zones need abilities. if someone knows of a counterexample, i'd love to know. 1996 World Champion does not count.
`zerker2000 wrote:And finally, I'm not quite sure if I am volunteering for anything, but I may indeed have a decent amount of free time within the next month.
ok.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: SQLite Data Engine
by zerker2000 » 24 Jul 2011, 01:42
Right, but would they break if fed CardFactory.map data instead?Braids wrote:lots of things call CardFactory.iterator() {often by treating AllZone.getCardFactory() as an Iterable}. many if not all assume that the Card objects are results of getCard.
My problem with that argument is that we already are, spread as it is across CardFactory*.java and cardsfolder/*/*(and possibly AbilityFactory*, though when I last checked all AFs used $Description).possibly so. i don't want to put oracle text in our txt cards if we can help it.ReadCardCardReader could get the Oracle text from some other file. why? unless we want to keep relocating our repository from theDimwits Making Copyright AllegationsDMCA whiners, we must keep Oracle text outside the code repository.
Though it may be better coding practice, it does necessitate the refactoring of all CardFactory.iterator() users, which may otherwise be avoidable.`zerker2000 wrote:Even if we don't want to create a separate UnparsedCard class, I'm fairly certain that could be added to Card as a boolean, and checked in e.g. DefaultPlayerZone.add.
i'd advocate for a separate class. it's easier to understand.
Not explicitly, but casting restrictions(e.g. Skyshroud Condor) work wherever, and are technically static abilities(I'm not sure how/if they're implemented in forge). Either way, any revealed card should be parsed completely.i know that Forge checks for static abilities on cards in libraries. i'm not sure why, though. i would tend to think that only cards in hands, exile, battlefield, graveyards, and command zones need abilities. if someone knows of a counterexample, i'd love to know. 1996 World Champion does not count.
Also, you missed _____.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
- zerker2000
- Programmer
- Posts: 569
- Joined: 09 May 2009, 21:40
- Location: South Pasadena, CA
- Has thanked: 0 time
- Been thanked: 0 time
Re: SQLite Data Engine
by Rob Cashwalker » 24 Jul 2011, 04:41
If the field you're searching for is indexed in the database, then it is quite a bit faster than filtering. The index is usually stored and processed as a binary tree, which you're quite familiar with. Memory wise, I can only say that we shouldn't need 8500+ cards-worth of ability objects in memory at any time, which the database could hold anyway. The only data it would need to contain is the printed text, name, mana cost, type, set/rarity, rules text, p/t and possibly the SVar metadata. Then add the indexing trees for nearly every field the DB and you still probably clock in at a lower total volume of memory needed.would a relational database be faster or more memory efficient than Generators? we would need hard evidence to be certain.
The biggest advantage would be in the simplicity of pulling lists meeting nearly any combination of parameters with no explicit code or confusing Lamda Lamda Lamda Nerds.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: SQLite Data Engine
by Braids » 24 Jul 2011, 17:48
`zerker2000 wrote:Right, but would they break if fed CardFactory.map data instead?Braids wrote:lots of things call CardFactory.iterator() {often by treating AllZone.getCardFactory() as an Iterable}. many if not all assume that the Card objects are results of getCard.
yes, definitely. it happened. now, it may be interesting to store allCards' contents in the map's values instead. but i don't know what would break. it would probably be very subtle.
`zerker2000 wrote:My problem with that argument is that we already are, spread as it is across CardFactory*.java and cardsfolder/*/*(and possibly AbilityFactory*, though when I last checked all AFs used $Description).Braids wrote:. . . i don't want to put oracle text in our txt cards if we can help it . . . why? unless we want to keep relocating our repository from the . . . DMCA whiners, we must keep Oracle text outside the code repository.
my vision is to only have Java code specific to the rules of the game and to certain cards. i'd prefer we store and distribute the rest in some other fashion. perhaps this isn't important until our repository gets hit with its first cease & desist. which hasn't happened yet. at least my pestering will have made people aware beforehand. we've already moved to a distributed revision control system as a result, to protect the repository.
these would have to be changed anyway. just about everything iterating over the CardFactory is interested only in printed/Oracle data. rarity, color, sets.zerker2000 wrote:`Braids wrote:i'd advocate for a separate class [like UnparsedCard or such]. it's easier to understand.
Though it may be better coding practice, it does necessitate the refactoring of all CardFactory.iterator() users, which may otherwise be avoidable.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: SQLite Data Engine
by Braids » 24 Jul 2011, 18:11
but is this stored in RAM?Rob Cashwalker wrote:If the field you're searching for is indexed in the database, then it is quite a bit faster than filtering. The index is usually stored and processed as a binary tree, which you're quite familiar with.Braids wrote:would a relational database be faster or more memory efficient than Generators? we would need hard evidence to be certain.
true enough.Rob Cashwalker wrote:Memory wise, I can only say that we shouldn't need 8500+ cards-worth of ability objects in memory at any time, which the database could hold anyway.
ok. that sounds cool.Rob Cashwalker wrote:The only data it would need to contain is the printed text, name, mana cost, type, set/rarity, rules text, p/t and possibly the SVar metadata. Then add the indexing trees for nearly every field the DB and you still probably clock in at a lower total volume of memory needed.
no explicit code? how would you manage that? sql counts as code.Rob Cashwalker wrote:The biggest advantage would be in the simplicity of pulling lists meeting nearly any combination of parameters with no explicit code . . .
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: SQLite Data Engine
by Snacko » 24 Jul 2011, 18:29
Yes in memory db isn't something new.
You can check out a DeckEditor in java I maintain viewtopic.php?f=29&t=464. It uses h2 in memory db + on disk serialization for sql queries.
You can check out a DeckEditor in java I maintain viewtopic.php?f=29&t=464. It uses h2 in memory db + on disk serialization for sql queries.
Re: SQLite Data Engine
by zerker2000 » 25 Jul 2011, 01:37
My vision also heavily features forge understanding card plaintext. As things stand, however, half of cardsfolder has AF scripting. This code, while admittedly non-java, does specify the behaviour of relevant cards. Sure, if a proper parser was set up, we could simply use a scrape of Gatherer; when I tried to, it was as difficult as you would expect, and I ultimately ran out of time/steam. Something may be concocted in the future, but for the moment, forge includes the cardset. Is there any harm in reusing it?Braids wrote:my vision is to only have Java code specific to the rules of the game and to certain cards. i'd prefer we store and distribute the rest in some other fashion.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.
--Eladamri, the Seed of Freyalise
- zerker2000
- Programmer
- Posts: 569
- Joined: 09 May 2009, 21:40
- Location: South Pasadena, CA
- Has thanked: 0 time
- Been thanked: 0 time
Re: SQLite Data Engine
by Braids » 25 Jul 2011, 16:32
`zerker2000 wrote:My vision also heavily features forge understanding card plaintext. As things stand, however, half of cardsfolder has AF scripting. This code, while admittedly non-java, does specify the behaviour of relevant cards. Sure, if a proper parser was set up, we could simply use a scrape of Gatherer; when I tried to, it was as difficult as you would expect, and I ultimately ran out of time/steam. Something may be concocted in the future, but for the moment, forge includes the cardset. Is there any harm in reusing it?Braids wrote:my vision is to only have Java code specific to the rules of the game and to certain cards. i'd prefer we store and distribute the rest in some other fashion.
specifying the behavior of a card in a scripting or programming language is not the same as copying the card text. that is defensible in countries such as Germany, from what i've heard.
you want to parse plaintext and convert it to the scripting language? i've heard that discussed before. it is a real innovation!
reuse what is there, eh, ok. at the very least, are you able to avoid placing any more verbatim oracle text in the repository? or can you store your card text elsewhere and have the user download it separately?
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: SQLite Data Engine
by jendave » 25 Jul 2011, 16:59
A good place to start is viewtopic.php?f=27&t=1347zerker2000 wrote:My vision also heavily features forge understanding card plaintext. As things stand, however, half of cardsfolder has AF scripting. This code, while admittedly non-java, does specify the behaviour of relevant cards. Sure, if a proper parser was set up, we could simply use a scrape of Gatherer; when I tried to, it was as difficult as you would expect, and I ultimately ran out of time/steam. Something may be concocted in the future, but for the moment, forge includes the cardset. Is there any harm in reusing it?Braids wrote:my vision is to only have Java code specific to the rules of the game and to certain cards. i'd prefer we store and distribute the rest in some other fashion.
The "Magic Data" project scrapes the Gatherer and puts it into plain text or XML. I did look into creating a DSL for parsing the text into code, but it is quite a task. You may want to look at jRuby or Scala. Good luck!
Re: SQLite Data Engine
by Rob Cashwalker » 25 Jul 2011, 20:53
Quite frankly, I don't mind Oracle text residing in each supported card.txt file. What I didn't like was the data file for the entire current-known multiverse having to be distributed in the beta release.
Having the Oracle text available in the card files would benefit the deck editor immensely, as the cards don't need their objects populated just to display the right text. Therefore the card object could be created more dynamically.
I'm considering using Java to dynamically manipulate the card.txt files to add/update the draft data as SVars. I don't see any reason a similar in-game function could be used to pull the oracle text into the card file post-distribution.
Having the Oracle text available in the card files would benefit the deck editor immensely, as the cards don't need their objects populated just to display the right text. Therefore the card object could be created more dynamically.
I'm considering using Java to dynamically manipulate the card.txt files to add/update the draft data as SVars. I don't see any reason a similar in-game function could be used to pull the oracle text into the card file post-distribution.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: SQLite Data Engine
by Braids » 25 Jul 2011, 22:03
how about putting that oracle text into a database (sql, berkeley, whatever) outside the git repository and have forge download/update the database post-install? that would leave card txt files to just contain script code and whatever other metadata they need for rules implementation.Rob Cashwalker wrote:Quite frankly, I don't mind Oracle text residing in each supported card.txt file. What I didn't like was the data file for the entire current-known multiverse having to be distributed in the beta release.
Having the Oracle text available in the card files would benefit the deck editor immensely, as the cards don't need their objects populated just to display the right text. Therefore the card object could be created more dynamically.
those txt files are heavily tied to the current practice of loading the entire multiverse of cards.Rob Cashwalker wrote:I'm considering using Java to dynamically manipulate the card.txt files to add/update the draft data as SVars. I don't see any reason a similar in-game function could be used to pull the oracle text into the card file post-distribution.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: SQLite Data Engine
by Rob Cashwalker » 26 Jul 2011, 01:16
The trick is that I'm not sure there's any way to reliably modify an SVar of the original card object, as opposed to all the copies that get made. Modifying the card.txt file pretty much guarantees that all future copies of the card will have the right meta data. (at least following a restart...)
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: SQLite Data Engine
by Braids » 26 Jul 2011, 02:16
i'm losing steam in this discussion. can you continue with a backup plan to reduce verbatim card texts in case we get a DMCA notice?Rob Cashwalker wrote:The trick is that I'm not sure there's any way to reliably modify an SVar of the original card object, as opposed to all the copies that get made. Modifying the card.txt file pretty much guarantees that all future copies of the card will have the right meta data. (at least following a restart...)
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
28 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 36 guests