electricsheep
electricsheep copied to clipboard
Different Approach to Playlist creation
Hi,
this is not really an issue or a pull request or anything. It is just my idea of playlist creation. I found the current approach quite complex with unpredictable results and the playlists are sometimes quite ugly. In my case switching back and forth between the same sheep for a very long time, having no continuous play back even though all my sheep are connected... So I came up with a different approach and implemented it.
The basic idea is a follows.
- take the complete set of sheep
- select a random one from that list
- try to find a path from the current sheep to the selected one (using graph search)
- if there is no path jump directly
- keep track of how often the sheep have been played (just for the session, not permanently)
- try to avoid replaying sheep by penalizing played sheep in the path search. A detour of 20 sheep is acceptable to avoid replaying a sheep
- when doing the random selection try to find a sheep that has been played less
I've appended the playlist.lua file that implements this schema. I remove all "unnecessary" functionality though. No override, no deleting of sheep... only playlist generation
Maybe someone else finds it interesting. This way the playlist is (at least) more "presentation mode" than the playlist that comes out of the included generator. It plays all sheep with a more or less even probability and doesn't get stuck in one end of the graph. playlist.lua.txt
Hi thank you for the code. Sounds like a good idea but when I tried it, sometimes it froze for several seconds. Perhaps the graph search is too slow for large flock?
I totally agree that this is a good area to improve though, I have never bee satisfied with the algo that I came up with.
How many sheep do you have? I only have 1300. With that number it works nicely. Maybe writing the algorithm in C would improve the speed. It is also possible to solve it iteratively in smaller chunks to avoid stalling. Also: if there is no path to the target sheep the method is relatively expensive. It needs to search the whole graph just to find that out and add a single sheep to the playlist
I have 2000 right now, so not that different.
hm... well my computer is relatively powerful but not really a supercomputer. There are some improvements possible... e.g. by having the right tables available to not search through the whole set of sheep for an edge starting from the current position... If you are interested I can try to optimize it
Let me post it in the user group and see what others say.
On Mac you can run it by copying it over /Applications/Electric Sheep.app/Contents/Resources/Scripts/playlist.lua
I thought of an other reason why the algorithm might be slower on your system: I have added ca 100 sheep edges that criss cross all through the flock. This would reduce maximum path lengths and thus make the search go faster