SRL Archive - Help

Logic not working? Lol


rj

2012-12-19 23:14:21

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:
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.

riwu

2012-12-19 23:19:42

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

rj

2012-12-19 23:21:48

From: riwu
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

Wardancer

2012-12-19 23:25:55

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

DannyRS

2012-12-19 23:27:05

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


This ^

rj

2012-12-19 23:27:17

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

riwu

2012-12-19 23:27:39

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?

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

User input.

Wardancer

2012-12-19 23:29:36

From: riwu
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.

rj

2012-12-19 23:29:43

From: riwu
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.


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

Wardancer

2012-12-19 23:33:08

^^
Please, write "is higher than".

rj

2012-12-19 23:44:03

lol final product:
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