Live data from Hacker News

Find Legal Moves in Brass Birmingham with Datalog

blog.pzakrzewski.com

1–10 of 26 posts

Re: Find Legal Moves in Brass Birmingham with Datalog

#3

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.

I've been playing around with making a version of tic-tac-toe that's interesting to grown-ups. Experimenting with rules a lot as you'll see. (I think 1357 is probably the best but not sure.)

https://5-by-5.edjohnsonwilliams.co.uk

https://github.com/edjw/5_by_5_tictactoe

Re: Find Legal Moves in Brass Birmingham with Datalog

#4
> Have you ever tried expressing board game rules in code? Does it sound a bit tedious?

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.

[1] https://tromp.github.io/go/SimpleGo.hs.txt

Re: Find Legal Moves in Brass Birmingham with Datalog

#5
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.

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.

Re: Find Legal Moves in Brass Birmingham with Datalog

#6
post #5

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. 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.

Did you publish the code somewhere?

Re: Find Legal Moves in Brass Birmingham with Datalog

#7
post #3

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.

I've been playing around with making a version of tic-tac-toe that's interesting to grown-ups. Experimenting with rules a lot as you'll see. (I think 1357 is probably the best but not sure.) https://5-by-5.edjohnsonwilliams.co.uk https://github.com/edjw/5_by_5_tictactoe

That's really cool! Need to find someone to play this with now :)

Though the counting seems a bit weird. Two overlapping lines of 5 seems to count as "1 two, 2 five". I also managed to get two overlapping fours to count as "2 two, 2 four". Maybe I just don't understand how it's supposed to work?

Re: Find Legal Moves in Brass Birmingham with Datalog

#8
I'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's a hierarchy of precedence for the territory that should be assigned to each account.

The datalog application that replaced an existing imperative solution is so much easier to understand and maintain.

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.

Re: Find Legal Moves in Brass Birmingham with Datalog

#9
post #8

I'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's a hierarchy of precedence for the territory that should be assigned to each account. The datalog application that replaced an existing imperative solu…

this is a pretty interesting workflow. I was indeed thinking how one would integrate Souffle into a bigger application.

Re: Find Legal Moves in Brass Birmingham with Datalog

#10
post #9
post #8

I'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's a hierarchy of precedence for the territory that should be assigned to each account. The datalog application that replaced an existing imperative solu…

this is a pretty interesting workflow. I was indeed thinking how one would integrate Souffle into a bigger application.

Here's a simple example: https://github.com/cwarden/souffle-go-example

It illustrates how you can have the Souffle program load its data from SQLite databases, or how you can work with tuples and relations from Go.

Post reply on HN