In <https://github.com/Koistinen/chess/blob/main/chess.nim> I am using the 
unicode flexibility Nim allows:
    
    
    type Piece = enum
      ♚ = -6, ♛, ♜, ♝, ♞, ♟, □, ♙, ♘, ♗, ♖, ♕, ♔
    
    type Pos* = object # 64 bytes
      bd: array[0..63, Piece]
      g50: int
      side: int
      ep: int
      castling: int
    
    proc StartingPos: Pos =
      result.bd = [
        ♖,♘,♗,♕,♔,♗,♘,♖,
        ♙,♙,♙,♙,♙,♙,♙,♙,
        □,□,□,□,□,□,□,□,
        □,□,□,□,□,□,□,□,
        □,□,□,□,□,□,□,□,
        □,□,□,□,□,□,□,□,
        ♟,♟,♟,♟,♟,♟,♟,♟,
        ♜,♞,♝,♛,♚,♝,♞,♜]
      result.castling = 0xf
    
    
    Run

In the future I am planning to use variable names like ♔sq for the square of 
the white king. My understanding is that this is not guaranteed for the future 
but it is likely that only unicode characters that are likely to be used as 
operators and similar will likely cause the code to break if used in this way.

Am I right in my understanding?

I have not seen others use Nim this way, what examples are there?

Any comments on my code? (It is supposed to prioritize clarity and not care 
about speed.)

Reply via email to