• What Are You Working On? V13
    5,003 replies, posted
[QUOTE=ZeekyHBomb;25420275]The tree-structures order the objects by their position, making an easy and fast selection of fewer candidates possible. No, quare the right, not left operant. sqrt(x) <= y is equal to x <= y² though the latter will most probably be faster. Google them.[/QUOTE] Still can't understand it, my math sucks, i had huge problems with it in school, couldn't concentrate. This just blows my mind.
[QUOTE=Shammah;25420514]Thanks for the squareroot thingy, it's a whopping 14% faster now! About the tree structure, the point is that these bullets will all have different locations and that means I would still have to iterate and order them all. Wait, let me get this straight, I suddenly think I know what you mean: order all of the bullets, then only select the ones that are close to the player, like in 2x it's radius around them, and do a collision check for only these? Does this really outweight the calculations needed to order them?[/QUOTE] It's easiest to have a map of arrays for each bullet: make each "array tile" quite small, and only check for collisions with bullets in the 9 surrounding tiles. Obviously move it from tile to tile as the position changes.
[QUOTE=TheBoff;25420652]It's easiest to have a map of arrays for each bullet: make each "array tile" quite small, and only check for collisions with bullets in the 9 surrounding tiles. Obviously move it from tile to tile as the position changes.[/QUOTE] I'm not working with tiles but with floating point accuracy. I need this accuracy because otherwise the point of the bullet-hell game would be gone and people would be frustrated by the lack of precision. "Why did I lose I didn't even come close to the bullet!"
You only need to order them in the tile structure. Of course you would still be checking their accurate positions, but you only need to consider the objects in the tiles. [editline]15th October 2010[/editline] [QUOTE=Giraffen93;25420622]Still can't understand it, my math sucks, i had huge problems with it in school, couldn't concentrate. This just blows my mind.[/QUOTE] The squareroot thingy was not directed at you. Still, it should be pretty obvious that if you have an equation sqrt(x) <= y and you do the same operation on both sides of the equation (squaring), that the result would be sqrt(x)² <= y². And sqrt(x)² is x (for x > 0 (in R)).
[QUOTE=ZeekyHBomb;25420977]You only need to order them in the tile structure. Of course you would still be checking their accurate positions, but you only need to consider the objects in the tiles. [editline]15th October 2010[/editline] The squareroot thingy was not directed at you. Still, it should be pretty obvious that if you have an equation sqrt(x) <= y and you do the same operation on both sides of the equation (squaring), that the result would be sqrt(x)² <= y². And sqrt(x)² is x (for x > 0 (in R)).[/QUOTE] Now you're just mocking me :downs:
Well, depends on which grade you are in. Though I think with 17 you just started to be taught this kinda stuff. Of course also depends on the country you are going to school in.
Or do something like : [code] for(each entity) { if( math.abs(player.pos - bullet.pos) < largest bullet size ) Do collision test on entity else skip it } [/code]
[QUOTE=ZeekyHBomb;25421067]Well, depends on which grade you are in. Though I think with 17 you just started to be taught this kinda stuff. Of course also depends on the country you are going to school in.[/QUOTE] Lol, in holland we get square root and equations first and seccond year after we go to highschool which is about when we are 13 - 15 ?
You still need to go through each entity. Also player.pos.distanceSquared(bullet.pos) < largetBulletSizeSquared. I don't think math.abs knows how to handle vectors (>implying that pos is a vector) by default.
I think I got taught that with 16, though I don't really remember. WTF automerge >:O
Yea, its just pseudocode I hoped he would have figured that part out by himself. Also how would you know which entity is in which tile ? indeed automerge is broken :(
[QUOTE=ZeekyHBomb;25421067]Well, depends on which grade you are in. Though I think with 17 you just started to be taught this kinda stuff. Of course also depends on the country you are going to school in.[/QUOTE] I have ADD & Asbergers, (don't say it's just bullshit because all my friends can do this) and i have huge problems concentrating on this stuff, i was atleast behind 150 pages last year, i passed like 3/15 math tests. I don't know any math tables (except 1 & 10). Damn.
[QUOTE=Giraffen93;25421169]I have ADD & Asbergers, (don't say it's just bullshit because all my friends can do this) and i have huge problems concentrating on this stuff, i was atleast behind 150 pages last year, i passed like 3/15 math tests. I don't know any math tables (except 1 & 10). Damn.[/QUOTE] If you put Sqrt() on both sides of the equation Sqrt(x) = Sqrt(y²) because Sqrt(y²) = y But it's easier for a computer to square than root. So (Sqrt(x))² = (Sqrt(y²))² This gives x = y² Hope it helped you. [editline]a[/editline] fuck, when re-reading it, I can't even understand what I wrote.
Sqrt(y²) = |y|
[QUOTE=Giraffen93;25421169]I have ADD & Asbergers, (don't say it's just bullshit because all my friends can do this) and i have huge problems concentrating on this stuff, i was atleast behind 150 pages last year, i passed like 3/15 math tests. I don't know any math tables (except 1 & 10). Damn.[/QUOTE] [url=http://en.wikipedia.org/wiki/Dyscalculia]I diagnose Dyscalculia[/url]
nothing complicated: [url]http://www.minecraftforum.net/viewtopic.php?f=35&t=50345[/url]
[QUOTE=OrYgin;25421278]Sqrt(y²) = |y|[/QUOTE] It's about sqrt(y)² though, not sqrt(y²). sqrt(y²) is only equal to sqrt(y)² in R when y >= 0. Lucky you that in this specific case, y happens to be >= 0 (or NaN).
Squirting? I don't understand anything. [editline]15th October 2010[/editline] [QUOTE=Pirate Ninja;25421302][url=http://en.wikipedia.org/wiki/Dyscalculia]I diagnose Dyscalculia[/url][/QUOTE] Almost.
sqrt is short for squareroot :P
[QUOTE=quincy18;25421119]Lol, in holland we get square root and equations first and seccond year after we go to highschool which is about when we are 13 - 15 ?[/QUOTE] i know its like REALY easy stuff: we also learn stuff like this 2-x=23X+8(X-7) cuz that means it's the same as 2-x=31x-7 thats the same as 32x=-5 so X=-5/32 in the end X=0,15625. math is easy :D
If the bullets can only collide with the player, using a tree or a tile structure isn't going to improve performance significantly. Scanning through the list and checking for collision with a single object has O(n) complexity. Scanning through the list and calculating the tiles the bullets are occupying also has O(n) complexity. It'll only become worthwhile to start optimizing with different structures if the amount of collision checks doesn't increase linearly with bullet amount. That'd be the case if the bullets could collide with other bullets. It's also marginally faster to have a tile structure if the bullets aren't guaranteed to move each tick. But I find that unlikely because they're bullets.
It's worth noting [i]why[/i] squaring is faster than square-root (on integers): the former always returns an integer, whereas the latter could return a float and so needs to perform higher-precision calculations.
[QUOTE=ZeekyHBomb;25421472]sqrt is short for squareroot :P[/QUOTE] [img]http://f.braxupload.se/rg45ei.png[/img] I just feel too stupid in here :eng99:
[QUOTE=ThePuska;25421513]If the bullets can only collide with the player, using a tree or a tile structure isn't going to improve performance significantly. Scanning through the list and checking for collision with a single object has O(n) complexity. Scanning through the list and calculating the tiles the bullets are occupying also has O(n) complexity. It'll only become worthwhile to start optimizing with different structures if the amount of collision checks doesn't increase linearly with bullet amount. That'd be the case if the bullets could collide with other bullets. It's also marginally faster to have a tile structure if the bullets aren't guaranteed to move each tick. But I find that unlikely because they're bullets.[/QUOTE] In that screenshot he's posted, assuming this grid in the back is the quadtree (which it cannot be due to it being 20x20 cells, but whatever), then is the more populated areas the quadtree would reveal only around 20 bullets, as opposed to 250. True, it will raise the efficiency as much as it would with collision checks other than the player, but it's all of the optimizations I could with of. manual merge: [QUOTE=Giraffen93;25421596][img_thumb]http://f.braxupload.se/rg45ei.png[/img_thumb] I just feel too stupid in here :eng99:[/QUOTE] Because you didn't know that sqrt is an abbreviation or because you don't know what a squareroot is? manual merge: nvm, I just got the picture ._. manual merge: [url]http://simple.wikipedia.org/wiki/Nth_root[/url] [url]http://simple.wikipedia.org/wiki/Square_root[/url]
[QUOTE=ZeekyHBomb;25421640]In that screenshot he's posted, assuming this grid in the back is the quadtree (which it cannot be due to it being 20x20 cells, but whatever), then is the more populated areas the quadtree would reveal only around 20 bullets, as opposed to 250. True, it will raise the efficiency as much as it would with collision checks other than the player, but it's all of the optimizations I could with of. manual merge: Because you didn't know that sqrt is an abbreviation or because you don't know what a squareroot is? manual merge: nvm, I just got the picture ._.[/QUOTE] Ooooh, &#8730;.. Well, i know what it is but not how to properly use it.
[QUOTE=Giraffen93;25421713]Ooooh, &#8730;.. Well, i know what it is but not how to properly use it.[/QUOTE] square root is the opisit of X^2 or X*X. it finds the value needed to do X*X so: sqrt(9)=3 and 3^2=9 sqrt(4)=2 and 2*2=4 sqrt(16)=4 and 4*4=16 get it now? [editline]15th October 2010[/editline] conclusion: sqrt(X)=X*X
[QUOTE=Mega1mpact;25421787]conclusion: sqrt(X)=X*X[/QUOTE] No it doesn't.
Not at all :haw: No clue how to use it in the code though.
Squaring means multiplying a number by itself. Squareroot undoes squaring. Squaring undoes squareroot.
[QUOTE=Giraffen93;25421850]Not at all :haw: No clue how to use it in the code though.[/QUOTE] Like I said, the squareroot thing was not directed at you :3
Sorry, you need to Log In to post a reply to this thread.