Click here to Skip to main content
15,917,059 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to scroll the Edit box without flash Pin
LaHaHa20-Nov-05 18:11
LaHaHa20-Nov-05 18:11 
QuestionMFCListCtrl Question Pin
kevin12720-Nov-05 11:14
kevin12720-Nov-05 11:14 
AnswerRe: MFCListCtrl Question Pin
followait20-Nov-05 14:55
followait20-Nov-05 14:55 
GeneralRe: MFCListCtrl Question Pin
kevin12720-Nov-05 15:51
kevin12720-Nov-05 15:51 
GeneralRe: MFCListCtrl Question Pin
kevin12720-Nov-05 15:59
kevin12720-Nov-05 15:59 
QuestionAre plugins necessary in this situation? Pin
hymerman20-Nov-05 10:49
hymerman20-Nov-05 10:49 
AnswerRe: Are plugins necessary in this situation? Pin
Roger Allen21-Nov-05 6:54
Roger Allen21-Nov-05 6:54 
GeneralRe: Are plugins necessary in this situation? Pin
hymerman21-Nov-05 13:29
hymerman21-Nov-05 13:29 
Well, I've been thinking this whole idea through and I've come to another stopping point... Let me fill you in on the wider picture:

There are actually three 'types' of genes in my implementation; Code genes (like the ones I've been taking about), variable genes (which code for just that, a variable- be it a bias, a weight for something, the number of legs the creature has, whatever), and 'enabler' genes (which are a boolean, and an integer specifying how many genes after that gene are to be skipped or not). The genetic code is pretty much static- that is, during the lifetime of a creature, the individual positions in their genetic code will always mean the same thing, and the code will not get bigger or smaller. What will change is the values held at each position in the genetic code.

I need some way of storing what each position codes for (which type of gene), and also the section of code to be executed, should a particular position call for it. I figure that a base 'gene' class is a sensible start. I also figure that 'VariableGene', 'EnablerGene' and 'CodeGene' should inherit from this 'Gene' class. Finally, each of the snippets of code should be in classes of their own which inherit from 'CodeGene'.

Now, where it starts getting hairy is here: There are many positions that code for each of these types of genes, so that suggests to me that I should create an instance of the appropriate gene type for each position in the code, to store in the manager. So, I have a gene for the maximum speed of a creature, I create an object of type 'VariableGene', and add it to the manager. There will also be many positions which code for a particular thing the creature has to think about, so it makes sense to create an instance of the 'CodeGene' class for each of these. The tricky bit is that these instances need to somehow store the set of possible code snippets the creature can run for this gene (alleles, if you're into genetics).

It would be all too easy to have a static, self-registering class for each and every gene, but this wouldn't be a very nice solution- there would be a lot of redundancy, and a lot of arbitrarily named classes ("EnablerGene12" etc.).

My first question is: can instances of classes be registered automatically? If I recall correctly, only static classes can do things automatically at program instantiation.

My second question is: How would I go about storing a list of cope snippets (functions, if you will) in the instances of 'CodeGene', and more importantly, how would I get these code snippets to automatically register themselves? I could have a list of function pointers or somesuch, but that seems a bit hacky. Really, a class for each code snippet seems a good idea.

An example of how I envisage the system working: Some part of the program wants to know how many code snippets there are for a given gene. It queries the gene manager about a given slot in the genetic code, and the manager consults what is stored there. It finds an object of type 'CodeGene', and queries that object as to how many code snippets it can code for. The CodeGene object returns that number down the chain back to whichever part of the program needed to know.

Now, if anyone can suggest to me a better way of doing this, or give me a clue as to how to implement this (my C++ skills are a little rusty), then I'd be very appreciative indeed! Thanks for your help so far, and thanks in advance for your replies!
QuestionCHtmlView Question Pin
Mohammad A Gdeisat20-Nov-05 10:07
Mohammad A Gdeisat20-Nov-05 10:07 
AnswerRe: CHtmlView Question Pin
Sheng Jiang 蒋晟20-Nov-05 10:35
Sheng Jiang 蒋晟20-Nov-05 10:35 
GeneralRe: CHtmlView Question Pin
vikas amin21-Nov-05 0:54
vikas amin21-Nov-05 0:54 
QuestionCFile::GetPosition and Seek Pin
Felagund226820-Nov-05 8:18
Felagund226820-Nov-05 8:18 
AnswerRe: CFile::GetPosition and Seek Pin
Mircea Puiu20-Nov-05 9:58
Mircea Puiu20-Nov-05 9:58 
GeneralRe: CFile::GetPosition and Seek Pin
Felagund226820-Nov-05 10:51
Felagund226820-Nov-05 10:51 
QuestionMFC application migration to C# Pin
jacka199920-Nov-05 7:59
jacka199920-Nov-05 7:59 
AnswerRe: MFC application migration to C# Pin
ThatsAlok20-Nov-05 21:30
ThatsAlok20-Nov-05 21:30 
AnswerRe: MFC application migration to C# Pin
jacka199921-Nov-05 9:05
jacka199921-Nov-05 9:05 
QuestionHow to establish the programming enviroment to begin my DirectX program? Pin
sude20-Nov-05 2:50
sude20-Nov-05 2:50 
AnswerRe: How to establish the programming enviroment to begin my DirectX program? Pin
Gary R. Wheeler20-Nov-05 3:29
Gary R. Wheeler20-Nov-05 3:29 
QuestionVS 2005 Add-Ins Pin
Franz Klein20-Nov-05 0:15
Franz Klein20-Nov-05 0:15 
QuestionCreateFile in ext2 Pin
Aqueel19-Nov-05 21:03
Aqueel19-Nov-05 21:03 
AnswerRe: CreateFile in ext2 Pin
kakan20-Nov-05 19:59
professionalkakan20-Nov-05 19:59 
QuestionSignature bytes Pin
zooley19-Nov-05 20:18
zooley19-Nov-05 20:18 
QuestionHelp for MFC OCX control Pin
Rajesh match19-Nov-05 19:47
Rajesh match19-Nov-05 19:47 
QuestionError R6029 Pin
IceWater4219-Nov-05 19:27
IceWater4219-Nov-05 19:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.