Results 1 to 5 of 5

Thread: Randomization problems.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Thanks. It works fine now. I changed it to 10 and now it returns 3 if I divide with 9 and mod is 0 or divide with 8 and mod is 1(I didn't want 0 to count for both) else it returns 0. I did this because 50-50% was not the optimal randomization for what I wanted. However I'm proud of myself I solved a problem all by myself by using OOP which I'm still very new to Problem was this:
    Code:
    Procedure playerturn;
    begin
    //do some things and loop until player misses.
    aiturn;
    end;
    
    Procedure aiturn;
    begin
    //do some things and loop utnil AI misses
    playerturn;
    end;
    this returned an error because the first procedure couldn't find the second. I found out however if I make an object for both of these procedures I'm able to make the procedures call each other. Cheers

  2. #2
    You can also fix that by adding:

    Code:
      procedure playerturn;
      Procedure aiturn;
    in the interface part of your unit (usually just above the word "implementation"). That will make sure that they can always be found by all code in the implementation section.

    Also, I see that you have two procedures calling eachother. You have to make sure that this won't cause in anfinite loop. These kinds of inifite loops will cause the Stack-overflow error.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  3. #3
    Of course I'll make that sure. They will not stack more than a hundred times for sure. That shoudln't cause an error. (As the game field is just 100 squares and after every single square has been shot it is sure that the game has ended). I mostly just use units for procedures and functions that I use often in other programs too (like a weighted mean calculation or a function maximum calculation) and as I progress with this game I have found other use of the "AI" object too but thanks this might be useful later on

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •