Print

Print


Dear Sean,

I will be grateful if you can do a jar for me.
Also if possible can you look at the same area in the von Neumann neighbourhood as it is behaving in the same way.

Kind regards,

Stewart.

On 11 May 2018 at 20:43, Sean Luke <[log in to unmask]> wrote:
I just nailed a dumb bug in width vs height for grids using moore neighborhoods.  The new version is out on the repository right now.  If you need me to build you a jar file, I can do that.  Let's see if it fixes things for you.

Sean

> On May 11, 2018, at 3:17 PM, Stewart Aitken <00000068a29a4109-dmarc-[log in to unmask]> wrote:
>
> Hello,
>
> Can anyone help me to overcome this issue, I can post the full code if required
>
> Kind regards
>
> Stewart.
>
> ObjectGrid2D is shown correctly within the GUI.
> I use the same code for a horizontal rectangle and a vertical rectangle with the following differences:
>
> Grid Width and Grid Height are reversed.
> Random start X and start Y
>
> Here is the neighbourhood function I use and the function to get the next cell.
> hop = dist.
>
>  mySpace.getMooreNeighbors(myX, myY, hop, Grid2D.BOUNDED, false, result, xNeighbors, yNeighbors);
>
>  nextX = mySpace.tx(xNeighbors.get(i));
>  nextY = mySpace.tx(yNeighbors.get(i));
>  if (mySpace.field[nextX][nextY]== null) {
>      mySpace.field[nextX][nextY] = child;
>      child.myX = nextX;
>      child.myY = nextY;
>      theAgents.add(child);
>      counter++;
>      break;
>     }
>   } myX = nextX; myY = nextY;
> }
>
>
> Horizontal works correctly at all times and Vertical always gives an incorrect Y position at the start.
> Also Y coordinate does not go beyond the X coordinate size. Thus we see a square area occupied equivalent of X squared.
>
> Regardless of the grid sizes the same behaviour is observed. In addition when I use the same code for the von Neumann Neighbourhood the same errors are observed.
>
> "mySpace.getVonNeumannNeighbors(myX, myY, hop, Grid2D.BOUNDED, false, result, xNeighbors, yNeighbors);"
>
> This is the output obtained for the Moore neighbourhood:
>
> Horizontal rectangle. Initiate and one step.
>
> GridWidth = 10, GridHeight = 5.
> Start X = 3, Start Y = 3.
> x = 2 : y = 2
> x = 2 : y = 3
> x = 2 : y = 4
> x = 3 : y = 2
> x = 4 : y = 4
> x = 3 : y = 4
> x = 4 : y = 2
> x = 4 : y = 3
> nextX = 2 : NextY =  : 2
>
> Vertical rectangle. Initiate and one step.
>
> GridWidth = 5, GridHeight = 10.
> Start X = 2, Start Y = 8
> x = 1 : y = 7
> x = 1 : y = 8
> x = 1 : y = 9
> x = 2 : y = 7
> x = 3 : y = 9
> x = 2 : y = 9
> x = 3 : y = 7
> x = 3 : y = 8
> nextX = 1 : NextY = 2
>
> Vertical rectangle. Second step.
> This is correct.
>
> Start X = 1, Start Y = 2
> x = 0 : y = 1
> x = 0 : y = 2
> x = 0 : y = 3
> x = 1 : y = 1
> x = 2 : y = 3
> x = 1 : y = 3
> x = 2 : y = 1
> x = 2 : y = 2
> nextX = 0 : NextY = 1



--



EMAIL DISCLAIMER http://www.york.ac.uk/docs/disclaimer/email.htm