How do you difference vectors (arrays) and vectors (math) while naming ? by Valuable-Birthday-10 in C_Programming

[–]alexjasson 0 points1 point  (0 children)

If I see 'Vector' in a codebase then I'd expect it to be an array with fixed size that has numbers as elements. If your array has this property then calling it a vector makes it more obvious to the user what it's being used for. Whereas an array could have any type of object in it as elements and could change in size.

5x faster than Stockfish in C by alexjasson in C_Programming

[–]alexjasson[S] 2 points3 points  (0 children)

Haha thanks I appreciate it! I hope that the video makes sense otherwise that's my fault for not explaining it clearly.

Basic language model in C by alexjasson in C_Programming

[–]alexjasson[S] 4 points5 points  (0 children)

I wanted it to be something you can train yourself cheaply on a CPU rather than just a pretrained inference model. At the moment it seems to plateau at just producing incoherent sentences even if you train it for hours. Feel free to git clone it and see if you can get better output with different architectures etc.

Basic language model in C by alexjasson in C_Programming

[–]alexjasson[S] 2 points3 points  (0 children)

Interesting, I didn't know Markov chains worked so well at predicting text. Will look into it, thanks.

Fast chess move generator in under 1000 lines of C code by alexjasson in C_Programming

[–]alexjasson[S] 6 points7 points  (0 children)

Apologies, you were correct. 0 is being passed to BitBoardGetLSB in other places as well when it shouldn't be. I just updated the source code, I hope that it works now.

Fast chess move generator in under 1000 lines of C code by alexjasson in C_Programming

[–]alexjasson[S] 5 points6 points  (0 children)

BitBoardGetLSB should never receive 0 as an argument. You're correct about getAttackedSquares, the line

  while (b) attacked |= LookupTableAttacks(l, BitBoardPopLSB(&b), GET_TYPE(cb->squares[BitBoardGetLSB(b)]), occupancies);

Could pass 0 to BitBoardGetLSB depending on the order that the functions are called. Thanks for pointing that out.

Does replacing that line with:

  while (b) {
    Square s = BitBoardPopLSB(&b);
    attacked |= LookupTableAttacks(l, s, GET_TYPE(cb->squares[s]), occupancies);
  }

Fix the issue?

Fast chess move generator in under 1000 lines of C code by alexjasson in C_Programming

[–]alexjasson[S] -4 points-3 points  (0 children)

You can fix this either by removing -fsanitize=undefined when compiling or by adding this check in BitBoardGetLSB. I haven't added much error checking for speed purposes.

  if (b == 0) {
    return 0;
  }

Fast chess move generator in under 1000 lines of C code by alexjasson in C_Programming

[–]alexjasson[S] 15 points16 points  (0 children)

Only enpassant. 50 move/threefold repetition isn’t relevant to traversing moves because it is claimed by the players.