robbyRobot/robbyRobot3.js
// Function to find cell with the lowest total cost from costs
Function to find cell with the lowest total cost from costs
Function to find cell with the lowest total cost from costs
function lowestCostCell(costs, processed) {
      const costedCells = Object.keys(costs)
      let lowest = null
      let i=0
      let cellId
      const len=costedCells.length
      for (; i<len; i++) {
        cellId = costedCells[i]
        if (lowest === null || ( costs[cellId]+calcH(cells[cellId])) < (costs[lowest]+calcH(cells[lowest])) ) {      
          if (!processed.includes(cellId)) {
            lowest = cellId
          }
        }
      }
      return lowest
    }
function lowestCostCell ( costs , processed ) { const costedCells = Object . keys ( costs ) let lowest = null let i = 0 let cellId const len = costedCells . length for ( ; i < len ; i ++ ) { cellId = costedCells [ i ] if ( lowest === null || ( costs [ cellId ] + calcH ( cells [ cellId ] ) ) < ( costs [ lowest ] + calcH ( cells [ lowest ] ) ) ) { if ( ! processed . includes ( cellId ) ) { lowest = cellId } } } return lowest }
Function to find cell with the lowest total cost from costs
Function to find cell with the lowest total cost from costs
// setup cached loop settings // this approach avoids referencing variables // in the function arguement object which gives // some speed advantages // check the cellId has not been processed (or is blocked)