From cb0d261441db4f5385ceecc690816a83a2908dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n?= <58742147+dip000@users.noreply.github.com> Date: Wed, 16 Feb 2022 12:59:14 -0600 Subject: [PATCH] some fixes --- MapBuilderForWeb/MultimapMechanics.js | 68 ++++++++++++++++----------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/MapBuilderForWeb/MultimapMechanics.js b/MapBuilderForWeb/MultimapMechanics.js index 016bdcc..71e130a 100644 --- a/MapBuilderForWeb/MultimapMechanics.js +++ b/MapBuilderForWeb/MultimapMechanics.js @@ -113,8 +113,15 @@ const mapLengthRows = occupancyMap.length; const mapLengthCols = occupancyMap[0].length; - const islandSizeRows = Math.round(mapLengthRows/nrows) - (nrows-1) + 1; - const islandSizeCols = Math.round(mapLengthCols/ncols) - (ncols-1) + 1; + //Not considenring the space occupied for map cuts + const availableRows = mapLengthRows-(nrows-1); + const availableCols = mapLengthCols-(ncols-1); + + //Number of rows, cols of each island and its residue due map size + const islandSizeRows = Math.floor( availableRows/nrows ); + const islandSizeCols = Math.floor( availableCols/ncols ); + const residueRows = availableRows % nrows; + const residueCols = availableCols % ncols; let outputData = new Array(); @@ -125,25 +132,32 @@ continue; } - let row = historyOfPlacements[i].positionX; - let col = historyOfPlacements[i].positionY; + //TODO: positionsX and positionsY are not always a part of the item. Use coordenates.x[0] instead + let row = historyOfPlacements[i].coordenates.x[0]; + let col = historyOfPlacements[i].coordenates.y[0]; for(var r=0; rislandSizeRows*r && rowislandSizeCols*c && col