Hacker News new | past | comments | ask | show | jobs | submit login
Generalized Knights (lemoing.ca)
132 points by lemoing on Dec 30, 2019 | hide | past | favorite | 45 comments



Now that computers can be cheaply trained to play chess at greater than human skill level without any pre-existing knowledge of the game, has anyone looked at the question of whether the rules of chess are optimal or non-optimal under some measure of interestingness and simplicity? Like, there was some evolutionary pressure on the rules of chess to be simple and yet yield interesting games in the early days before the rules had solidified. It's now possible to take an arbitrary chess rules variant and cheaply train a machine to be (with high confidence) at least as good as a grand master would be in the universe where those rules had persisted for a thousand years. Are there better rules out there?


There was a story on here a few weeks ago [1] where retired grand master Vladimir Kramnik advocated for getting rid of castling. He worked with the Alpha Zero team to investigate the ramifications. They re-trained the network from scratch on the rule change and Kramnik claims it’ll lead to way more interesting games at the top level. It remains to be seen whether this plays out in practice, given that humans are more risk-averse (particularly in sharp positions) than Alpha Zero.

[1] https://news.ycombinator.com/item?id=21789224


Not sure if this is what you are asking, but Bobby Fischer thought the current chess rules led to boring games so he invented Fischer Random Chess.

https://en.wikipedia.org/wiki/Fischer_random_chess

It makes the games far more complex and dynamic since the pieces are placed somewhat randomly. There are other variants which remove castling which makes the game even more dynamic as it prevent castling to secure your king from the middle of the rank.


How about this simple rule, has this been tried?

To begin with each player puts one piece of their color on the board on their turn where-ever they want.

When all pieces are on table, the player who placed the last piece gets the first move, to compensate for the fact that the other player had the advantage to place the first piece on the board where-ever they wanted to.


It seems like you'd end up with a lot of pawns placed near the end of the board, quickly (instantly?) turning into queens.


Then add a rule where pawns are limited to the middle rows of the board, amd/or reduce the amount of pawns


That would seem to work.

Another approach could be that yes you must fill the first two rows of your side initially, but players would take turns in doing that piece by piece. You would see how your opponent places their army piece by piece on their side and you would adjust your placements accordingly.


I see. So I guess it wouldn't make much sense, without adding more new rules.


Thanks, I'm aware of many chess rule variants. The question is whether these have ever been studied systematically by training human-level computers on each rule set and then analyzing the games played.


> cheaply

Citation needed. AlphaZero was 'cheap' only if you have Google-scale resources at hand.


AlphaZero beat Stockfish, which is substantially more powerful than humans. Much fewer resources would be needed for human level performance.


I think moving the pawn two squares forward is one such rule innovation (as in the movement was not there in old time chess, also because of this en passant had to be implemented as well)



I first found it helpful to see how many moves it takes a knight to jump from one square to another by looking at the vertical and horizontal axes:

  |        2
  |        3
  |        2
  |        3
  |2 3 2 3 K 3 2 3
  |        3
  |        2
  |        3
Then by looking at the diagonals:

  |4       2       4
  |  2     3     2
  |    4   2   4
  |      2 3 2
  |2 3 2 3 K 3 2 3
  |      2 3 2
  |    4   2   4
  |   2    3     2
  |
  |
Finally looking at the map:

  |
  |8| 4 3 2 3 2 3 2 3
  |7| 3 2 3 4 1 2 1 4 
  |6| 4 3 2 1 2 3 2 1 
  |5| 3 2 3 2 3 K 3 2 
  |4| 4 3 2 1 2 3 2 1 
  |3| 3 2 3 4 1 2 1 4 
  |2| 4 3 2 3 2 3 2 3 
  |1| 3 4 3 2 3 2 3 2 
  | +----------------
  |   a b c d e f g h


What is the K in that last graph (F5) and why did it move compared to previous?


K is the knight or just a knight on a chess board. The numbers represent how many moves to get to each square. Hope this helps


A question I had (which might be the same as the one asked above) was why you chose to place it off-center.


It could be anywhere, the numbers will translate as well. Try to do it by hand as an exercise.


A bit unrelated, but Onitama [1] is a game based on maximizing/leveraging the "weirdness" you see in the knights. On every turn you select between two choices of movement. Difficult to describe here, but it's a really fun game.

[1] https://boardgamegeek.com/boardgame/160477/onitama


It's a two-player turn-based perfect information game. You've got five possible moves, four of which are "in play" (two each), and one of which is not. One player picks one of their cards, moves one of their pawns according to one of the card's possible destination squares, then swaps the card they just used with the "out of play" one.

You win if you take your opponent's "king pawn", or move your "king pawn" onto the enemy's vacated throne. All other pawns are disposable, as in Chess. The throne (and king pawn starting location) is in the middle of a side of the 5x5 board, opposite the enemy's throne, with two normal pawns either side of it to cover the entire edge. The king pawn has no superpowers.


That's a good synopsis of the rules.

Here's an attempt at the implications this has. It's pretty hard to lose by having your King captured, so at least at my level, what can decide games is how safely gets their king further during the inevitable large trading of pawns that happens in the middle.


The mathematics seem valid to me but the underlying concept of 'knights are weird' just doesnt ring true.

Knights move precisely the way they do because there whole concept is to be able to threaten any other piece without being threatened.

The knights movement is precisely designed to e the simplest movement possible that can fulfill this roll.

The knights ability to jump over pieces comes from the fact that there are always two ways for the knight to get to a square so no one piece can block a knight... I do understand that in theory 2 pieces could block a knight but that's the justification for its magical jumping ability.


When I referred to knights as weird, I was thinking more of how their movement patterns are incongruous with rooks/bishops/queens that move in a straight line but are blocked by pieces in the way. Their weirdness is what makes them useful (uniqueness may have been a better word).

I liked the way another commenter described it below: knights can move to the closest squares other pieces can't move to.


A fun tech side of this post is that the random walk visualization is an SVG that is generated live on the page, and hence new each time. Very cool!

The code: https://lemoing.ca/scripts/knight.js


Glad you appreciated it!


I really love the live animations, and that they don't start until you scroll to them. However as I was reading I found myself deliberately keeping very close to the bottom of the page so that I didn't trigger an animation too early and have to split my attention between it and the text. A hover-to-start function, or a pause button, would have been even better in my opinion.

Just a bit of feedback in case you're thinking of doing similar articles in the future, which I hope you are, because this was fantastic.


I know what you mean about the distracting animations! I tried to set it up so that the animations would pause if they weren't in focus. Having an option to manually trigger the animations would be a good next step.

I definitely appreciate the feedback! I'm hoping to write similar articles in the future so this is definitely helpful.


While knights move similarly, involving other rules about their movement, in Shogi and Xiangqi, I also played a chess version, which I think was Korean, (now looked it up: Ah, it is called "Janggi") with a program once. There the knights moved differently.

As a chess and chess variants player, who thinks about geometrical features of the game and pieces, especially the knight, one will have thought about most of the things described in that post, or they will seem immediately clear: "Yes ofc, that is because ...". However, if one is not a mathematician or looks at these things in detail, one might not have used the mathematical terminology or have known how to describe some criteria for a generalized knight reaching squares.

I find it also interesting, for how many chess players chess and software development in ones spare time go together. Chess can serve as a source for many interesting projects.


In shogi, the 桂馬 moves like the knight but only the two forward most moves; it can still jump. However, in shogi it can promote (most pieces in shogi can promote).

In xiangqi, the 馬 moves like the knight, in any direction, but it can be blocked (it is considered to go one orthogonal and then one diagonally outward); it is possible that one 馬s threatens the other, but not other way around because the opponent's one is blocked. (The rule that the kings are not allowed to look at each other can also have this non-mutual attacking effect, but 馬 does it even independently of that rule, and of the river.)


I don't think the knight is any more weird than the pawn. It's just weird in different ways. Pawns can move up and capture on an angle. Can en passant, can become another piece.

The King and rook can castle which involves moving multiple pieces and over each other.

So there's a lot of weirdness. But that's not to say this isn't a fascinating or worthwhile investigation.


