We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi All, I am doing an agent-based model in Go (golang.org). I am a final year CS student working on a research project for in conjunction with researchers in the Biology department at my university.
I need a web-client viewport which will render the 'state' (i.e. position etc) of each agent within the 2D environment which is handled on the server. There are tens of thousands of agents (potentially millions) which necessitates a true concurrent programming and runtime environment (hence why I am doing it in Go) – this is way too much overhead to be done entirely in a sketch or even dynamically on the client side. Therefore the actual drawing is offloaded to the client, but all the computation (beyond JSON unmarshalling and coordinate translation to the world space of the sketch/viewport) is done on a dedicated server.
What I want to draw inside a sketch (viewport) is very simple: points, with varying stroke widths and colours. That's it. I just need to draw tens of thousands of them constantly, updating as they change position. All the computation which determines where those points are before being drawn is delivered via a JSON from the server. What I need is for the P5 sketch to do a bit of translation from the JSON object into some (predeclared and global) arrays of x,y pairs and just draw points at those coordinates by iterating through the said arrays. I don't need to block draw() from being called until the GET request is filled and the JSON has been processed, it should just render the contents of the arrays in the state they currently are in. So, there are two continual processes occurring by the client.
FIRST: LOOP( requesting the JSON data, processing it) SECOND: DRAW LOOP.
Anyone have any experience with something like this? Maybe there is a better and simpler way to do it?
I would say that the obvious alternative would be to bypass the seperate request for the JSON entirely and just have a web socket open so you are directly getting the array data from a function call inside the draw loop. I.e. via http you get the iteration range, then a value for the co-ordinates of each point... hmm.... It doesn't matter that this will slow down the framerate at all by waiting for the requests. I just need the easiest way to get the co-ordinates into memory to be drawn in the sketch.