Skip to content

Optimize the solver algorithm #1

@StTronn

Description

@StTronn
  • Improve searching for visited boards using hashing

the current traverses the array visited containing boards O(n).This operation is done for every next move possible
let visited=[]; for(let board of visited) if(isBoardSame(board,child)) found=true;
this could be improved by hashing make visited a hash table,to implement it a unique key needs to be created for every board this can be done using creating string in sequence of the array

  • change priority to hamming distance from moves+hamming distance

this.priority=this.hamming();
change it to
this.priority=this.move+this.hamming();
start node would have 0 moves for every child moves =parent.moves+1

  • use Manhattan distance instead of hamming distance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions