agentscript icon indicating copy to clipboard operation
agentscript copied to clipboard

wrap x and y in patches.patch(x, y)

Open bennlich opened this issue 4 years ago • 8 comments

An experiment in torus topology! With this change, patchAhead never returns undefined, which is cool. But does this break anything? How do we test, @backspaces ?

bennlich avatar Apr 29 '21 06:04 bennlich

CircleCI reports a failure, in testing. May not be a big deal.

I don't know if it would be useful, but how about a new method or flag: patchAhead(x, y, wrap=false)

Existing code would not be affected and you can try to see if it gives you enough wrap support.

backspaces avatar Apr 29 '21 15:04 backspaces

What about a new world or patches property that defines whether or not the world wraps?

bennlich avatar Apr 29 '21 15:04 bennlich

Turtles have an off-world property/function that includes wrapping. It also has clamping, bounce and any function you hand to it.

It might be confusing to have the World have something similar but not the same?

But more important, does simply changing the one method solve your problem? Or do you need more than that?

backspaces avatar Apr 29 '21 15:04 backspaces

It would be great to find a sweet spot!

backspaces avatar Apr 29 '21 15:04 backspaces

On testing: we have two sets of tests (puppeteer & unit testing of Turtle3D). These are the npm "test".

But also a test that run all the one pagers in separate browser tabs. We do this for views2, views3, views3d. It's great because it lets you run everything and look for dead tabs!

It catches LOTS of bugs.

backspaces avatar Apr 29 '21 15:04 backspaces

I think I lost a response, basically have a flag for patchAhead(x,y,wrap=false) so existing models/usage is the same but wrap is availalable.

backspaces avatar Apr 29 '21 16:04 backspaces

Just to be clear, the nifty running the models in the browser as separate tabs is not in the npm test feature, it doesn't have a "fail" that could be caught. Instead I run it by hand.

npm run2c, run3c, run3dc

backspaces avatar Apr 29 '21 16:04 backspaces

Just to be clear: turtles resolve this by using the this.atEdge = 'wrap' default. At edge for turtles has several possibilities. From docs: * atEdge can be: * - 'die' * - 'wrap' * - 'bounce' * - 'clamp' * - 'random' * - a function called with the Turtle as it's argument

Also, each breed can have different behavior.

patches.patch(x,y) does call model.world.isOnWorld(x, y) and if off world, returns "undefined".

To resolve this would be puzzling for the programmer I think. I.e. if patches "wrapped" and turtles "bounced".

backspaces avatar Jul 08 '22 17:07 backspaces

I believe the this.atEdge = 'wrap' default above resolves this.

backspaces avatar Aug 15 '22 17:08 backspaces