nyStagmus

Members
  • Content count

    97
  • Joined

  • Last visited

Community Reputation

122 Neutral

About nyStagmus

  • Rank
    Member
  1. class constructor issue

    You might want to start using pointers and dynamic memory allocation here.. E.g. //Game.h #ifndef GAME_H #define GAME_H #include <string> #include <vector> #include "Board.h" #include "Computer.h" #include "Human.h" using std::string; using std::vector; class Game { public: Game(); ~Game(); char AskYesNo(string prompt); char Opponent(char side); bool IsLegal(const vector<char>& field, int move); char Winner(const vector<char>& field); void AnnounceWinner(char humanSide, char computerSide); void Play(); private: Board m_Board; Computer *m_Computer; Human *m_Human; }; #endif //Game.cpp (only up to the constructor part. The rest is irrelevant.) #include <iostream> #include <string> #include <algorithm> #include <cctype> #include "Game.h" using std::cout; using std::cin; using std::string; using std::count; Game::Game() { string name; cout << "Please, enter your first name: "; cin >> name; int firstmove = AskYesNo("Do you require the first move? <Y/N>: "); if (firstmove == 'Y') { m_Human = new Human(name, 'X'); m_Computer = new Computer("The machine", 'O'); } else { m_Human = new Human(name, 'O'); m_Computer = new Computer("The machine", 'X'); } } Game::~Game() { delete m_Human; delete m_Computer; } Of course, it might need some more error-checking due to the increased complexity of dynamic memory.
  2. References c++ question

    Quote:Original post by password Do you think it's enough to pass the prompt string as a reference alone? If you do that you will have to explicitly instantiate those strings when calling those functions.
  3. The only way to be really sure that it will be platform-independent is to provide the RNG yourself. Try googling for it. There are lots of good (and less-than-good) algorithms available.
  4. Convertion

    It's been a while since I did Pascal, but I seem to remember the ord procedure. Try some_int = ord(some_char) edit: But that might not solve your particular problem...
  5. Pushing pointers into a std::vector

    Make sure that _Data isn't NULL when deleting. In the destructor try: if( _Data ) delete _Data;
  6. Which is cheaper? sqrt() or Trig?

    I think that this is a fine example of why all programmers should learn at least some asm. That is not to say that everyone should be experts in itty gritty low-level optimisations, since they are rarely needed, but it is always good to understand the inner workings of the cpu. Please note that this is not specifically directed at you Phalanx. It's just a general observation and opinion.
  7. delete *pTextureBuffer crashes

    Sorry all! I reread the code and I agree with you, it looks fine. My bad. Good luck with your coding.
  8. delete *pTextureBuffer crashes

    Quote:Original post by CodeMunkie That is not what he is doing though. It is perfectly ok to create a dynamic array of textures and then later access them individually to pass to CreateTexture. No problem there. I don't want to cause a fight here, but why would he want to pass them to CreateTexture? That way he would just get a memory sink where all his newed pointers are lost. As I said before it was a long time since I did DX, but IIRC there was never any need to new any DX interface. Please correct me if I am wrong.
  9. delete *pTextureBuffer crashes

    I'll give you a word of advice here: Stop coding right now and read through the DX documentation. Specifically, start with the tutorials and then work your way from there. It was some time since I worked with DX, but afair you don't create a texture with new, you create it from the IDirect3DDevice9 interface. It will initialize a lot of internal variables. Then you "delete" it by using Release(). So, as I said earlier: Read the documentation. You will need it!
  10. Adding to a "newed" pointer

    Like rypyr wrote in his example: Use std::list You can find more info on its member functions on msdn. It's very easy to use and fulfulls your requirements.
  11. A few points: 1. The human brain is in fact both digital and analog. There are literally hundreds of different kinds of neurons that look and work differently. 2. How we perceive temporal and spatial information, such as the touch of a hand, is imperfectly understood. What we know is that a part of the human brain, approximately the part at the top of your head, is laid out in such a manner that each small area represents an area of the human body. Exactly how that translates to us "knowing" where that is is currently not understood. 3. There is a similar concept like the one you describe. Look up "neural networks". It's been around for 20 or so years and is continually being researched and used around the world. 4. Someone mentioned doing some operations in parallell. This is currently not possible on existing computers, but if we had, say, a few billion parallell general processors, there is no reason we shouldn't be able to accurately model the brain. Summary: Take a look at "neural networks" and take a look at what is there today.