Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 218 219 [220] 221 222 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 886109 times)

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3285 on: October 29, 2012, 07:32:06 am »

Are you creating the data sources? Because it would seem like a visual image would be, perhaps, the least efficient way to transmit this information.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3286 on: October 29, 2012, 07:42:46 am »

All I have is that pyramid graph. I don't know the ranges of each type, by the way. Seeing that some of the boundaries aren't parallel a side, it seems like it isn't a straight case.

Could you tell me a better way? Dx

What I need to do is given three percentages, finding what group that triad of data points belongs to.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3287 on: October 29, 2012, 07:47:20 am »

If the graphs the best you've got, it's the best you've got. What are you going to do with the boundary lines, though? Those usually aren't on graphics like this for that exact reason.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3288 on: October 29, 2012, 07:49:17 am »

I was going to make a new version of the graph, with no lines, just colors.
Now I have to learn how to do the SDL thing... hrng Dx
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3289 on: October 29, 2012, 07:51:55 am »

Wait... how can you make a new version of the graph if the graph is the only thing you have? To make a new version, wouldn't you need access to the raw numbers?
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3290 on: October 29, 2012, 08:06:16 am »

MS Paint to the rescue! ;)
Looking it up in a bitmap is pretty fast, it's just a large lookup table. It'd be faster even than looking it up using actual mathematics and finding the collision with a set of polygons.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3291 on: October 29, 2012, 08:09:04 am »

At first, I thought the best solution would be to use a bunch of if-else statements for each type of soil, but I quickly realized that wouldn't work.

Yeah, that is a weird graph. Your bitmap color lookup idea may be the best solution. Or, you could do something fancy using polygons for detecting each type of soil. Get the position inside of the triangle of the soil to test and check to see which polygon its in. This would be a little more accurate, and it pleases me as a programmer. Either way would work, though.


Edit: Siquo ninjaed my idea!  :P
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3292 on: October 29, 2012, 08:16:31 am »

A couple of problems I've thought of:

(1). The coordinates on a bitmap start at the top-left corner. The equation for a coordinate on a ternary graph assumes the lower left corner is the start.

(2) If a rounding error causes the coordinate to go out-of-bounds of the ternary graph, there's no way to tell where to classify it.

On another note, I think I should try and use the Boost.random library. People say that it helps debugging a lot, since you can have a bunch of independent generators.

Get the position inside of the triangle of the soil to test and check to see which polygon its in. This would be a little more accurate, and it pleases me as a programmer. Either way would work, though.
That sounds very complex. D:
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #3293 on: October 29, 2012, 09:41:55 am »

I have a problem I want to solve.

Soil composition is decided by three elements, clay, silt, and sand. There is a ternary plot for it:

Spoiler: large image (click to show/hide)

If I wanted to be able to access this data from a program, I suppose I'll have to create a new version of it in bitmap format that has simple colors for each soil type. Then, I'd use the formula **, multiplied by the correct value, since the formula assumes each side of the triangle has a length of 1, and then find the pixel at that point and figure out the soil type.

...Is there an easier way? Dx I'll have to learn how to access bitmap images at a point, probably through another library, and I have to admit I'm terrible at learning how to use libraries from the documentation.

Also, does SDL or libtcod happen to have the ability to read a bitmap image pixel at (x, y)?

Edit: C++.
This looks like a linear optimization problem with 3 variables.

Lets start by defining the bounding lines for clay because it is the largest.

The bottom line is:
clay: clay > 40

the left line is:
clay: sand < 55
the right line is:
clay: silt < 60

So the aggregate function for clay is:
clay: clay >40 & sand < 55 & silt < 60

silty clay is: clay >40 & silt > 40

And sandy clay is: sand > 55 & clay > 35

Repeat for all polygons.

And once you have the formula's for each you can optimize the terms through a truth table if you really need more efficiency.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3294 on: October 29, 2012, 10:02:59 am »

Gah... I spent an hour and a half trying to use the libtcod heightmap and noise generator functions, and I have nothing to show for it. Error after unknown error, culminating in the "heap corrupted, triggered break point" that has plagued me for the past hour.
One ghost error was Perlin noise inexplicibly returning 0 all the time. Wavelet noise didn't do that.

Another: The console printout shows a single column of colors on the first frame(queer in that the rendering does it per line, not column), then on the second it shows a single black column, then all red (which is the default background color and shouldn't show up normally), and then it crashes by heap corruption.

Also weird is that the same exact heightmap, untouched, suddenly turns into an empty structure on the second frame.

Anyways, I felt like I wasted all of that time. Nothing learned, nothing done, nothing finished.
I think I'm going to try my best to reinvent the wheel whenever possible & doable. It's much better than the alternative, tapping a black box and hoping what I want pops out.

@Nadaka: How would that work with the loamy sand/ sandy loam?  Now that I look at it, even the four sided shapes aactually do work that simple, though again sandy loam doesn't.
« Last Edit: October 29, 2012, 10:12:36 am by Skyrunner »
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #3295 on: October 29, 2012, 11:51:19 am »

for the complicated shapes that have concave edges, it does get slightly more complicated.

There are two ways to deal with this.

1: simply break the geometry from the concave point so that you have convex geometry only.
2: consider the order in wich you perform your calculations. For example, if we already have determined if something is loam or not loam, then we can use a convex geometry for sandy loam that overlaps with loam. But its ok, because we would have already ruled anything in that area as loam beforehand.

And laomy sand just has different angle on its line as follows:

sand: sand > 90

loamy sand: sand < 90 & ( clay + (silt / 2) < 15)
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3296 on: October 29, 2012, 06:27:41 pm »

Threw in my mapbuilding code today:
http://www.test.glyphgryph.com/main.html

Ignore the bits underneath, it's just graphical debug information for the map building components.
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3297 on: October 30, 2012, 05:35:18 am »

I'm writing a platformer I want you all to test. Can anyone recommend a good filesharing service?
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3298 on: October 30, 2012, 05:51:49 am »

Dropbox, Mediafire.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3299 on: October 30, 2012, 06:15:30 am »

Dropbox is by far the best way to share collections of bytes to people. Put a file in your Public folder, right click --> Dropbox --> Copy public link, paste link. Much easier than going through some ad infested file sharing website.
Logged
Pages: 1 ... 218 219 [220] 221 222 ... 796