|
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!
|
|
|
|
|
Hi all,
I need to do the following with my C++ MFC program:
1. I want to download a webpage from the internet (http://www.mysite/mypage.html), this is done through the CHtmlview::Navigate method
2. when it finishes loading, I need to programitically fill a form in that page, lets say that the page contains elements button1, text1,... then how would I get/set their contents in my c++ program?????
any answers are welcome, source code is very preferable,
Thats all
Mohammad Gdeisat
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
|
http://secure.metawerx.net/resources/code/chtml.htm
check this link
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Something really weird is happening to me. I run the next code snippet:
<br />
int pos = File.GetPosition();<br />
File.ReadString(str1);<br />
File.Seek(pos, CFile::begin);<br />
File.ReadString(str2);<br />
str1 is different from str2 - str2 is read from a few bites earlier in the file. what's even wierder is that the difference between str1 and str2 is changing when I try this code on different locations in the file.
the file is unicode, hebrew and I'm running visual c++ 6.0, if it matters.
|
|
|
|
|
CStdioFile::ReadString() performs reading line-by-line (reading is stopped by the first newline character; the '\n' character is removed from the string). You do not use Seek for text files where information is stored on a line-by-line base.
Some information concerning the unicode staff in your case can be found here, at CP:
http://www.codeproject.com/file/utf16.asp[^]
SkyWalker
-- modified at 15:58 Sunday 20th November, 2005
|
|
|
|
|
I still don't get it - if the file pointer is located at the same point in both instances, why does it matter what order do I use to read?
is there a way to 'bookmark' a location and then read using readstring? is there a way to go back in the file?
|
|
|
|
|
I wanna convert my MFC application to C#. Please help with suggestions and/or tools?
-- modified at 8:47 Monday 21st November, 2005
|
|
|
|
|
thats the tough task... I believe you have to do that manually
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I decided to rewrite the application.
For the UI conversion there is a tool RC Convertor from www.dudelabs.com but I cannot find any other tool which can convert my business logic code from C++ to C#.Will keep you posted with my progress.
|
|
|
|
|
:-DMy operating system is windowXP,and programming language is Vc++6.0.I want to begin to learn to use Directx 9 in my program .Do I need to install Microsoft DirectX 9.0 in my computer?Which Head file do I need to include in my program?
Anyway,How to establish the programming enviroment to begin my DirectX program?
Thank you very much for your answer!
sude
|
|
|
|
|
|
In VS .NET 2003 one used the following:
#import "libid:a155fa04-fade-491b-b007-fb9379ea47db" raw_interfaces_only named_guids
#import "libid:233ADBAD-405A-4249-AA0B-828093D57184" raw_interfaces_only named_guids
#import "libid:238B5186-2429-11D7-8BF6-00B0D03DAA06" raw_interfaces_only named_guids
to make use of the VCCodeModel, VCProjectModel and VCProjectEngine. However when changing to VS 2005 these libids are incorrect and I can't find the corresponding ones for VS2005. Does anybody know where I can find them?
I am the handsome one in the crowd.
|
|
|
|
|
Hello
As i told in earlier post that i am using MFC to read a file from a floppy that is using linux ext2 file system. Mr. Kaken told me that i could use CreateFile(...). Does CreateFile returns an handle to inode of that file?
Thanks.
We Believe in Excellence
-- modified at 3:04 Sunday 20th November, 2005
|
|
|
|
|
Hello again.
CreateFile returns a HANDLE (to the volume in this case). You use that handle to read from and write to the volume.
The HANDLE (AFAIK) doesn't mean anything outside Windows itself, it's just a unique identifier to use for file/stream operations.
When you open a volume, you get all the sectors of that volume as a contigous "file", kind of.
From there, it's up to you how to handle each and every sector. Just remeber, the smallest bit of information you can deal with is one sector.
|
|
|
|
|
Can anybody tell me how can i acces the first bytes at the entrypoint of an exe. I know the PE layout, format, but i don't know how i can translate the entrypoint to fileoffset and how i read those bytes?
-- modified at 2:25 Sunday 20th November, 2005
|
|
|
|
|
i developed one testmfc OCX control with GUI
when i tried to invoke OCX through create intance
hret = test.CreateInstance(__uuidof(TestOCX));
its creating successfully but no GUI parrt is showing.
any kind of help appreciated.
thanx ..
reagrds
Rajesh
|
|
|
|
|
Hi ...
I am new to VC++ though i have written a few C++ programs back in the day when u did not need a PHD in computer science to use a microsoft IDE.
Every .NET FORMS application i create using the wizard, terminates with a runtime error R6029 ... "This applicatoin cannot run using the active version of the .NET Runtime. Please contact the application's support team for more information."
That second sentence is a real laffer.
Even the simplest example in the VC++ 2003 tutorial has the same problem. It compiles and links just fine, but gives that message soon after the F5 key is struck.
I've never been a microsoft fan, and this crap just entrenches that dislike.
Any ideas or suggestions?
Thanks.
|
|
|
|
|
|
Thank you Graham ... it worked.
i had seen this b4 but i did not know how to apply it ... now i do. Besides, I culd not comprehend how THIS could apply to my shiny new VC++2003 system:
"R6027: An application built with /clr and the Visual C++ .NET 2003 (7.1) compiler is being run on a machine that only has version 3705 of the common language runtime, which is the runtime version that shipped with Visual C++ .NET 2002 (7.0)."
WHAT!!!!!
This solution raises lots of questions: Why does VC++2003 ship with the 2002 runtime library and NOT the 2003 version? Why does the 2003 compiler/linker generate code that does not run with the SHIPPED runtime?
Most important ... HOW ON EARTH WOULD ANYONE KNOW THEY SHOULD INCLUDE "/clr:initialAppDomain" TO SOLVE THE PROBLEM? Why didn't the build wizard include it if micro$oft KNEW of this ridiculous situation?
UNBELIEVABLE ... typical micro$oft ... maybe for ANOTHER TEN BILLION ...
GRRRRRRRRRRRR!
Thanks, Graham
|
|
|
|
|
I did a dialog to display the bmp picture. Then i add some coordinates and text using pDC.
But i don't know how to save this bitmap with what i have added as a bmp file?
Does any one can give me some tips?
Thanks!
|
|
|
|
|
Hi,
Capture the client area and save it.
HDC hdc = ::GetDC(hWnd);
CDC dc, memDC;
dc.Attach(hdc);
memDC.CreateCompatibleDC(&dc);
CRect rc;
::GetClientRect(hWnd, &rc);
CSize sz(rc.Width(), rc.Height());
CBitmap bm;
bm.CreateCompatibleBitmap(&dc, sz.cx, sz.cy);
CBitmap *pOldbm = memDC.SelectObject(&bm);
memDC.BitBlt(0, 0, sz.cx, sz.cy, &dc, 0, 0, SRCCOPY);
// now you can do what you need to with bm.m_hObject
memDC.SelectObject(pOldbm);
bm.Detach();
::ReleaseDC(dc.Detach());
Bye
Cool Ju
Dream ur Destiny
|
|
|
|
|
Hello, everyone,
I want to copy a dialog from one program's resource file to
other program's resource file?
I tried , but failed.
Who can tell me the right method to do this, Thanks a lot!
|
|
|
|
|
For a conventional (not .NET) application, that uses .RC files and a resource.h file, the most reliable approach is the following:
1. Open both resource.h files in the source file editor.
2. Use the "Open With" option in the File Open command to open both .RC files in the source file editor.
3. Use copy/paste to copy the dialog from one .RC file to the other.
4. Copy the resource ID's for the dialog and its controls from one resource.h to the other.
5. Note that you may have to manually renumber the ID's for the dialog, if they conflict with other ID's already in use.
Unfortunately, I don't do .NET programming, so I don't know the procedure there.
Software Zen: delete this;
|
|
|
|
|
Hi,all!
When i use the virtualalloc function to assign the memory, sometime the system told me that
'not enough memory,can't handle the command'. I think perhaps somewhere i assign the memory
and don't destroy it,But my memory is large enough-2G,i don't understand!
Who can help me?Thanks a lot!
|
|
|
|
|