• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

1003 Excellent

About Lode

  • Rank

Personal Information

  • Interests
  1.   How does that work? The cubic bezier on Wikipedia does not hit each control point, only the outer two - but then it's also 2D intead of 1D:   http://en.wikipedia.org/wiki/B%C3%A9zier_curve   Can this be calculated in a way similar to bicubic interpolation? I couldn't find anything.   THanks a lot!
  2. Other uses for matrices in games?

    The entire game '2048' is a matrix :) If empty cells are zeroes.
  3. Awesome! That is a great idea and works great, thanks!   EDIT: never mind the other comment I posted here, Smoothstep does look visually better than http://dinodini.wordpress.com/2010/04/05/normalized-tunable-sigmoid-functions/ :)
  4. good random permutation?

    World generation: On the left: ugly patterns of trees (the dots) On the right: good pattern of trees with your code :)  
  5. good random permutation?

    Thanks for pointing that out. That last one works nicely. But if I remove the last 4 lines (before return x), then the patterns look ugly. Seems like that additional repetition of similar things fixes it. So, works great, but I'm going to experiment to try removing some lines :) Do you have any explanation why some of these give ugly patterns in results, while others look very random? Thanks!
  6. Hello,   Bilinear interpolation generates visible crosses, see image from wikipedia to see what I mean, I mean the horizontal and vertical structures and sharp edges:     Bicubic interpolation looks much rounder:         Imagine now that the colors are types of world (tundra, desert, grass, ...): the rounder shapes are *highly* preferable over the ugly "crosses" of bilinear interpolation.   However, bicubic interpolation has two disadvantages (the second being the most problematic for me):   1.) It requires 16 points, rather than only 4 points. It would be highly preferable for me to only have to use the 4 corners of a square zone, not corner points of neighboring zones as well 2.) Values can overshoot, that is, they can become lower or higher than the 4 corners of this zone. I really don't want this, "conditions" in a zone should be bounded by its corners for convenience reasons (predictable range of values in a zone).   So, the question is: Does there exist a way of 2D interpolating that only uses 4 corner points and only returns values in that range, but, looks "rounder" than bilinear interpolation? Thanks!
  7. good random permutation?

    Thanks a lot!   In the end I went with a hybrid with Álvaro's suggestion and irreversible's example :)   With seed a fixed constant that determines the world, and x the input number, my first implementation was:       x ^= (seed ^ 1234567890);     x = (x + 1234567890) & 2147483647;     x = (x * 1000000001) & 2147483647;     x = (x >> 18) | (x << 14);     x = (x * 1000000005) & 2147483647;     return x;   But that had noticable patterns still so not good. But then I combined it with irreversible (the order in which things happen is based on it, the numbers not), giving this:       x ^= (seed ^ 1234567890);     x = (x * 1000000001) & 2147483647;     x = (x ^ ((x << 6) ^ (x >> 26))) & 2147483647;     x = (x * 1000000001) & 2147483647;     x = (x + ((x << 5) ^ (x >> 12))) & 2147483647;     return x;   And that seems to work quite well indeed :)
  8. Hello,   For a randomly generated world, I'm trying to find a way of randomly generating rivers in the landscape.   However, unlike for example in Dwarf Fortress, in my world the whole world is not known beforehand. DF generates the rivers with physical models on the entire landscape. That is not my intention.   In my case, the world is more like it works in Minecraft: a sector is only generated when you encounter it. Generating heights, humidity and so on is done this way with perlin noise, and that can work in independent sectors.   What I mean by "working in independent sectors" is that it is able to generate a sector with pseudorandom numbers, without any information about the other sectors, and yet if you zoom out and see the whole world, all the sectors smoothly connect together.   But for rivers, which of course go through many sectors, you sort of need to know where a begin and end is, so I can't find a way to generate it "independently". The fact that ideally the rivers would also flow from mountains to oceans makes it even more difficult. Same for roads: I want roads to connect cities, but a sector in-between ideally should not have to know which sectors contain the actual cities (as that is something that the city-sector alone can only know from its own pseudorandom values).   The simplest algorithm that does achieve that is to simply have a grid of cities (roads are the edges, a city at every intersection), but that is boring.   Are there algorithms for "independent" random river and road generation? And what is this concept called? Thanks!
  9. good random permutation?

    Thanks! Yeah I didn't really know the exact scientific name of what I was looking for which made googling hard. Perfect hash, and random access random permutation, sound indeed like it.   It needs to be stateless because the whole world will not be generated at once, it generates a part only when you reach it. E.g. if you reach a part with a coordinate x + 65536 * y = 5000, it needs to give you the value for 5000.   About Java: I'm not even using it but if I would the world should be the same. So, it doesn't have unsigned integers. I don't like that, at all, but it is what it is. 64-bit integers can of course store the 32-bit value, but truth is the upper value doesn't really matter a lot so going up to 2 billion seems fine.
  10. Hello,   I'm looking for a way to map a 31-bit positive integer (leaving some room for Java!) to another 31-bit positive integer, for purpose of random world generation, with the following properties: -if you go through the inputs in sequence, the resulting output sequence should be a good pseudo-random sequence -it should not require state. So a linear congruence generator or similar will not work afaik. Instead, it should be able to give you the output for any of the inputs at any time, no requirement to go through it in order. -it should be fast, so cryptographic hashes are probably not it -it should be stable: always give the same output for the same input (so no true random generator ) -each result is unique, that is, every possible integer is output by one input integer (not the most important requirement, but would be nice, each output value should have equal probability). So some arbitrary bit twiddling and multiplications won't do it either   I tried to implement something similar to the following one:   http://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/   but it's actually not that great, I want to use a seed value as well, and while this one works great for some seeds, it does not for many as well and to make it even more annoying, it gives too similar patterns for seeds that are near each other (so if you generate for coordinates x and y a random world temperature with seed 1000 and a random height with seed 1001, they will be too correlated. Or something like that, in any case the patterns are ugly with nearby seeds).   Does anyone have suggestions for such a function? Thanks a lot!
  11. Thanks! Very interesting. I did read a bit about holomorphic functions before, but failed to see it in this context.   One question still remains for me: Is the derivative of non-holomorphic functions defined at all, or is it simply considered "not differentiable"? And in particular, is the derivative of Im(x) simply the zero function?   I tried to search for it, but I find mostly things about holomorphic functions, not about non-holomorphic ones...   I'm experimenting with numerical math things, especially those that give pretty plots (like here http://www.gamedev.net/topic/655487-hsl-with-smoother-transitions/), and am trying to be generic so wouldn't want to exclude such functions.   Thanks!
  12. Hi, Given the function: f(x) = im(x). So, it takes the imaginary part of x. On the real line, this function always returns 0. However, in the imaginary direction, it returns real values and has a slope of 1. With the definition of the derivative, you look in the real direction only and miss that there's a slope in the imaginary direction. Wolfram Alpha gives 0: http://www.wolframalpha.com/input/?i=derivative+of+f%28x%29+%3D+im%28x%29+at+x+%3D+5 So, is that indeed correct then? Do you have to ignore the slope in imaginary direction for a derivative? Shouldn't the answer be something like 1, or -i? My concern is that this derivative is not useful for Newton's method to find zeroes of complex functions, e.g. the above example would always return 0 even though there's a slope. I'm also wondering how to define slope in a 4D space (2D input, 2D output). Thanks.
  13. Thanks! HCL is not bad at all I really like how smooth everything looks. The colors themselves are a bit too pink though, I just have to do some tweaking with mostly choosing the right chroma parameter I guess...     Edit: Well, in retrospect, I think HCL makes colors too bland... No real red I guess I need to find something that remains closer to the original HSL, in that it uses all possible things a computer monitor can do at the cost of accuracy, but at least doesn't have the visible bands that HSL has.
  14. Hello,   It's extremely hard to explain with words, so I hope the image says it all:     The standard HSL color model looks like the image on the left.   Depending on which angle from your screen you look at it (im my case it's always visbile but more when looking from the bottom), you can clearly see that there is a horizontal line in the middle of the image. It's in fact just a difference in how it transitions, but the human eye/brain somehow makes a "line" of it. In addition, there are 3 such vertical lines, between the red and green, between the green and blue, and in the purple zone.   The red markings in the centermost image contain where those ugly lines are.   And the rightmost image shows a plot of a mathematical function (guess which) made with that very HSL color model. And there it is, the ugly line is visible there as well.   I'd like to make better looking plots. It should still be a HSL-like color model: still black at the bottom, white at the top (HSV is not white at the top), and all hues in the center. But smoothed in some way that no such obvious lines are visible.   I now use the standard HSL to RGB conversion function I already tried, after HSL to RGB, to set Y to the lightness with RGB->YUV->RGB conversion, but that looks even uglier, yellow becomes olive.   Does anyone know:   If there's a trick to make HSL color better for such mathematical plotting purpose?   What the phenomenon with the "lines" is called?   Another more suitable color model? Thanks!
  15. Hi,   Normally I strongly dislike when a website forces anything (like zoom levels).   However, when using a website in a mobile browser, double tapping will zoom, dragging will scroll, etc...   So if you make a game in JS that requires tapping, all kinds of unwanted effects like the mobile browser interpreting your tapping as zoom or scroll commands will happen.   Is there any way to make a website force a certain zoom level in a mobile browser, automatically showing the area of interest and having the browser not intercept double tapping? Thanks!
  • Advertisement