Search:

Type: Posts; User: Onions

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    41
    Views
    4,615

    I finally fixed this a couple of days ago. I...

    I finally fixed this a couple of days ago.

    I gave up on storing the information in a text file and used some vectors instead. Then I made a function which copies the vectors to an (otherwise...
  2. Replies
    41
    Views
    4,615

    I've changed it to this: while...

    I've changed it to this:



    while (file_to_read) {

    file_to_read >> chromosome_int_read;
    file_to_read >> fitness_string_read;

    ...
  3. Replies
    41
    Views
    4,615

    So, if I then opened the DEAD file to look at...

    So, if I then opened the DEAD file to look at what had happened would it look like



    111111111111 223 222222222222 342 111111111111 112


    Or would it still be
  4. Replies
    41
    Views
    4,615

    Well, it compiles and runs, yes. But after it has...

    Well, it compiles and runs, yes. But after it has made a few enemies the game crashes for random reasons again.
  5. Replies
    41
    Views
    4,615

    I've tried your loop, Bench. It still crashes,...

    I've tried your loop, Bench. It still crashes, unfortunately.
  6. Replies
    41
    Views
    4,615

    Crashed. Even if it tries to read just one...

    Crashed. Even if it tries to read just one chromosome and fitness from that DEAD file it crashes.

    (Sigh)
  7. Replies
    41
    Views
    4,615

    I commented out the loop which reads in the...

    I commented out the loop which reads in the chromosomes and fitness integers, and just shoved this there:




    string chromosome = "222222222222";

    for (int i = 0; i < 215; i++) {...
  8. Replies
    41
    Views
    4,615

    Yeah, I can do it in a new program. With a vector...

    Yeah, I can do it in a new program. With a vector too.

    [I'm talking about what 7stud described]

    I just don't get this at all.

    When an enemy is destroyed, it's chromosome and fitness is...
  9. Replies
    41
    Views
    4,615

    Hmm...it crashes the moment it tries to use that...

    Hmm...it crashes the moment it tries to use that loop.

    Why exactly is it a problem if you use getline() twice?
  10. Replies
    41
    Views
    4,615

    Well, the code now looks like this... ...

    Well, the code now looks like this...



    ifstream file_to_read("DEAD.txt");

    string chromosome_string_read;
    chromosome_string_read = "";

    string fitness_string_read;
  11. Replies
    41
    Views
    4,615

    They are both strings. I have tried reading...

    They are both strings.

    I have tried reading in a different file using the same sort of method, and that crashes the game as well. I can't seem to read in anything from a text file without it...
  12. Replies
    41
    Views
    4,615

    I've changed it to this, and it STILL crashes. ...

    I've changed it to this, and it STILL crashes.



    while (getline(file_to_read, chromosome_int_read, '_') && getline(file_to_read, fitness_string_read)) {


    God, this is annoying. If I remove...
  13. Replies
    41
    Views
    4,615

    Ah, OK.

    Ah, OK.
  14. Replies
    41
    Views
    4,615

    Mate, sorry I'm being such a dumbass here...but I...

    Mate, sorry I'm being such a dumbass here...but I don't understand what you mean by that.

    Can you explain what you mean exactly?
  15. Replies
    41
    Views
    4,615

    So, how do I stop it from reading in a blank...

    So, how do I stop it from reading in a blank chromosome and a blank fitness? It can't be good having them in the string vectors.
  16. Replies
    41
    Views
    4,615

    Right, OK...I've switched it to strings. And it...

    Right, OK...I've switched it to strings. And it still crashes after a short while.

    Looking at what happens, it seems it is reading in a blank line from the text file.

    If there are 6 lines of...
  17. Replies
    41
    Views
    4,615

    If I change it to... ...

    If I change it to...



    file_to_read.get(chromo_char_read, 13, '_');


    The game freezes when it tries to create a new enemy.
  18. Replies
    41
    Views
    4,615

    Yes, I wanted to treat it as a string...so get()...

    Yes, I wanted to treat it as a string...so get() is the correct function to use, eh?
  19. Replies
    41
    Views
    4,615

    Oh, OK...sorry, just read your other bit. ...

    Oh, OK...sorry, just read your other bit.

    "chromosome_int_array" is a vector of strings. I've been meaning to change the name, it's confusing and stupid.

    I'll just add that 2nd parameter of...
  20. Replies
    41
    Views
    4,615

    OK. So, I changed it to... ...

    OK. So, I changed it to...



    file_to_read.get(chromo_char_read, 13, '_');


    But it still crashes. Am I being really stupid here?
  21. Replies
    41
    Views
    4,615

    File I/O problem

    Hi.

    In the game that I am making, I use a genetic algorithm to evolve the enemies.

    The way I store the enemies "DNA" is in a text file.

    But, when I am reading the text file in and storing...
  22. Replies
    3
    Views
    913

    class EnemySprite : public Sprite ...

    class EnemySprite : public Sprite
    {
    protected:
    int m_iChromosome;
    int m_iFitness;
    ...
  23. Replies
    3
    Views
    913

    Writing a member variable to a text file

    Hi,

    I have an EnemySprite object that has an int member variable called Chromosome. The value of it is "1".

    I'm trying to write that value to a text file, but instead of getting "1" I am...
  24. Replies
    12
    Views
    1,248

    Ohhh, I see. I had no idea you could do that with...

    Ohhh, I see. I had no idea you could do that with strings.

    You'll have to forgive me - I'm in England, and it's been a long day.
  25. Replies
    12
    Views
    1,248

    But if the string is "1123211132", how do I...

    But if the string is "1123211132", how do I actually access the characters within?

    In Java, I'd just do stringName.getChar(index)...is there a C++ way of doing that?
Results 1 to 25 of 31
Page 1 of 2 1 2