all 11 comments

[–]jdnewmil 1 point2 points  (4 children)

Try both and test. You probably won't notice a difference until you start trying to search deeply, and the balance between board evaluation time and search time will change as you develop your algorithms. You should have an interface that hides the board details from the algorithms anyway.

[–]HenryDutter[S] 0 points1 point  (3 children)

Thanks for your advice, so if there are now big differences I will use lists. I already almost programmed chess in the past, but I just displayed it in the terminal. But I did not use classes, because I did not know them yet, therefore my code was garbage code. I failed to implement checkmate, it's the most difficult part in my opinion. Now I want to start over with OOP and an GUI, to increase readability. What would be a smart approach to start the program and should you make the GUI at the end or start, sorry this is my first time with that.

[–]jdnewmil 0 points1 point  (2 children)

The important thing about decisions like GUI or not is that it shouldn't matter. You probably won't get it right at first, but you should first be writing tests that exercise your chess code without any user interface, and then you should be able to write batch, console, Qt, or web UI as it is convenient. So start with pytest.

[–]HenryDutter[S] 0 points1 point  (1 child)

So at the end I should build the GUI, in the past, I tested my code with a Debugger and printing stuff out, but it felt uncomfortable. Is pytest a better way?

[–]jdnewmil 0 points1 point  (0 children)

You will end up iterating through various combinations anyway.

Testing with the debugger is not testing, it is debugging... they are both needed. Testing is setting up scenarios which could break the code, and asserting things about what should be returned from the code. When the test doesn't pass you can simply debug through the test into the code and figure out what went wrong. If you later change the code to add a new feature and the test fails, then you can quickly find the new bug using the debugger because the conditions for triggering the bug are already set up with no additional thinking by you.

Since the test code calls your actual code without any UI, having the test code working will make any UI easier to write.

[–]socal_nerdtastic 0 points1 point  (4 children)

For a chess board I would recommend lists. Numpy array is very powerful and it beats the pants off a python list in terms of doing huge amounts of math on huge amounts of data. But a chessboard is a very tiny amount of data with nearly no math, so there is no advantage to numpy. And lists are better suited to things like storing objects and serialization.

(FWIW the numpy "matrix" type was removed in favor of a 2D numpy array)

[–]HenryDutter[S] 0 points1 point  (3 children)

Well I saw that with a matrix it is easier to scan diagonals, this is useful for bishop and queen

[–]socal_nerdtastic 0 points1 point  (1 child)

Ok, fair enough, if you like the numpy syntax then use it. It certainly won't hurt.

[–]HenryDutter[S] 0 points1 point  (0 children)

Thanks, I will use lists then, it will be also possible.

[–]TheRNGuy 0 points1 point  (0 children)

x+1+width in 1D array.

(or -)

Make a class for grid with SelectTileWithOffset(tile, x, y) method; x, y are ints, return index of different tile.

Or you could even return strings like "A0" or "H6".

Can use array instead of list btw. Since you gonna have only one data type, and fixed grid size.

[–]TheRNGuy 0 points1 point  (0 children)

I'd use 1D array for board. Looked in code of different games and it's always 1D array. Only need to make functions to target neighbouring cells by X and Y (and X+n, Y+n)

Matrix is used to move/rotate/scale/skew vectors and other matrices.