heroku wrote: ↑Sat May 02, 2026 11:04 pm
Hello I have a script written in a language I call gofchess, that attempts to describe chess tactics it looks like this:
if has_fork_with_checks_and_hanging_for_only_king_evades(bishop, bishop2, king, rook) then
forall king_evades(king, king2) then
if captures(bishop2, rook_bishop3) then
if push_attacks(pawn, pawn2, bishop3) then
if captures(bishop3, pawn2_bishop4) then
if promotes(pawn, pawn2_queen) then
if captures(king3, queen_king4) then
The if keyword(Variables) then structure is fixed and used everywhere, keyword are the second part of the language defined like this:
def triple_fork_with_checks_for_only_king_evades(From, To, King, ForkB, ForkC)
move(From, To)
attack(To, King)
attack(To, ForkB)
attack(To, ForkC)
no_captures(To)
no_blocks_check(To, King)
no_push_blocks_check(To, King)
For example this keyword when defined can be used in the if then form. And the body of the definition uses builtin keywords with specific meanings, where a move(From, To) is a move happening, and attack(To, King) meaning filters To attacks King without moving anything.
The execution is about unification of variables similar to Prolog. Where in the definition Uppercase variable names are used, and if then form uses lower case piece roles, which is run against a chess position and the piece roles are bound to square names.
There is no formal specification or anything, but I hope you get the gist of how it works. I've built several iterations of this working in both Typescript and C++ very efficiently.
I could write a lot of in this language to extract the solution lines of chess puzzles (taken from Lichess DB). But the problem is as the rules get more and more, there are false positive matches, and it grows.
If you are interested in this idea, or have any constructive feedback, I am open to a discussion.
Here's the MIT License form of the engine written in Typescript:
https://github.com/eguneys/hopefox/blob ... second.gof