ghohl30 / Hivemind

python implementation of the board game Hive
0 stars 0 forks source link

Profile hive.py and try to identify bottlenecks #7

Closed ghohl30 closed 1 month ago

ghohl30 commented 5 months ago

We need to improve the performance of the Hive game by identifying and addressing bottlenecks in the code. The goal is to create a brief report on the current state of efficiency and open issues for clear bottlenecks.

Tasks:

ghohl30 commented 1 month ago

Profiler results:

Total time: 52s Most time consuming:

What to do about this?

The deepcopy takes long because i am using a lot of mutable datastructures to hold my game state. I want to implement a more imutable functial approach in order to get away with a shallower way of copying games. This might also already help make the legal moves checks more efficient.

In order to increase the efficiency there I will try to go through the logic and see if I can make that simpler. I will try to think about not recalculating all possible moves from scratch. And i will try to minimize the circular references to the minimum.

Issue 1: Mutable --> immutable and reduce circular references Issue 2: Improve copy methods Issue 3: Further investigate all_legal_move execution times and find bottlenecks