backspaces / agentscript

An Agent Based Modeling system (ABM)
http://backspaces.github.io/agentscript/
GNU General Public License v3.0
107 stars 14 forks source link

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

Closed bennlich closed 2 years ago

bennlich commented 3 years ago

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 ?

backspaces commented 3 years ago

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.

bennlich commented 3 years ago

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

backspaces commented 3 years ago

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 commented 3 years ago

It would be great to find a sweet spot!

backspaces commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

Just to be clear: turtles resolve this by using the this.atEdge = 'wrap' default. At edge for turtles has several possibilities. From docs:

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 commented 2 years ago

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