JamesCarr1 / Chess_AI

0 stars 0 forks source link

Compare dict vs. bitboard for tensor conversion #5

Closed JamesCarr1 closed 1 year ago

JamesCarr1 commented 1 year ago

Currently, conversion from Board object to a tensor (through as_tensor) is very slow. Compare two options:

JamesCarr1 commented 1 year ago

Running the conversion 10000 times each yields the following results:

fen_method took 0.3049468994140625 seconds to execute 10000 times.

dict_method took 0.14049696922302246 seconds to execute 10000 times.

my_bb_method took 0.09064698219299316 seconds to execute 10000 times.

ex_bitboard_method took 0.12563681602478027 seconds to execute 10000 times.

Clearly my_bb_method is the best.

JamesCarr1 commented 1 year ago

Now further improving the efficiency of my_bb_method. Previously, was defining the lists pieces and colours INSIDE the function. Now comparing two options:

JamesCarr1 commented 1 year ago

Ever so slightly slower passing them in rather than using variables.py:

Therefore, use variables.py