Yeah, that's true! The reason I looked into this in the first place because the basics of movement in chess are fairly straightforward until you take a look at some of the weirder edge cases. Knights seem like the simplest out of the "weird" cases :)


I think the easiest way to conceptualize the knight's movement is that the knight moves to the nearest squares that no other piece could move to. In a sense the knight's moves are the complement of the other pieces' moves.


Yeah. Especially since they're consistently weird. Pawns have limited movements. And castling happens once.


The pawn movement is acknowledged at the end of the first paragraph:

> Pawns are a little weird, but in general they always have to move forward.


Pawns can also change to arbitrary pieces if they reach the end of the board (and I guess a Knight might be the only piece worth changing into other than a queen?)


"Under-promotion" - deliberately not changing a pawn into a queen is very rare and the unique properties of the knight do matter tactically. Under-promotion not to a knight can matter because of stalemate. (Most under-promotion is the domain of chess problems rather than games). https://www.chess.com/article/view/a-guide-to-underpromotion


I've found bishops to be more useful in end games because they can block whole diagonals and thus I will gladly exchange my knights for the opponent's bishops. Knights can be easily outmanoeuvred - it is easy to render a knight useless for one move and thereby gain some space to turn a check against you into a more favorable position.


But if the endgame has blocked pawns, the knights vs bishop is a lot more nuanced.


Rooks and bishops can be useful sometimes to turn stalemate into checkmate.


https://graebor.itch.io/field-of-fate This chess game prototype has some interesting variant pieces and a couple of other creative features: traits and relationships. It’s not particularly well balanced, but interesting to play with.

For example it has acrobats which jump to a square in a 3x3 square a certain distance away. It has a variant of a Bishop that rather than moving in a diagonal moves in an extended knights move style bumpy diagonal.

One of the things that comes out of this is that part of the power of these pieces is how many squares they can reach (as a proportion of those available on the board), and a generalisation of pieces’ moves to being slightly closer to arbitrary functions mapping squares to each other on the board.


This red to green color scheme isn't so great for colorblind people like myself. I prefer blue to red.

    // Break at scripts/knight.js:369 then run
    sC = sequentialColor;
    sequentialColor = (low, high, gap, long = false) => sC(240, 0, gap, long);


Since this is HN, I'd like to tie this into thoughts I've had on programming languages for years, which unfortunately I'm not skilled enough to rigorously prove.

I know OOP is out now-a-days, but bear with me cause I don't know of any equivalent functional papers/books to describe this idea as well. Elemental Design Patterns [1] shows a way of relating the formal lambda calculus of OOP relationships to design patterns by defining the set of the core operation relationships between types/objects/fns/etc. If you treat all objects/types/functions/etc as a cartesian grid, those core relationships define a basis vector that allows you to combine different operations that create the famous OOP design patterns. And in fact I've always thought of that basis vector the same way as the movements of a chess board, and I've wondered if there's other moves you could add to provide an easier way of hitting all squares.

Since a programming language selects specific syntax to navigate these relationships, if you could describe a language in terms of a lower level basis language, would it make it easier to see which patterns are missing from a language to help move from one concept to another? Could this help design committees select better language constructs that don't do the same things, or conflict in some way? And I'm going to go out here on a limb and hypothesize that a language is Turing Complete if it provides language constructs to allow you to hit every square on the grid, but again not enough skill to prove it myself.

Anyways, I've never thought about the modulo math of these operations like in the case of a Knight's move, so this was super interesting! Does anyone know of any good papers/talks on type theory mixed with modulo spaces, cause I'm certain you could build a different basis for more functional patterns using category theory, and now I'm curious how it might tie in.

[1] https://www.eecs.yorku.ca/course_archive/2006-07/F/6431/Stot..., https://www.amazon.ca/Elemental-Design-Patterns-Jason-Smith/...


You have night riders in fairy chess (which is a type of chess composition). https://en.wikipedia.org/wiki/Nightrider_(chess)


Very cool piece! Maybe I should try fairy chess at some point. Thank you! The explanation why it is possible to checkmate using 2 nightriders and the king is also immediately obvious, which makes them even more interesting.


Appreciate the post! I'm currently reading the Cryptonomicon and whole-heartedly recommend it to others for reading.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: