Conworld Codex 2018-09-22
In this post:
- Prolog exists!
- Prolog is... extremely suited to Conworld Codex.
- Turns out I was so distracted with stuff that was not "modeling my domain information", that I didn't... model... my domain information.
I recently remembered that I've occasionally tried to get into logic programming with Prolog, and it occurred to me that using Prolog might allow me to have Conworld Codex functionality without messing with GUI code.
So, let's try porting the bits of Conworld Codex I care about to SWI-Prolog...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | event(Cause) :- causes(Cause,_,_,_). event(Effect) :- causes(_,Effect,_,_). event(Part) :- makes_up(Part,_,_,_). event(Whole) :- makes_up(_,Whole,_,_). event(Event) :- topic_of(Event,_,_,_). topic(Topic) :- topic_of(_,Topic,_,_). teller(Teller) :- causes(_,_,Teller,_). teller(Teller) :- makes_up(_,_,Teller,_). teller(Teller) :- topic_of(_,_,Teller,_). commentary(Commentary) :- causes(_,_,_,Commentary). commentary(Commentary) :- makes_up(_,_,_,Commentary). commentary(Commentary) :- topic_of(_,_,_,Commentary). topic_of( salt_mill_critiqued, salt, the_omniscient_narrator_from_the_lua_version, "Deoshen Aternabel's salt mill \c design was intended to use sun, \c wind, etc, to extract salt from \c the ocean."). topic_of( salt_mill_critiqued, deoshen_aternabel, the_omniscient_narrator_from_the_lua_version, "Deoshen Aternabel designed a \c 'salt mill'. Despite the care he \c put into its architecture, he \c never addressed the fact that \c his design was impractical in \c the cool, moist climate of Gaewon."). topic_of( aternabel_at_spansen, atsimats_aternabel, the_omniscient_narrator_from_the_lua_version, "Admiral Atsimats Aternabel saw \c Gaewon's victory over Bilus as a \c chance to bring glory to his \c family by realizing Deoshen's \c design. He framed it in terms of \c the glory of Gaewon."). causes( bilusic_population_boom, bilusic_expansion, the_omniscient_narrator_from_the_lua_version, "The reigning belief in Bilus's \c government was that war would \c address the crowding, either \c through colonization or attrition"). causes( salt_mill_critiqued, aternabel_at_spansen, the_omniscient_narrator_from_the_lua_version, "Admiral Atsimats Aternabel \c wishes to realize the designs of \c his grandfather(?)"). causes( bilusic_expansion, gaewom_empire, the_omniscient_narrator_from_the_lua_version, "The defeat of the Bilusic navy \c gives Gaewon the confidence to \c expand, itself"). makes_up( aternabel_at_spansen, gaewon_empire, the_omniscient_narrator_from_the_lua_version, "Admiral Atsimats Aternabel's \c speech was part of a general \c sentiment that Gaewon had \c 'proven itself' by defeating Bilus"). makes_up( plague_of_gaewon, gaewon_empire, the_omniscient_narrator_from_the_lua_version, "The Plague threw the island of \c Gaewon into chaos, severing \c administrative ties with the colonies"). |
... Well. That was insultingly easy compared to trying to role the detailed relational stuff myself. The first twelve clauses are, as near as I can tell, everything I cared about from the Python version. I'm not certain, because I went a few months I think, without looking at the code, so it's not obvious to me what I was doing back then. The other issue is that the Lua version predates my big idea of "It should focus on collating in-universe perspectives", so the data doesn't make any sense. I'm going to try redoing it with the text version.
I have a rough draft of the text version in Prolog now. It turns out it's somehow even less suited to the above format, so I'm going to need to think long and hard about what I actually want to represent, and how. Fortunately, expressing this stuff in Prolog appears to be extremely low-friction, so I'm really happy I finally thought to try this out.