Page 1 of 1

Krogothe's Metal Spot Class

Posted: 05 Dec 2005, 18:20
by krogothe
I decided to make one anyways, to suit my AI better and improve my skills...
Init it and youll get an array with all the metal spots, already sorted in order of metal just for you. If its a pure metal map you can build mexes everywhere so no spots will appear since they are not needed.

http://fileuniverse.com/?p=download&uni ... ar&ID=1948

Calculating the distance and buildability of a spot is your job though.

Let me know if it doesnt:

-Find 100% of the Metal Spots in the absolutely optimal position 100% of the time.
-Give the correct amount of metal 100% of the time.
-Place spots without flukes 100% of the time (Low ranked spots near good ones are fine).
-Work with ANY map and ANY mod or ANYthing you throw at it.
-Run stable without a crash 100% of the time.

If youre using it dont remove the cb->SendTextMsgs and give credit where due, thanks! (<3 u really af)

Posted: 05 Dec 2005, 19:54
by Masse
U CANT LOVE AF I DO <3
AF IS MINE <3
IM GONNA KILL U <3

just kidding... :roll: *whistles*

Posted: 05 Dec 2005, 20:23
by AF
Actually, the way its been doen ti shouldnt be easy tot ear outt he core of cains class and replace it with this giving us a nice new class that works even better.

Posted: 05 Dec 2005, 20:26
by krogothe
Do what you want as long as credit is fully given as explained above...

Dont expect anything less than perfection from this class tbh it took me a whole 3 hours plus twice that on testing, if it flukes or fucks up let me know ASAP

Posted: 06 Dec 2005, 20:33
by AF
Oh where to begin.

I had a terrible day yesterday and I finished it off tryignt o get this itnegrated into cains class.

Krogothe, go look at STL and cotnainer classes such as vector<>, you'd find them useful.

You forgot to add the metalspot class, we're nto all working on AAI source here.

As a result, this using a different method fo storing them I ahd to write code to convert ebtween the format you have them in and the format cains clas uses. Cains clss was good because the data it handled could be sent directly tot he engine without preprocessing, and used the same method as Zaphod, and the TAI 0.1 algorithm so you could rip out the core and stick a new algorithm in and still get the benefits of all the outerlayer mex placement stuff.

So i spent some tiem getting it all working and compiled. As soon as I started the game though it crashed. So i went back and looked again, changed a few thgins to see if I could get ti working. Same again. After 30 mins of fustration i deleted my source fodler and replaced it with a abckup. Then I saw the flaw. This algorithms save and laod mechanism is reliant on there being a folder inside which ti stores its files, much as the faulty 0.28.10 NTAI release relied on a folder called MEXCACHE and crashed if it wasnt found. But by then it was late and I was tired.

This class looks promising, and ti does a lto of stuff cains class cant do (savign and caching data for future dates for example, and writing TGA files)), and there's room fro improvement (cant blame him for not using STL classes and the liek he's still learning).

First suggestion:

replace the arrays BestSpots and tempbestspots, with vector<int> BestSpots etc.... they should work just the same in the existing code.

Also instead fo stripping mapnames of the extension, keep the extension and just add .m to the end. And store mex placement data in the aidll/globalai/ folder with the other AI stuff.

And preferably use a system whereas you use float3 variables, where the y value is the amount of metal. the y value is ignored by the engine so you can stick the data directly into a command and use it, and it's easier to use it for other stuff too.

your char filename[10] buffer etc arrays could be replaced just by char filename[30]; followed by an sprintf("//MEXFOLDER//%s.dat",GetMapName());.

Posted: 06 Dec 2005, 21:51
by krogothe
Okay, thanks for the hints and the great example of constructive criticism!
I Added the struct to the header file, removed dependency on the replace extension method, put the amount as the y coord...
Ill need to read up on vectors but it doesnt seem very hard at all, seems the same as lists! It surely is a better idea than creating 2 arrays to store the same data!
Im also playing around with more function such as finding spots by distance etc (its working pretty well, so far no probs in any map)...
once my (many) questions are answered ill post a new version of this class (which has to yet to screw up at finding spots)