Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1024761 // chess_makeFEN

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (1895L/12K).

sS chess_makeFEN(LL<S> recognized) {
  if (empty(recognized)) null;
  new LS out;
  for (LS row : recognized) {
    int i = 0;
    new StringBuilder buf;
    while (i < 8) {
      int j = smartIndexOfNot(row, "empty", i);
      if (j > i) {
        buf.append(j-i);
        i = j;
      } else {
        S p = row.get(i++);
        S piece = secondWord(p);
        char c = eq(piece, "knight") ? 'n' : first(piece);
        if (startsWith(p, "white")) c = upper(c);
        buf.append(c);
      }
    }
    out.add(str(buf));
  }
  ret join("/", out);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024761
Snippet name: chess_makeFEN
Eternal ID of this version: #1024761/2
Text MD5: 1a8bb4cb2687abd05bdf517964448922
Transpilation MD5: dd9294795a2cc245ca64874bc9d76320
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-24 17:36:17
Source code size: 575 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 170 / 241
Version history: 1 change(s)
Referenced in: [show references]