roholazandie / boids

36 stars 15 forks source link

Boids on PySimpleGUI.... #1

Open MikeTheWatchGuy opened 5 years ago

MikeTheWatchGuy commented 5 years ago

Hi there... I've been wanting to port your code to PySimpleGUI since I read your article. Thank you for factoring out the P5 calls. It make porting MUCH easier. I removed all of the P5 calls except for the Vector call.

I'm wondering if you used a different package for your computations if you would get better speed.

I managed to get the code to run on 2 different GUI platforms. I almost had it running on a 3rd one (Qt), but ran into trouble with my graphing features on that port. The graphing is an area that's needed some work on PySimpleGUIQt for some time.

The two that I managed to run on were tkinter and browser based.

First the tkinter implementation Boids - Tk

Now the Browser-based (uses Remi as the GUI Boids - Web

You'll see at the top of your 2 .py files the changes required to move back and forth between these 2 GUI's. You only need to change the import statement in the .py files.

My "value add" with these GUIs is the ability, in realtime, to change the number of birds in the flock. I support if the speed were to ever get too fast, then another GUI element could be added to control speed. Not sure what other parameters you might want to tweak that are deep inside of your algorithm. If you have some, they are super easy to add to the GUI window.

MikeTheWatchGuy commented 5 years ago

I've also made a Repl.it for the project so that you can see the source code AND run it in your browser. In this case it's the tkinter version: https://repl.it/@PySimpleGUI/Boids-on-PySimpleGUI

MikeTheWatchGuy commented 5 years ago

I made a repository for the PySimpleGUI port. https://github.com/MikeTheWatchGuy/boids-PySimpleGUI

I wanted something that showed images of the algorithm in action with a GUI window.

roholazandie commented 5 years ago

This is amazing! I really liked the changes you made! You can even remove the Vector because I have one Vector class in fast_boid module. I think the problem with speed is more fundamental than using a different package. For me, using p5 was totally arbitrary. For making the code faster we need to use ideas like multithreading or dividing the space. For now, I used ray which doesn't work very well with p5. Maybe you can do that in PySimpleGUI. If you want I can add you to contributors and then we can have different implementations once in one repo.

MikeTheWatchGuy commented 5 years ago

Thank you!

Yea, it turned out pretty well.

It would be awesome if you could offer a version of your code that uses PySimpleGUI. I'm thinking there are some internal values that you may want to be able to change in realtime that can be added to the GUI too. Let me know if there's anything I can do to facilitate that. I would prefer to shut down the repository / fork I have of your code and instead have the PySimpleGUI version live in your repository.

I like the portability of it all. I just wish I could run on Qt right now but I've got a bug.

I tried to get Ray to work, but wasn't able to. I'm still working on it.

roholazandie commented 5 years ago

I have added you to contributors and now you can push your codes. Currently, I'm working on some other codes but as soon as possible I will work on the efficiency problem.

MikeTheWatchGuy commented 5 years ago

I made changes to my repo today to expose some of your settings. They're a lot of fun to play with. I also prompt for the size of the window at the program's launch. Sometimes 1000x1000 is too much for some people, so I offered several.

The resulting window when 800x800 is chosen is this: image

I don't know how you want to integrate our Repos. I'm keeping them separate for the moment as I'm not sure where you want them checked into your Repo, if anywhere.

I like these latest GUI changes. Makes it easier to learn about the internals of your algorithm by changing the parameters in realtime and seeing the results.

I only changed main.py for this last round of changes.

roholazandie commented 5 years ago

This is really nice! I don't know if there is any way to do such a cool thing in p5. Looks like now it's even faster. About merging it's all up to you. I think if we want to merge we have to create submodules for it. Again, that's really cool!