Skip to content

πŸš€ Parallelisation + improvements to algorithmic + representations

Latest

Choose a tag to compare

@raj-open raj-open released this 07 Sep 19:31
2936efc

Qualitatively improved the GS algorithm as follows:

  1. we separately keep track of the obstacle and the dithered obstactle, instead of computing this for every pair of pieces. This results in a linear time improvement.

  2. instead of the order in the depth-first tree search, we dynamallyically sort to prioritise placing pieces, for which the number of possibilities is the fewest. This results in a significant time improvement.

  3. we implemented parallelisation which allows us to efficiently determine all solution in a short amount of time.

In addition to this, the logging of solutions has improved. E.g.

just run-rust GeniusSquare A5 B1 C3 C6 D2 E4 F1

results in

Roll: A5 B1 C3 C6 D2 E4 F1

Problem:
      ╔═══╦═══╦═══╦═══╦═══╦═══╗
      β•‘ A β•‘ B β•‘ C β•‘ D β•‘ E β•‘ F β•‘
      β•šβ•β•β•β•©β•β•β•β•©β•β•β•β•©β•β•β•β•©β•β•β•β•©β•β•β•β•
╔═══╗     ┼───┼           ┼───┼
β•‘ 1 β•‘     β”‚ β–  β”‚           β”‚ β–  β”‚
╠═══╣     ┼───┼   ┼───┼   ┼───┼
β•‘ 2 β•‘             β”‚ β–  β”‚        
╠═══╣         ┼───┼───┼        
β•‘ 3 β•‘         β”‚ β–  β”‚            
╠═══╣         ┼───┼   ┼───┼    
β•‘ 4 β•‘                 β”‚ β–  β”‚    
╠═══╣ ┼───┼           ┼───┼    
β•‘ 5 β•‘ β”‚ β–  β”‚                    
╠═══╣ ┼───┼   ┼───┼            
β•‘ 6 β•‘         β”‚ β–  β”‚            
β•šβ•β•β•β•         ┼───┼            

Compute solution ... found 69 solutions.
Time for 1st solution:      7.499ms
Average time per solution:  2.555521ms
Total time:                 176.331ms

Solution 1:
      ╔═══╦═══╦═══╦═══╦═══╦═══╗
      β•‘ A β•‘ B β•‘ C β•‘ D β•‘ E β•‘ F β•‘
      β•šβ•β•β•β•©β•β•β•β•©β•β•β•β•©β•β•β•β•©β•β•β•β•©β•β•β•β•
╔═══╗ ┼───┼───┼───┼───┼───┼───┼
β•‘ 1 β•‘ β”‚ 1 β”‚ β–  β”‚ 2 β”‚ Z   Z β”‚ β–  β”‚
╠═══╣ ┼───┼───┼   ┼───┼   ┼───┼
β•‘ 2 β•‘ β”‚ X   X β”‚ 2 β”‚ β–  β”‚ Z   Z β”‚
╠═══╣ β”Ό       ┼───┼───┼───┼───┼
β•‘ 3 β•‘ β”‚ X   X β”‚ β–  β”‚ 3   3   3 β”‚
╠═══╣ ┼───┼───┼───┼───┼───┼───┼
β•‘ 4 β•‘ β”‚ 4   4   4   4 β”‚ β–  β”‚ L β”‚
╠═══╣ ┼───┼───┼───┼───┼───┼   β”Ό
β•‘ 5 β•‘ β”‚ β–  β”‚ C β”‚ T   T   T β”‚ L β”‚
╠═══╣ ┼───┼   ┼───┼   ┼───┼   β”Ό
β•‘ 6 β•‘ β”‚ C   C β”‚ β–  β”‚ T β”‚ L   L β”‚
β•šβ•β•β•β• ┼───┼───┼───┼───┼───┼───┼

which eases readability. We also fixed the use of terminal fonts, so the latter appears in the console with colour coded pieces.