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).

1  
sS chess_makeFEN(LL<S> recognized) {
2  
  if (empty(recognized)) null;
3  
  new LS out;
4  
  for (LS row : recognized) {
5  
    int i = 0;
6  
    new StringBuilder buf;
7  
    while (i < 8) {
8  
      int j = smartIndexOfNot(row, "empty", i);
9  
      if (j > i) {
10  
        buf.append(j-i);
11  
        i = j;
12  
      } else {
13  
        S p = row.get(i++);
14  
        S piece = secondWord(p);
15  
        char c = eq(piece, "knight") ? 'n' : first(piece);
16  
        if (startsWith(p, "white")) c = upper(c);
17  
        buf.append(c);
18  
      }
19  
    }
20  
    out.add(str(buf));
21  
  }
22  
  ret join("/", out);
23  
}

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: 172 / 244
Version history: 1 change(s)
Referenced in: [show references]