Wormloop Applet
Wormloop Applet
I wrote a python applet of the worm-loop rule. The reason why I did so was because I had a hard time fixing the mutation rate so that worms had an equal chance of becoming bigger or smaller. I wanted to see the actual outcome of the rule and know whether or not worms will truly become more complex overtime.
The performance on this applet is still a bit slow. It's because of the collision detection which takes up about 90% of the overall execution time.
Link to the repository: https://github.com/ThatSoundsFun/WormLoop/releases
Link to the CA rule (still buggy): viewtopic.php?f=11&t=2049#p30253
The performance on this applet is still a bit slow. It's because of the collision detection which takes up about 90% of the overall execution time.
Link to the repository: https://github.com/ThatSoundsFun/WormLoop/releases
Link to the CA rule (still buggy): viewtopic.php?f=11&t=2049#p30253
Last edited by pi_guy314 on July 26th, 2016, 6:21 pm, edited 2 times in total.
Re: Wormloop Applet
Hmm! I know nothing about pygame, but this tutorial says that updating only the changed parts makes it faster. Also, it may be faster if the main logic is rewritten in something like C, I think?
One of my big big big goals is to make a golly-like program, but with rules as script files (probably Lua) so that one could design the rule as they like...
Edit: with a c engine and pygame (or lua sdl) frontend.
One of my big big big goals is to make a golly-like program, but with rules as script files (probably Lua) so that one could design the rule as they like...
Edit: with a c engine and pygame (or lua sdl) frontend.
Re: Wormloop Applet
I never knew updating the entire screen would slow down the applet down much, and it'll only take a few lines of codes to fix it. Thanks for the advise.Scorbie wrote:Hmm! I know nothing about pygame, but this tutorial says that updating only the changed parts makes it faster.
A python to c converter might be enough. I'm not sure how those work though.Scorbie wrote: Also, it may be faster if the main logic is rewritten in something like C, I think?
That's an nice concept. It could allow for more interesting things like cells with motions, similar to the margolus neighborhood.Scorbie wrote:One of my big big big goals is to make a golly-like program, but with rules as script files (probably Lua) so that one could design the rule as they like...
Edit: with a c engine and pygame (or lua sdl) frontend.
Re: Wormloop Applet
I think you would like Cython if you are using C inside python. (Seems like the least work to the user) Or pypy may make it fast enough without modifying the source. Still, it may be fast enough with only the pygame tweak.pi_guy314 wrote:A python to c converter might be enough. I'm not sure how those work though.I wrote:Also, it may be faster if the main logic is rewritten in something like C, I think?
Edit: Stupid me, there's also ctypes, and probably other plenty of ways to use c with python. You should probably google for more options if you are planning it seriously.
Yeah, I saw some rules that are pretty hard to simulate in Golly because of its nature (e.g. moving particles, collisions, neighborhood of range >2 etc.) Hence this idea. Still, considering my programming proficiency and the amout of time I could spare, I think it would be a long way to go.pi_guy314 wrote:That's an nice concept. It could allow for more interesting things like cells with motions, similar to the margolus neighborhood.
Re: Wormloop Applet
I updated the applet to v1.1.0. the screen will now only update the ends of each worm instead of the entire screen which helped improved performance by a lot. For some reason the link didn't show the latest version which I fixed.
There still some performance issues with the applet itself whenever there's a lot of worms. I believe it's coming from checking collisions. I could try one of those methods to speed it up. I could also try dividing the screen into subsections so worms will check within their own subsections for collisions.Scorbie wrote:I think you would like Cython if you are using C inside python. (Seems like the least work to the user) Or pypy may make it fast enough without modifying the source. Still, it may be fast enough with only the pygame tweak.
Edit: Stupid me, there's also ctypes, and probably other plenty of ways to use c with python. You should probably google for more options if you are planning it seriously.
Re: Wormloop Applet
Good to hear that. I'll try to see that after I get more time:)pi_guy314 wrote:I updated the applet to v1.1.0. the screen will now only update the ends of each worm instead of the entire screen which helped improved performance by a lot. For some reason the link didn't show the latest version which I fixed.
Re: Wormloop Applet
Edit: I get this error:
Windows 10, 32bit, installed the latest pygame(1.9.1, I think.) I installed both python 2 and 3 but the error doesn't say "module pygame not found" so I am pretty sure python version issues are irrelevant.
Code: Select all
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.
C:\Users\Scorbie\Life\WormLoop-1.1.0>main.py
Traceback (most recent call last):
File "C:\Users\Scorbie\Life\WormLoop-1.1.0\main.py", line 22, in <module>
Game.init_screen(width, height)
TypeError: unbound method init_screen() must be called with Game instance as first argument (got int instance instead)
Re: Wormloop Applet
I think one possibility is that your using the wrong version of pygame. Here's the link to the latest versions of pygame:Scorbie wrote:Edit: I get this error:Windows 10, 32bit, installed the latest pygame(1.9.1, I think.)Code: Select all
Error
https://bitbucket.org/pygame/pygame/downloads. (3.4 version)
Other than that, I don't know what could be causing it nor can I reproduce the error. If this error still occurs, I think it would maybe be better to move it here if possible:
https://github.com/ThatSoundsFun/WormLoop/issues
I think I should probably consider py2exe so installing the latest versions of python and pygame wouldn't be necessary.
Re: Wormloop Applet
Just installed pygame with pip as the pygame msi installer doesn't work for some reason. (I think it couldn't find python3 in my home directory.)
Edit: (offtopic) the python3 windows installer now defaults to installing only for me (@ the home directory) So I think these 3rd party python installers should do something about that...)
And wow! You have a decent app right there! I am pretty amazed that it's fast enough to watch. Nice to see the log file too.
Different colors mean different species, right?
Edit: (offtopic) the python3 windows installer now defaults to installing only for me (@ the home directory) So I think these 3rd party python installers should do something about that...)
And wow! You have a decent app right there! I am pretty amazed that it's fast enough to watch. Nice to see the log file too.
Different colors mean different species, right?
Last edited by Scorbie on July 21st, 2016, 1:16 am, edited 1 time in total.
Re: Wormloop Applet
I believe in order for those to work, the python directory has to be C:\Python35 for python 3.5 and etc. I'm not 100% sure on that.Scorbie wrote:Just installed pygame with pip as the pygame msi installer doesn't work for some reason. (I think it couldn't find python3 in my home directory.)
Thanks, I appreciate you enjoying my applet . Yes, different colors means different species. Any additions or deletions of a turning genes will result in a different species. There's still some more features and optimizations left to be added in the future.Scorbie wrote:And wow! You have a decent app right there! I am pretty amazed that it's fast enough to watch. Nice to see the log file too.
Different colors mean different species, right?
Re: Wormloop Applet
Updated the applet to v1.2. The change-log for this version is long and is found at the repository.
The biggest change I believe is that JSON is used instead of pickling which makes sharing save files safer.
The biggest change I believe is that JSON is used instead of pickling which makes sharing save files safer.