|
You last visited: Today at 14:32
Advertisement
Minimal resource consumption on returning coordinates
Discussion on Minimal resource consumption on returning coordinates within the CO2 Private Server forum part of the Conquer Online 2 category.
09/20/2014, 05:39
|
#1
|
elite*gold: 0
Join Date: Feb 2008
Posts: 322
Received Thanks: 121
|
Minimal resource consumption on returning coordinates
Okay so I've tried a few methods already, as I am coding custom skills for my project and I'm quite in a pit where I can't seem to come up with a solution to ease the performance used to just return the values.
The original code which took too much is by using these:
All coordinates from 000 - 999 both X and Y in dictionary loaded from start of server.
Calculating a cone;
Using ConcurrentDictionary
and filter down with the Math of the cone
Lastly I fill the new ConcDictionary with the coordinates that is correct.
Once it gets to the last coordinate, example 682, then it will automatically break on Y.
However because of this, it has still looped from 000 all way to 600 skipping coordinates and just unnesecary use of computer resources.
Code:
Original:
Coordinates as Entity //Needs replacement
So, I'll let you guys state your opinions, pretty sure you guys can come up with something much better. but remember, I need it to return the X,Y value of everything within a cone/circle or any sort depending on the math.
|
|
|
09/20/2014, 08:51
|
#2
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
|
Quote:
Originally Posted by drakejoe67
Okay so I've tried a few methods already, as I am coding custom skills for my project and I'm quite in a pit where I can't seem to come up with a solution to ease the performance used to just return the values.
The original code which took too much is by using these:
All coordinates from 000 - 999 both X and Y in dictionary loaded from start of server.
Calculating a cone;
Using ConcurrentDictionary
and filter down with the Math of the cone
Lastly I fill the new ConcDictionary with the coordinates that is correct.
Once it gets to the last coordinate, example 682, then it will automatically break on Y.
However because of this, it has still looped from 000 all way to 600 skipping coordinates and just unnesecary use of computer resources.
Code:
Original:
Coordinates as Entity //Needs replacement
So, I'll let you guys state your opinions, pretty sure you guys can come up with something much better. but remember, I need it to return the X,Y value of everything within a cone/circle or any sort depending on the math.
|
That is horribly inefficient. Do you know what's behind a dictionary to start with? It's a tree of some design. To get a value from the tree, it compares the search key with the root's key. If the search key is greater than the root key, it branches right; else, it branches left. It keeps comparing keys until the key of the child leaf matches the search key. You're talking about close to a million leaves just for getting a coordinate from the Canyon map. Although trees do minimize comparisons, that's still a crap ton of comparisons.
Load coordinates in an array and all you have to do is run a quick arithmetic statement to get coordinates from memory. No comparisons required, at all. Not only is that far less memory usage than using a dictionary, it's magnitudes better in terms of efficiency. With leaves, you have to not only store the key and value (instead of just the value), you have to store pointers to the child and parent leaves in the branch. So, in recap, a dictionary with even one coordinate inside it is less efficient than an entire map stored as an array (in CPU cycles). Dictionaries are not a good idea. If resource consumption is your only concern, an array is still the way to go - just think smarter about your bit allocation.
|
|
|
09/20/2014, 09:23
|
#3
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
Why would you even keep the coordinates in an array, you can calculate cones with high school math and just generate the coords. Also, you dont really need a cone. You need two triangles. One larger pointing to the player and one connected to it pointing in the opposite direction. It`s more than enough in this case.
|
|
|
09/20/2014, 09:29
|
#4
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
|
Quote:
Originally Posted by KraHen
Why would you even keep the coordinates in an array, you can calculate cones with high school math and just generate the coords. Also, you dont really need a cone. You need two triangles. One larger pointing to the player and one connected to it pointing in the opposite direction. It`s more than enough in this case.
|
Alright, I'm not understanding this. What is this thread even talking about if it's not loading coordinates from a data map for Conquer Online? Is this related to this section at all? Why a cone, why triangles? What is going on here? What does "calculate a cone" even mean? The area, volume, vertex, draw points in OpenGL? I need English and I need context.
|
|
|
09/20/2014, 10:27
|
#5
|
elite*gold: 0
Join Date: Feb 2008
Posts: 322
Received Thanks: 121
|
Only using math is fine, it just makes things take more time and since I am using this for multi purposes I think it's easier to do like Fang said.
Why I asked for a method Fang suggested is simply because I need a list of all available coordinate of a map to use for well, my custom features.
Though, my 2nd method of trying to find a way to do this. I already have an arithmetic method without an array of dictionary of coordinates. But I generated the coordinates after calculation which took alot less performance. Though this is trouble some when the math is different depending on which direction I shoot a skill as an example.
For Math calculation to make cones and such, I got all that no problem.
So then, something I have yet to try but very unsure of, how efficient is using array and the Where => method? Will it still loop through entire array and lag as **** since coordinates are like 1500 x 1500 on some maps.
|
|
|
09/20/2014, 18:20
|
#6
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
|
Quote:
Originally Posted by drakejoe67
Only using math is fine, it just makes things take more time and since I am using this for multi purposes I think it's easier to do like Fang said.
Why I asked for a method Fang suggested is simply because I need a list of all available coordinate of a map to use for well, my custom features.
Though, my 2nd method of trying to find a way to do this. I already have an arithmetic method without an array of dictionary of coordinates. But I generated the coordinates after calculation which took alot less performance. Though this is trouble some when the math is different depending on which direction I shoot a skill as an example.
For Math calculation to make cones and such, I got all that no problem.
So then, something I have yet to try but very unsure of, how efficient is using array and the Where => method? Will it still loop through entire array and lag as **** since coordinates are like 1500 x 1500 on some maps.
|
The where method in Linq acts like a query. It uses conditionals as well. I'm not sure how they do it, if it's in parallel or just in sequence (which would be even more inefficient than a dictionary), but it's still not the way to do it. Again, I would just use a simple algorithm and an array (storing each row in sequence that can be accessed using the following formula).
coordinates + (x * width)) + y
|
|
|
Similar Threads
|
String resource and npc resource database manager error
01/06/2014 - Rappelz Private Server - 2 Replies
I want to make changes in string resource and npc recources (files names are "BHwGAUC}_@,ld5Q`A {C" and "sdXwe'vmvdeHga$"). I opened them with rappelz manager 2012 and tried repack them but I was getting some sql errors. Is there any other programs that I can download and use for it?
|
Resource Offsets for wood/herbs coordinates
01/23/2010 - General Gaming Discussion - 6 Replies
hey just want to know how to get the offsets of coords of the resources like wood/ore and herbs. or does anyone know them? Trying to make a new Gatherer bot.
|
All times are GMT +1. The time now is 14:33.
|
|