Results 1 to 11 of 11

Thread: Logic not working? Lol

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Logic not working? Lol

    I'm making a basic script that has nothing to do with botting but it appears to have broken logic. It picks a random number and if you put a higher number it is supposed to say to high and if it's to low then it sais to low. But, everytime it sais to low no matter what. Heres the script:
    Simba Code:
    Program Game;
      const
      RANDOM_PICK = 100;
    var
      Number,Tries,GuessInt:Integer;
      Response,Guess:String;
    Procedure DisplayResults;
    begin
      if (StrToInt(Guess)) > RANDOM_PICK then
        begin
        Writeln('TO HIGH!');
        end;
      if (StrToInt(Guess)) < RANDOM_PICK then
        begin
        Writeln('TO LOW')
        end;
      if (StrToInt(Guess)) = RANDOM_PICK then
        begin
        Writeln('WINNER')
        end;
    end;

    Procedure  AskGuess;
    begin
      If (InputQuery('Guess number', 'Number', Guess)) Then
      begin
      Writeln(StrToInt(Guess));
      DisplayResults;
      end;
    end;
    Procedure  PickNumber;
    begin
      Number := Random(RANDOM_PICK);
      Writeln('' + IntToStr(Number))
      AskGuess;
    end;
    Begin
    PickNumber;
    end.

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    If i pick any integer higher than 100 it will say too high?

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    If i pick any integer higher than 100 it will say too high?
    No it picks a random of that. Run the program in simba you will know what I mean

  4. #4
    Join Date
    Jul 2012
    Posts
    279
    Mentioned
    5 Post(s)
    Quoted
    46 Post(s)

    Default

    Where do you define Guess, aka give it a value? I can't find it.

  5. #5
    Join Date
    Nov 2012
    Posts
    2,351
    Mentioned
    55 Post(s)
    Quoted
    603 Post(s)

    Default

    Quote Originally Posted by Wardancer View Post
    Where do you define Guess, aka give it a value? I can't find it.
    This ^


    Programming is like trying keep a wall of shifting sand up, you fix one thing but somewhere else starts crumbling

  6. #6
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    LOL found the problem I was testing RANDOM_PICK when the variable "number" is were the random variable is stored

  7. #7
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    The script generates a random number b/w 0-99, and prints it. (and that's it), then it prints too high/low/winner if your input is >100/<100/100 respectively. What are you trying to do?

    Quote Originally Posted by Wardancer View Post
    Where do you define Guess, aka give it a value? I can't find it.
    User input.

  8. #8
    Join Date
    Jul 2012
    Posts
    279
    Mentioned
    5 Post(s)
    Quoted
    46 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    The script generates a random number b/w 0-99, and prints it. (and that's it), then it prints too high/low/winner if your input is >100/<100/100 respectively. What are you trying to do?


    User input.
    Oh right, thanks. Playing around with InputQuery, I see.

  9. #9
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    The script generates a random number b/w 0-99, and prints it. (and that's it), then it prints too high/low/winner if your input is >100/<100/100 respectively. What are you trying to do?


    User input.
    Simba Code:
    Program Game;
      const
      RANDOM_PICK = 100;
    var
      Number:Integer;
      Guess:String;
    Procedure DisplayResults;
    begin
      if (StrToInt(Guess)) > Number then
        begin
        Writeln('Your number ' + (Guess) + ' is higher then ' + IntToStr(Number));
        Writeln('TO HIGH!');
        end;
      if (StrToInt(Guess)) < Number then
        begin
        Writeln('Your number ' + (Guess) + ' is lower then ' + IntToStr(Number));
        Writeln('TO LOW');
        end;
      if (StrToInt(Guess)) = Number then
        begin
        Writeln('WINNER');
        end;
    end;

    Procedure  AskGuess;
    begin
      If (InputQuery('Guess number', 'Number', Guess)) Then
      begin
      Writeln(StrToInt(Guess));
      DisplayResults;
      end;
    end;
    Procedure  PickNumber;
    begin
      Number := Random(RANDOM_PICK);
      Writeln('' + IntToStr(Number))
      AskGuess;
    end;
    Begin
    PickNumber;
    end.

    There got it

  10. #10
    Join Date
    Jul 2012
    Posts
    279
    Mentioned
    5 Post(s)
    Quoted
    46 Post(s)

    Default

    ^^
    Please, write "is higher than".

  11. #11
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    lol final product:
    Simba Code:
    Program Game;
      const
      RANDOM_PICK = 100;
    var
      Number,Tries:Integer;
      Guess:String;
    Procedure DisplayResults;
    begin
      if (StrToInt(Guess)) > Number then
        begin
        Writeln('Your number ' + (Guess) + ' is ' + IntToStr((StrToInt(Guess))-Number) + ' higher than the correct number which is ' + IntToStr(Number));
        Wait(2000);
        IncEx(Tries, 1);
        end;
      if (StrToInt(Guess)) < Number then
        begin
        Writeln('Your number ' + (Guess) + ' is ' + IntToStr(Number-(StrToInt(Guess))) + ' lower than the correct number which is ' + IntToStr(Number));
        Wait(2000);
        IncEx(Tries, 1);
        end;
      if (StrToInt(Guess)) = Number then
        begin
        Writeln('WINNER');
        IncEx(Tries, 10);
        end;
    end;

    Procedure  AskGuess;
    begin
      If (InputQuery('Guess number', 'Number', Guess)) Then
      begin
      //Writeln(StrToInt(Guess));
      DisplayResults;
      end;
    end;
    Procedure  PickNumber;
    begin
      Number := Random(RANDOM_PICK);
      //Writeln('' + IntToStr(Number))
      AskGuess;
    end;
    Begin
    PickNumber;
    repeat
    Askguess;
    until Tries >= 10;
    end.
    bored.lol

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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