|
Internally, you'd use vector, but I believe the answer is VARIANT, which has VT_ARRAY as one of it's types, which needs to be ORed with an actual type to make an array of.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Dear CG,
Thanks for that. But I am now horrified by a new realization.
Read my new post for more info...
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=124762#xx124762xx
Nish [still under shock]
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
Check ATL's CSimpleArray / CSimpleMap. These templates are not documented, so you will have to take a look on the implementation
|
|
|
|
|
If you want to enumerate a collection there is another mechanism more flexible and interesting then SAFEARRAY - take a look at enumeration interfaces ( IEnumXXX). ATL has support for this ( IEnumOnSTLImpl, etc) but you can do it by yourself very easily.
|
|
|
|
|
hi:
how to new a doc in MDI application ?
Thanks
benben
|
|
|
|
|
If you have a pointer to the CDocTemplate for the document, you can create a new instance of it using
pDocTemplate->OpenDocumentFile(NULL) ;
If you need to do this from an existing doucment:
pDocTemplate = GetDocTemplate() ;
pDocTemplate->OpenDocumentFile(NULL) ;
or from anywhere else
CDocManager *pDocMan = AfxGetApp()->m_pDocManager ;
POSITION pos ;
pos = pDocMan->GetFirstDocTemplatePosition() ;
CDocTemplate *pDocTemplate = pDocMan->GetNextDocTemplate(pos) ;
pDocTemplate->OpenDocumentFile(NULL) ;
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
can anyone help me design a game tree for tictactoe. i am trying to do the recursion for the AI of the tictactoe and i cant seem to get it write. i decided to write the game tree 1st but i can figure out how to write it. can anyone kindly help me do that? anyways, thank you very much.
|
|
|
|
|
First of all...whats a game tree...?
Is this like a flowchart or something...?
What AI are you having problems with...determining a win with the active player or the computer making it's moves..?
Recursion will make your game logic IMO doubly hard...a simple double iteration loop would look much nicer on the eyes. Depending on how many times your recursion function is called, this could be very in-efficient. Unless i'm missing something...each time a function is called it pushe s it's params and locals onto a lifo stack, this could cause your stack to grow quite large i'd think.
Can you do it with a loop or MUST you use recursion...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
umm... i dont really have to do it using recursions. i am just practicing it for fun. oh a game tree is like a family with all the possible moves that can happen when playing tictactoe. i got my algorithm already just that i am having a harding trying to figure out how to evaluate the players moves then return the best move the computer can move. i was going to implement that by looking at a game tree but i can figure out how to write one. oh, i am trying to determine how the computer will move on the board after the player has moved. i made the computer as the 1st one to move as default. here is my algorithm:
Const int MAXDEPTH = 9;
CheckForMoves()
If Board is all Occupied or Player Won or Depthcount > MAXDEPTH
- return.
Else
- DepthCount++;
- GetPlayerMove(row & column);
- Evaluate Player Move and return the best move the computer can take.
If the Move the computer has made is a good move and The Board Cell is
empty.
- Computer makes the move
Else
- CheckForMoves() <-- Check for moves
I am getting a hard time trying to figure out how to evaluate the player move and how to make it return the best possible move and also how to check if the move done is a good move. well, if you guys think my algorithm logic is wrong let me know. and if so can you tell me a better algorithm to implement it
thank you very much...
|
|
|
|
|
AI for tic tac toe can be anything from simple as hell and fairly complex.
1) This simplest method of AI is to just iterate the array gameboard and check for NULL's, the first NULL = empty space which means...the computer should pick this spot.
Of course this doesn't leave for very interesting game play (not that tic tac toe would or could)
1) To spice things up a little you could add some more advanced AI and do something like...instead of take the first available spot...search the game board for a potential opponent win and fill that gap before they do, I think this would work best if the computer started second.
2) Then you could use a game tree (i'd never heard of that before). Something I was attempting to do in my comp sci class was actually dynamically store players moves in a db while executing and use this growing db as a method of choosing the next mostly likely win-win scenerio.
The second approach would best be suited for the computer if it starts second...but would provide night and day difference in AI...
If you sit down and think about it for a sec or two you'd probably think of a better way of doing this, but heres just a quick idea on how to implement this.
char move[9];
Then create an array of move's (tree) initialized with X and O's in different places. Use this tree to choose your next move.
The one downside to this method (which I just realised while writting this... is that you'd need one 'move' for each possible scenerio...to be able to use this method effectively...thats a whole lot of move[n]={X,O,O,X,O,X,X,O...}
This is only one possible solution to a problem which has many.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
Hi all,
I was wondering if there was a way to get/set the delay time between when a key is pressed and it starts to auto-repeat. Any info would be great.
TIA
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
HKEY_CURRENT_USER\Control Panel\Keyboard
KeyboardDelay and KeyboardSpeed
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
|
That's what I was looking for
Thanks a bunch!
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
Michael Dunn wrote:
Use SystemParametersInfo() instead, so the code will work if MS changes the location where the setting is kept in the future. The relevant constants are SPI_GETKEYBOARDDELAY and SPI_GETKEYBOARDSPEED.
Oh, thanks...
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
Consider the following array, whose contents are NOT sorted:
int Ids[10]={12,4,22,67,2,5,11,33,6,10};
If a binary search routine is written to search through this array, what will happen? For example,
Will the program abort, since the array is not sorted? or
will the binary search routine be successful, but inefficient? or
Will the binary search fail? or
???
Loli10
|
|
|
|
|
The binary sort will fail.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Binary search on a non-sort list will yield a LOT of erronious "not found"s.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Sort it first. Binary search expects a sorted array. It won't crash your program, but you will get wrong results for your search if the array is unsorted.
Nish
It's seven o'clock
On the dot
I'm in my drop top
Cruisin' the streets - Oh yeah
I got a real pretty, pretty little thing that's waiting for me
|
|
|
|
|
Hi
How to change row height in owner draw CListCtrl
which has Report View ?
--
NodeX
|
|
|
|
|
WM_MEASUREITEM probably...
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
WM_MEASUREITEM probably...
I try it, but this event never occured.
NodeX
|
|
|
|
|
To receive that message, it has to be owner drawn. Which also means you have to implement the WM_DRAWITEM and other messages.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi !
I am Ergin. I've been building a database program using CFormView. Now I need to get rid of the scroll bars but I can't. I mean I don't want it to be resizable or scrollable (I want fixed). I couldn't do that.
And as a second one I have a CTabCtrl inside and when I put a picture behind it , it ends up in the middle of the CTabCtrl. I think Tab is a hollow control. How can I correct this ??
If you answer I will be very pleased. Tomorrow I have to show the program off but still I couldn't finish it.
byeeee
|
|
|
|