TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Find Legal Moves in Brass Birmingham with Datalog

62 pointsby gieksoszover 1 year ago

9 comments

xnover 1 year ago
I&#x27;ve become a big fan of datalog and souffle. We wrote a territory assignment application for a large healthcare organization with multiple overlapping marketing teams, where each team defines territories with various geographic and account attributes such that there&#x27;s a hierarchy of precedence for the territory that should be assigned to each account.<p>The datalog application that replaced an existing imperative solution is so much easier to understand and maintain.<p>Souffle generates c++ from the datalog program. We use SWIG to compile the c++ code into a Go application. So we have a Go application that deals with getting data in and out, and all of the business logic is defined in datalog.
评论 #38362823 未加载
nchammasover 1 year ago
This is pretty neat, and it reminds me of my experiment solving the water jug problem from Die Hard 3 using Hypothesis [1] (a Python library for property-based testing).<p>Though I doubt Hypothesis&#x27;s stateful testing capabilities can replicate all the capabilities of Datalog (or its elegance for this kind of logic problem), I think you could port the author&#x27;s expression of the game rules to Hypothesis pretty straightforwardly.<p>[1]: <a href="https:&#x2F;&#x2F;nchammas.com&#x2F;writing&#x2F;how-not-to-die-hard-with-hypothesis" rel="nofollow noreferrer">https:&#x2F;&#x2F;nchammas.com&#x2F;writing&#x2F;how-not-to-die-hard-with-hypoth...</a>
评论 #38375032 未加载
scolexover 1 year ago
I&#x27;ve implemented rules of <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Whist" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Whist</a> in prolog <a href="https:&#x2F;&#x2F;github.com&#x2F;scolex&#x2F;prolog-whist&#x2F;blob&#x2F;master&#x2F;whist.pl">https:&#x2F;&#x2F;github.com&#x2F;scolex&#x2F;prolog-whist&#x2F;blob&#x2F;master&#x2F;whist.pl</a> some yeas ago as school project. Unfortunately comments are in czech language.
评论 #38363725 未加载
mock-possumover 1 year ago
Aside from the article, I do really like the idea of implementing board game rules as a coding exercise. The only one I’ve ever been confronted with was tic tac toe, and I remember really having fun with the detecting winning moves part.
评论 #38366242 未加载
评论 #38361912 未加载
trompover 1 year ago
&gt; Have you ever tried expressing board game rules in code? Does it sound a bit tedious?<p>I expressed the logical rules of Go, which are already phrased in a concise yet mathematically rigorous way, pretty much directly into Haskell [1], which was more fun than tedium.<p>[1] <a href="https:&#x2F;&#x2F;tromp.github.io&#x2F;go&#x2F;SimpleGo.hs.txt" rel="nofollow noreferrer">https:&#x2F;&#x2F;tromp.github.io&#x2F;go&#x2F;SimpleGo.hs.txt</a>
kokkenover 1 year ago
That was an issue I encountered when writing the logic for Shogi so that I could build my own engine. Writing Python to express the logical dependencies was surprisingly unintuitive.<p>My original attempt was clunky and I rewrote the logic from scratch 2 or 3 times until I could bear look at the code and not wince.
评论 #38362533 未加载
philihpover 1 year ago
I implemented the rules of Ora et Labora. Every card&#x27;s ability is some fun puzzle of enumerating all the legal ways to play it. Some are simple like &quot;go here and you get an amount of sheep&quot;, others are &quot;you can convert an amount peat to coal here&quot; so if you have 5 coal, you can offer 0, 1, 2, 3, 4, or 5 peat as input. The more fun problems are like &quot;convert 3 different resources into 6 of any one type of basic resource&quot; or &quot;convert four to bread for 0.5 energy each&quot; and wood is worth 1 energy, peat 2, and coal 3 energy. Lots of fun combinatorics.<p>It&#x27;s all open source and playable at <a href="https:&#x2F;&#x2F;ora.kennerspiel.com" rel="nofollow noreferrer">https:&#x2F;&#x2F;ora.kennerspiel.com</a>
monlockandkeyover 1 year ago
Wait, so can this be used to model a card game like Magic The gathering?
评论 #38371133 未加载
monlockandkeyover 1 year ago
Is there an equivalent Python library to model these rules?
评论 #38373792 未加载
评论 #38371926 未加载
评论 #38369269 未加载