Page 4 of 11 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 109

Thread: Automatic Forester

  1. #31
      Ramah is offline
    Guild Expert Ramah's Avatar
    Join Date
    Mar 2009
    Location
    Nottinghamshire
    Posts
    1,327
    Blog Entries
    3

    Post

    Ok... here would be how I did it if I was working out how to place trees and trying to keep in with how I think you are doing it with your 16 square grid.
    I'm assuming your placement routine starts in the top left corner, goes along the x-axis, then down one row on the Y-axis and returns to X0.

    The first thing I would do is have the program examine each of the brushes in its list looking for the widest one. I would then divide this by 4 to get the size of your grid - giving you your sixteen sections which the tree would occupy. As long as all the tree brushes are reasonably close in size then it doesn't matter that some would be smaller and not fit exactly to the edges of the grid.

    If you resize the trees with your slider this calculation would need doing again obviously.

    I'd then send the subroutine crawling through my array, starting at X0, Y0 (or X1 Y1 if Java doesn't use zero-based arrays or whatever). You know where to place the trees in relation to the .png alpha image (no idea how you do that by the way) so as soon as you reach a point in the matrix where a tree is allowed relative to the png mask you do your random check and figure out if a tree is placed and which tree is used etc. Your subroutine would then flag certain positions in your array as unavailable or illegal. If your array is boolean then I guess it would mark them as false.
    Your subroutine would then repeat until you got to the next space which you are allowed to grow a tree on looking at both the .png mask AND the positioning of the last tree. You then do your random check again etc...

    Here's an image to help demonstrate what I mean...

    Automatic Forester-tree_placement_example.jpg

    So, when tree 1 is placed I would mark off all the places where I have the red X's as ungrowable. So.. X+1, X+2, X+3, X-1 Y+1, Y+1, X+1 Y+1 in the array would be marked as False.
    If a tree is placed in those positions it is too close to the original and looks odd.

    If you do no random checks on the positions where the tree is placed (only for which tree brush is used) then this would be the maximum density forest. There would be a tree in every available position that your .png mask allows.
    To lower the density you would either
    a) do a random chance check for each LEGAL space, lowering the odds each time the density is lowered.
    b) Increase the number of positions marked as ILLEGAL whenever a tree is placed. So each tree is forced to grow further away from the others the lower the density is.
    c) A combination of both of the above.

    I hope this helps. It makes perfect sense to me but I'm not the one programming it and you would obviously know more about whether this is doable for you or not.

    EDIT: I forgot to say... the red X's on the image above are ONLY relative to the first tree placed. If that image was correct there would be other red X's placed relative to the positions of the other two trees.
    Last edited by Ramah; 01-08-2010 at 02:30 PM.
    Royal: I'm very sorry for your loss, your mother was a terribly attractive woman.


    My Cartographer's Guild maps: Finished Maps


    More maps viewable at my DeviantArt page: Ramah-Palmer DeviantArt

  2. #32
      Ramah is offline
    Guild Expert Ramah's Avatar
    Join Date
    Mar 2009
    Location
    Nottinghamshire
    Posts
    1,327
    Blog Entries
    3

    Post

    Gah! In an attempt to learn to understand Java a little more I've downloaded an editor and I'm trying to get the source code running in it but I'll be damned if I can get it to work. It took me ages to figure out how to open up the two files as a project so they would build without throwing errors up. And now I cannot get it to run without throwing an error up that it cannot open an image. But I can't figure out how to link to the image folder.
    Opening that folder in the project doesn't work.

    Gah. I'm sure there's something else I'm supposed to be getting on with... ah wait... doing a map. Hmm... but wasn't there something else? Ah yeah... working on my story.
    Royal: I'm very sorry for your loss, your mother was a terribly attractive woman.


    My Cartographer's Guild maps: Finished Maps


    More maps viewable at my DeviantArt page: Ramah-Palmer DeviantArt

  3. #33
      Fluesopp is offline
    Guild Apprentice
    Join Date
    May 2009
    Location
    Norway
    Posts
    48

    Default

    Mapping is funnier than writing? Heh.

    I'll take a look on that idea. I might even rewrite the whole program now that I know it works.

    If you are using netbeans, the Image folder must be placed in the project folder. If you are using eclipse, I don't know. Probably the same place.

  4. #34
      Ramah is offline
    Guild Expert Ramah's Avatar
    Join Date
    Mar 2009
    Location
    Nottinghamshire
    Posts
    1,327
    Blog Entries
    3

    Post

    Ok, well I'll wait and see what you come up with then. No point in me trying to get my head around your code if you're just gonna go and rewrite it all on me.

    I just downloaded Netbeans after you said that and I managed to get it to work in that. It was a different editor I was using before.
    Well... I say I've got it to work but unless you included a different build in your source code to the one you used in your application then they are behaving very differently.
    The amount of trees showing up on the screen is far fewer when run through the compiler, and they don't scale up to such a massive size.
    Does the source code include the changes you made whilst trying to get the density to work?
    Royal: I'm very sorry for your loss, your mother was a terribly attractive woman.


    My Cartographer's Guild maps: Finished Maps


    More maps viewable at my DeviantArt page: Ramah-Palmer DeviantArt

  5. #35
      Ramah is offline
    Guild Expert Ramah's Avatar
    Join Date
    Mar 2009
    Location
    Nottinghamshire
    Posts
    1,327
    Blog Entries
    3

    Post

    I had a play with the source code this evening and this is what I came up with...

    The positions of the trees are more along the lines of a maximum density forest how I would do it. I gave each tree a random little jiggle so it wasn't too uniform but I would say it needs each tree jiggle to effect its neighbours too, so it will look less like a pattern.

    Automatic Forester-treetest2.png

    One thing I can't seem to fix are those holes in the forest. I thought at first you had it randomly choosing whether to place a tree or not but upon investigation I believe its because the Tree0 image doesn't seem to work. I thought it may be because the count started at 1 but all my experiments to fix it failed.

    I'll try rattling a few new brushes off for it tomorrow. To me it looks like they would be better with a hard edge so the program has no problem masking them off.
    Royal: I'm very sorry for your loss, your mother was a terribly attractive woman.


    My Cartographer's Guild maps: Finished Maps


    More maps viewable at my DeviantArt page: Ramah-Palmer DeviantArt

  6. #36
      Ascension is offline
    Community Leader Ascension's Avatar
    Join Date
    Jun 2008
    Location
    St. Charles, MO
    Posts
    8,216

    Post

    I think the holes look nice...ya gotta have some open spaces so I'd have a white blank picture for my spacer. If you could set how many holes per hundred that you want then you could get rid of the holes or have a whole bunch of holes.
    If the radiance of a thousand suns was to burst at once into the sky, that would be like the splendor of the Mighty One...I am become Death, the Shatterer of worlds.
    -J. Robert Oppenheimer (father of the atom bomb) alluding to The Bhagavad Gita (Chapter 11, Verse 32)


    My Maps ~ My Brushes ~ My Tutorials ~ My Challenge Maps

  7. #37
      Ramah is offline
    Guild Expert Ramah's Avatar
    Join Date
    Mar 2009
    Location
    Nottinghamshire
    Posts
    1,327
    Blog Entries
    3

    Post

    I agree, Ascension. The holes do add to it and if they weren't there I would certainly want a random check to put a few holes like that in it. It's just bugging me as to why they are there. It's nice to understand something.
    Anyway, until Fluesopp checks this out then I guess I won't know. Unless someone else with more Java knowledge than me checks it out.

    Anyway... I just had another quick play with it before bed as I had a little brainwave on how to get rid of the obvious pattern without too much hassle.
    I included a 4% random check on every tree placed along the x-axis and if it fired then that tree and all other after it move along an extra grid space.
    I think this looks a lot nicer.

    Automatic Forester-treetest3.png

    This, to me, with a change of the brushes, would already work amazingly well and will get some use. I'm really looking forward to seeing what else Fluesopp can do with it.
    Royal: I'm very sorry for your loss, your mother was a terribly attractive woman.


    My Cartographer's Guild maps: Finished Maps


    More maps viewable at my DeviantArt page: Ramah-Palmer DeviantArt

  8. #38
    Community Leader Facebook Connected Steel General's Avatar
    Join Date
    Jun 2008
    Location
    Ft. Wayne, IN
    Posts
    9,464

    Default

    Cool stuff here folks!
    My Finished Maps | My Challenge Maps | Ghoraja Juun, my largely stagnated campaign setting.

    Unless otherwise stated by me in the post, all work is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.



  9. #39
      Ramah is offline
    Guild Expert Ramah's Avatar
    Join Date
    Mar 2009
    Location
    Nottinghamshire
    Posts
    1,327
    Blog Entries
    3

    Post

    New forest on Lykarnia courtesy of this program...

    Automatic Forester-new-forest.jpg

    I still had to shade the trees etc. but the shape and placement is down to the program.
    Royal: I'm very sorry for your loss, your mother was a terribly attractive woman.


    My Cartographer's Guild maps: Finished Maps


    More maps viewable at my DeviantArt page: Ramah-Palmer DeviantArt

  10. #40
      Fluesopp is offline
    Guild Apprentice
    Join Date
    May 2009
    Location
    Norway
    Posts
    48

    Default

    That's very nice.

    Can you perhaps send me those improvments you made?
    Currently rewriting the program now.

Page 4 of 11 FirstFirst ... 23456 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •