# Help with simple number game

hey i need to make a game where:
the computer pick a random number from 15 to 30
the player starts first, he choses between 1,2,3. then the computer does the same thing.*note it has to substract the 1,2or 3 from the random number the computer picked. le last one to pick the number is a loser.
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
var
number, uno, cno: byte;
begin
Randomize;
number := Random(30)+1;
uno := StrToInt(Edit1.Text) mod 3; // user number
cno := Random(3)+1; // computer number
if uno <> cno then
// wrong
else
// right...
end;

that is easy :-)
0
Author Commented:
actually what u said random will equal any number from 1 to 30, i need it to random from 15 to 30
0
Commented:
oh, stupid =)
Random(16)+15;

:-)
0
Commented:
100% working solution :))
all the game in litle code

put two button one memo and one radiogroup on form

and in public put  broj:integer; like

private
{ Private declarations }
public
broj:integer;
{ Public declarations }
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
button1.Enabled:=false;
button1.Caption:='&Pick';
button2.Caption:='&New';
begin
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
label kraj;
var cb:integer;
begin
if cb>=0 then
begin
broj:=broj-cb-1;
if broj=0 then begin showmessage('you win'); button1.enabled:=false; goto kraj end else
if broj mod 4=0 then cb:=1 else cb:=broj mod 4;
broj:=broj-cb;
if broj=0 then begin showmessage('computer win'); button1.enabled:=false; end;
kraj:
end else showmessage('pick a number');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
randomize;
broj:=random(15)+15;
button1.Enabled:=true;
end;

work wery good a?

try to defeat computer :))
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
two questions it works 2 btw
1) what does broj:integer; mean?
2)what does label kraj; mean
0
Commented:
just put in the
broj:integer;
in the public declaration
that is the global variable i cen accses this wriable from any   procedure of tform1

the

label kraj

i the label declaration
that is for the             goto label   command
when use goto command u must first declare label
label is teh point where program jump when program found
goto command

i hope u anderstand me

i have a wery bad english :))
0
Commented:
broj:=random(15)+15; -> that gives 0-29
if broj mod 4=0 then cb:=1 else cb:=broj mod 4; -> mod 3 i suppose
kraj: -> :???
and the yhing is there is no "end else showmessage('pick a number');" cause you modify broj var which stores the random number...
0
Commented:
yep    broj:=ranodm(15)+15      GIVES 15-29    :)))

that
if broj mod 4=0 then cb:=1 else cb:=broj mod 4; -> mod 3 i suppose
kraj: -> :???
is 100% good nothing to change if u put mod 3  computer will lose most of the time    :)))

and the last Pick a nummber  is if a user dont chose any number in the start

so everythin is 100% corectly

opppps the number shoud be between 15 and 30

so broj:=broj:=ranodm(15)+16

only small corection :)))

0
Commented:
karatekid182:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
Commented:
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

...Snehanshu
EE Cleanup Volunteer
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.