Defold + Biosim4

Note. Just found a bug - a memory leak in the texture setting code. Will patch tomorrow.

EDIT Memory issue fixed. Ran for 500 generations and a nice and stable 70MB for the whole run.

2 Likes


Added a little node viewer. Quite an interesting little app to muck around with :slight_smile:

5 Likes

How do I try this thing out? I naively downloaded the Git project, but I’m hit with a wall of errors when I run it.

Maybe I’m jumping the gun trying to test it out now? The video looks so cool!

error.txt (10.0 KB)

Hi @totebo - first make sure you have fetched the native extensions.
In the menu on Defold: Project → Fetch Libraries.
Then try a build. This will likely only build on Desktop platforms - have tried on Windows and Linux. I’ll give OSX a try on the weekend to make sure thats ok (there might need to be some adjustments).
I’ll put up some release packages here on the weekend so people can just download and use.
Thanks for having a look at it.

1 Like

Hey, yeah the extensions are all there, but getting the same errors for some reason. I’m on macOS, which probably explains it. Thank YOU for making this in the first place, it’s really quite fascinating.

Ahh looking at the errors, its making some sense. Looks like the OSX clang needs to have some extensions set for it to support some of the conventions in the code. Specifically: “-Wc++11-extensions”.
Kinda odd, since enums (what its complaining about) is a C89 thing shouldnt really need C++11 extensions. Will try some things out in the morning. Should have a quick solve for you tomorrow.

1 Like

That is done at project startup in the editor.

1 Like

The error mentions scoped enums, not regular enums:
” scoped enumerations are a C++11”

2 Likes

Sorry. yes you are right on @Mathias_Westerdahl, its a enum class which I dont think needs to be implemented that way in any case. The code from the library isnt overly complicated, so I might just refactor it anyway - could be an easy fix. Im also trying it out in html, which is helping cleanup some of these sorts of things too.

@totebo I have removed the enum Class. I still havent tested on OSX yet (will do tomorrow).
See if that works any better for you. Im trying to build html5, if that works, I’ll put it up on itch and people will be able to try it out at least.

1 Like

Thanks, just had a quick try, but there are still errors. No worries though, just hope to test this thing out at some point. HTML5 sounds like a good option.

Welp this has turned out to be more interesting that I thought :slight_smile:
Building on Win seems to be quite different. OSX and Linux (when I examined some of the output) have some issues when building the code. There is quite a bit of C++11 type code in the two libs included - mostly in the biosim4 code.
Additionally, with the current threaded setup (so it doesnt block Defold) there are problems building a html solution as well . Im going to clean out this code - I tend to prefer more C like code anyway, and the end code will probably get a 2-4x perf increase anyway, so its probably worth it.
The result, is I suspect this might be a few days to changeover. Im hoping by Wednesday it should be complete. Will post here about progress.

2 Likes

Note that we don’t use threads on html5.

1 Like

@Mathias_Westerdahl - yeah thanks. I was getting errors related to that. I sorta expected that to be the case too.

I have made another change. And Im not sure if Im being crazy, or just stupid :slight_smile: … Ive started converting to Lua. I looked at some of the main routines, and I actually think lua will out perform the C++. There is heavy use of maps and dual vector lists - which are both memory hungry std obejcts and also quite slow :slight_smile: … Hash tables however, on the lua side should be comparable if not slightly faster especially for how they are doing lookup - there are lots of calls to find, which is real slow.

Anyway, about 20% in, and I think I’ll call it a night. I think the timeline will be roughly the same as doing it in C, and more importantly, it will be full cross platform which is nice.

3 Likes

Ok. The conversion is done :slight_smile:
Now just sorting through all my bugs. Probably a day or so more. I suspect without jit on html it might be a bit slow - will see. Its all in a branch in the current git project - biosim4-lua if people are inquisitive :slight_smile:

3 Likes

So… this isnt dead yet. I have been doing bits and pieces over the last couple of crazy weeks.
The interesting thing, is that the majority of it is working - but I did a direct translation of classes to tables which was a big mistake (not learning from my previous mistakes!!). And so, I need to decouple the ‘class-like’ methodology from the tables and build either some meta tables or C like methods.
Performance due to the above, is horrendous - mainly because of how the tables are copied and instanced (ugh!!). I suspect its a few more few of mucking around before its properly usable.

The nice thing about doing this, is I have a pretty good understanding of how the whole thing works now, and has be interested in making some little AI libs for Defold. More to come on that front.

5 Likes

Hooray its done :slight_smile: … After wife caught covid, then me and a bunch of other “life getting in the way” events, I finally got back to this and finished it off.

Check out the repo - it should run on anything. I hope to have the Itch.io version up in the next hour or so.

The major changes:

  • Its all in lua. With the exception of the chart generation for the neural network view (this can be converted too, but I wont bother atm).
  • The integration of the UI and the application is better now its in Lua.
  • There are lots of globals, to get around problems with how the code was written in C++
  • Some of the table objects are still very inefficient. If you want, you could speed it up :slight_smile:
  • It should work in all platforms now.

Itch page here: https://bukkat.itch.io/biosim4-lua
NOTE: The Itch / HTML version is the slowest!

Screenies:



8 Likes

Uggh. Just tried to bundle Mac and it fails on the chart stuff. This can be commented out, and not included - just means that the neural network for a single node wont be rendered in the third tab panel.
Theres probably a simple way to solve this, but atm, Im leaving it.

1 Like

And it is very cool, too, I just played with it a bit.

Hope you are all fine now!

4 Likes

Hi @anon95708182. We are currently doing fine, my wife and I are recovering. Luckily we managed to minimise the spread to just myself and my wife. We were quite lucky in this, since we saw our whole family the weekend my wife had contact with someone infectious. None of them have had it transmitted to them.

Thanks for the concern, and glad you liked the little app. Its interesting in its current form, but might be far more interesting as an AI library :slight_smile:

7 Likes