glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[glob2-devel] AIHelper Constants


From: Bradley Arsenault
Subject: [glob2-devel] AIHelper Constants
Date: Sun, 27 Nov 2005 16:25:27 -0800

As many of you know, I am developing AIHelper. Lately, I've ran into a
bit of an issue with the large number of constants accociatted with
AIHelper. A while back, nct gave me some suggestions on my AIHelper.
He mentioned moving the constants into class scope. However, when I
move constant arrays into class scope, I get an error saying that I'm
not allowed to initialize them in class scope. I've already worked it
out with some c++ help people, it is impossible to declare and define
an array in class scope. So, that rules out the possibility to put the
constants into class scope.

I use constant arrays to give a preset number of elements constant
numbers. Rather than seperating it out into several constants and
having case switch statements choose between them, I prefer to put
them into one array, making it easily possible to index the constant.
For example, several of my constant arrays have to do with buildings.
Using constant arrays, its easy to index the constant I need based on
the type of the building, which provides for a healthy abstraction.

I don't want to declare the arrays in class scope and define them in
the source file, that would be uniform. I could declare all my
constants in class scope and put them in the sourcefile, but that
wouldn't be uniform either and would certainly be a bit wierd. I could
declare and define all my constants in the sourcefile, again thats
non-uniform, however it may be the best solution.

I thought of making a constant retriever class, one that can retrieve
constants (and constant arrays) by their name and other supplied
information. It would then be possible for these constants to be
changed at runtime without much effort. However, this would make for
quite verbose access of the constants,
"constant_retriever.getUint("construction_area_width")". I'm wondering
what everyone else on the list thinks about it.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]