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?
Find Legal Moves in Brass Birmingham with Datalog
11–20 of 26 posts
Re: Find Legal Moves in Brass Birmingham with Datalog
#12Re: Find Legal Moves in Brass Birmingham with Datalog
#13I've implemented rules of https://en.wikipedia.org/wiki/Whist in prolog https://github.com/scolex/prolog-whist/blob/master/whist.pl some yeas ago as school project. Unfortunately comments are in czech language.
Re: Find Legal Moves in Brass Birmingham with Datalog
#14Though I doubt Hypothesis'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's expression of the game rules to Hypothesis pretty straightforwardly.
[1]: https://nchammas.com/writing/how-not-to-die-hard-with-hypoth...
Re: Find Legal Moves in Brass Birmingham with Datalog
#15It's all open source and playable at https://ora.kennerspiel.com
Re: Find Legal Moves in Brass Birmingham with Datalog
#16Re: Find Legal Moves in Brass Birmingham with Datalog
#17Aside 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.
[1] https://github.com/DylanSp/tic-tac-toe-react/blob/master/src...
Re: Find Legal Moves in Brass Birmingham with Datalog
#18Earlier quoted context omitted.
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
#19Re: Find Legal Moves in Brass Birmingham with Datalog
#20Is there an equivalent Python library to model these rules?