Advertisement
pierrotdu18

Untitled

Aug 16th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function isChip(tool)
  2. {
  3.     return tool<0;
  4. }
  5.  
  6. function getCellsToUseTool(tool, leek)
  7. {
  8.     return isChip(tool) ? getCellsToUseChip(-tool, leek) : getCellsToUseWeapon(leek);
  9. }
  10.  
  11. function getNearestCellToUseToolFromCell(tool, cellFrom, leek)
  12. {
  13.     var array = [];
  14.     for (var cell in getCellsToUseTool(tool, leek))
  15.     {
  16.         array[cell] = getPathLength(cellFrom, cell);
  17.     }
  18.     return search(array, arrayMin(array));
  19. }
  20.  
  21. function getNeededMPsToExecuteCombo(combo, leek)
  22. {
  23.     var MPsNeeded = 0;
  24.     var previousCell = getCell();
  25.     for (var tool in combo)
  26.     {
  27.         var cellToUseTheTool = getNearestCellToUseToolFromCell(tool, previousCell, leek);
  28.         MPsNeeded += getPathLength(previousCell, cellToUseTheTool);
  29.         previousCell = cellToUseTheTool;
  30.     }
  31.     return MPsNeeded;
  32. }
  33.  
  34. // Le corps :
  35.  
  36. for (var key : var possibleCombo in permutations)
  37. {
  38.         permutationsNeededMPs[key] = getNeededMPsToExecuteCombo(possibleCombo,leek);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement