Timeline for Algorithm for dividing a 2D grid into organic looking plates
Current License: CC BY-SA 3.0
22 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 23, 2015 at 14:25 | comment | added | Christian Geese | Hey Thomas, I started anew (like I always do ;)), now it's really fast, but thanks for offering! | |
| May 28, 2015 at 15:50 | comment | added | Thomas | @ChristianGeese Would you feel comfortable posting your code to a place like pastebin or something like that? I'd be happy to have a look -- I don't know C#, but maybe I'm able to spot something that might cause the slowness anyway? | |
| May 28, 2015 at 15:49 | comment | added | Thomas | @ChristianGeese Even if you use Cell and Plate classes (instead of ints), the code should run very fast, as long as you used the same algorithmic approach. | |
| May 27, 2015 at 8:35 | comment | added | Christian Geese | Hey, I finally found some time to recode this following your ideas. Works much better than my previous version, though it still takes some time. My code is pretty bloated (I use Cell and Plate classes for further work) and I tried to implement your idea instead of translating your code. Anyways, thanks alot! | |
| May 20, 2015 at 11:51 | history | edited | Thomas | CC BY-SA 3.0 |
added 24 characters in body
|
| May 20, 2015 at 9:17 | comment | added | Thomas | I've now updated the code slightly: the bit masks are gone and with them is the restriction of a maximum of 32 colors. The bit masks were used to store for each unfilled cell which are the candidate plates it could be assigned to. The new version simply looks that information up in the actual grid. Secondly, I added the border wrap-around. It turned out that both changes actually simplified the code somewhat. Last but not least, I changed some variable names for better readability. Enjoy! | |
| May 20, 2015 at 9:15 | history | edited | Thomas | CC BY-SA 3.0 |
Updated the algorithm: no bit masks necessary, implemented wrap-around.
|
| May 20, 2015 at 8:36 | history | edited | Thomas | CC BY-SA 3.0 |
added 2 characters in body
|
| May 20, 2015 at 8:30 | history | edited | Thomas | CC BY-SA 3.0 |
Improved code legibility
|
| May 19, 2015 at 16:30 | comment | added | Christian Geese | Damn. Rereading your pseudo- and real code, I did NOT do it the way you do it. :D I will try and change my code (or straightup redo everything). | |
| May 19, 2015 at 16:20 | vote | accept | Christian Geese | ||
| May 19, 2015 at 16:20 | |||||
| May 19, 2015 at 15:14 | comment | added | Thomas | Storing the cells with adjacent plates might be useful if, e.g., you want to guarantee that the plates are (more or less) the same size. | |
| May 19, 2015 at 14:25 | history | edited | Thomas | CC BY-SA 3.0 |
added 145 characters in body
|
| May 19, 2015 at 14:23 | comment | added | Christian Geese | I store plate-adjacent cells in a list belonging to the plate, that's probably the source of the "overwrite"-problem. My implementation is very close to your pseudocode, I guess I have made one or more hefty mistakes somewhere. Didn't get around to checking your real code YET! :) | |
| May 19, 2015 at 14:19 | history | edited | Thomas | CC BY-SA 3.0 |
added 31 characters in body
|
| May 19, 2015 at 14:12 | comment | added | Thomas |
@ChristianGeese - Filled cells should never be overwritten: the cells array contains a list of all unwritten cells and a cell is removed from that list as soon as it is assigned a plate. This way it can never be overwritten. But now I'm curious: you say you already implemented it this way, yet a 500x500 grid with 6 plates take "forever" -- the above code, however, can fill 500x500 with 10 plates in under a second on my machine?!
|
|
| May 19, 2015 at 14:00 | comment | added | Christian Geese | Hey, thanks! In retrospect, I should've been more verbose with my pseudocode, since I already do it the way you suggested. :D One little difference: Instead of 5), I check ALL cells belonging to a plate for empty neighbors right before I add a new one, because your way would lead (I think) to plates sometimes overwriting each others cells where two plates meet. I have gotten a new idea on how to tackle that, though!! | |
| May 19, 2015 at 12:11 | comment | added | Thomas | Well, you beat me to it ;-) But apart from that, I think it's useful in that there's some sample code to look at. | |
| May 19, 2015 at 12:09 | history | edited | Thomas | CC BY-SA 3.0 |
added 740 characters in body
|
| May 19, 2015 at 12:08 | comment | added | Engineer | Because repeating what I said an hour ago is useful. ;) | |
| May 19, 2015 at 12:08 | history | edited | Thomas | CC BY-SA 3.0 |
added 740 characters in body
|
| May 19, 2015 at 12:02 | history | answered | Thomas | CC BY-SA 3.0 |