Thanks, sure let me share more details, especially because I ran into another issue where I have a similar query but I wan to bind the possible dict values to variables.
So the problem I solve is determining trading card quality. In this particular case yugioh cards. I have 8 attributes: name, artwork, artwork_border, attribute_symbol,stars, lore_border, card_border, card_surface. Each attribute can have a different set of possible values. First I was using a list, but I ran into issues with some predicates where the actual and defined order was not the same. Of course it is possible I did something wrong. And I also felt the list just not descriptive enough. So these are the Dicts, and there are a bunch of possible rarities which is a unique combination of the settings of those 8 attributes.
The predicates are something like (it is different compared to the example above, mostly for readability, otherwise its hard to spot which fields are different. This was also a problem with the list solution):
card_rarity(Options,normal_rarity) :-
print_message(information, format(" Card: ~w", Options)),
valid_card(Base),
Options = Base.
card_rarity(Options,rare_rarity) :-
valid_card(Base),
member(Options, [Base.put(name,silver_holofoil), Base.put(name,black_holofoil)]).
card_rarity(Options,holofoil_rare_rarity):-
valid_card(Base),
Options = Base.put(_{artwork:holofoil_background,card_surface:holofoil}).
card_rarity(Options,ultra_rare_rarity):-
valid_card(Base),
Options = Base.put(_{name:gold_holofoil,artwork:holofoil_background}).
/* main_subject_coated_in_raised_glossy_varnish and embossed_holofoil_background might be always there */
card_rarity(Options,ultra_rare_rarity):-
valid_card(B),
put_dict(_{name:gold_holofoil, artwork_border:embossed_gold_holofoil, attribute_symbol:embossed_gold_holofoil, stars:embossed_gold_holofoil},B,Base),
member(Options, [
Base.put(_{artwork:embossed_holofoil_background, card_surface:sprakle}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, card_surface:sprakle}),
Base.put(_{artwork:embossed_holofoil_background, lore_border:embossed_gold_holofoil, card_surface:sprakle}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, lore_border:embossed_gold_holofoil, card_border:embossed_gold_holofoil, card_surface:sprakle}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, lore_border:embossed_gold_holofoil, card_border:embossed_gold_holofoil, card_surface:sprakle}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, lore_border:normal, card_border:embossed_gold_holofoil, card_surface:sprakle}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, lore_border:normal, card_border:embossed_gold_holofoil, card_surface:sprakle}),
Base.put(_{artwork:embossed_holofoil_background}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish}),
Base.put(_{artwork:embossed_holofoil_background, lore_border:embossed_gold_holofoil}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, lore_border:embossed_gold_holofoil, card_border:embossed_gold_holofoil}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, lore_border:embossed_gold_holofoil, card_border:embossed_gold_holofoil}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, lore_border:normal, card_border:embossed_gold_holofoil}),
Base.put(_{artwork:main_subject_coated_in_raised_glossy_varnish, lore_border:normal, card_border:embossed_gold_holofoil})
]).
card_rarity(Options,collectors_rare_rarity):-
valid_card(B),
put_dict(_{name: rainbow_holographic, artwork_border:embossed_holofoil, attribute_symbol:embossed_sparkle, stars:embossed_sparkle, lore_border:embossed_holofoil,card_border: holographic_finger_printing, card_surface:sprakle},B,Base),
member(Options, [
Base.put(_{artwork:embossed_holofoil_background}), /* might be just one these two combined */
Base.put(_{artwork:main_subject_embossed_in_holofoil})
]).
This also contains the biggest and worst. It is pretty explicit now, but as you can see it can be simplified by just ignoring a bunch of fields. For now it is like that so I can also get myself familiar with these things.
About the UI and the features:
It is a console app which shows you the attributes and their possible values where you can select, and as you select it shows you what are the matching rarities so far. Ideally you end up with one, or the unknown_rarity which is the catch all.
The reason why I ran into the new problem, I realized it would be cool if I can disable (or remove) options which have no chance to lead to a known rarity, so I decided to bind all unset attribute to a variable instead of the ignore and set the rest. BTW the prolog.Var() thing worked. Thank you
To answer your questions:
- The dict is a relatively small set I think
- It is not fully dynamic
- the number of rarity predicates is 24