[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

Guess the animal game in pascal

Can anyone help me making the animal guessing game in pascal.
Please help me.
0
bruno_carrulo
Asked:
bruno_carrulo
  • 8
  • 4
  • 3
  • +4
2 Solutions
 
VGRCommented:
???
what's this ?
0
 
ILECommented:
what is the animal game?
0
 
dbruntonCommented:
Questions like

Has it got four legs?
Does it swim?
Does it fly?

No source code offered here for perusal.  Homework?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
VGRCommented:
this feels like HW. Anyway, I like it.

Some ideas :
start with a textfile of (better) a file of records.
Each record (or set of lines in the textfile) would be :
-name of the animal
-properties of the animal (species, race, gendus, etc)
- values of the animal for allowed questions :
++movement mode (fly,swim,walk,run,fly, or a combination of course)
++members number (0..?) and type (legs, arms,...)
++extremities number (0..?) and type (hand, foot...)
++respiration mode
++colour(s)


Then of course the program would - if acting as the game master - try to answer questions from the user.
This is a difficult part if you allow plain English input (sentence/syntaxic analysis), but you may offer only the "allowed questions" in a menu, like "has it legs?", "has it X legs?" (X would be input by the user) etc

good luck, this seems interesting
0
 
SimesACommented:
The previous programs I've seen usually learn from the user.

The program asks questions, based on its previous "experience", then makes a guess when it runs out of questions.

If the guess isn't correct, then the user is requested to enter a question that would distinguish the guess from the correct answer. This question would be used next time this position was reached to improve the programs guess.

See http://www.guessmaster.com/question.asp for an example
0
 
davidmwilliamsCommented:
Here's technical information on the Animal game - http://efsa.sourceforge.net/archive/bielak/animal_guess.htm
0
 
davidmwilliamsCommented:
As an aside, if this is indeed a homework question, I would imagine your instructor is probably looking for a solution that involves an advanced data structure like a binary tree.
0
 
davidmwilliamsCommented:
As an aside, if this is indeed a homework question, I would imagine your instructor is probably looking for a solution that involves an advanced data structure like a binary tree.
0
 
davidmwilliamsCommented:
Looks like you're not the only one who had this homework question ;P

Here is some source code - written by columbo666 - from URL http://www.experts-exchange.com/Programming/Programming_Languages/Pascal/Q_10201058.html

-------------------------------

USES CRT;
TYPE ZEIGER=^ELEMENT;
ELEMENT=RECORD
T:STRING;N1,N2:zEIGER;
END;
VAR A,E,X,Y:ZEIGER;
C,C1:CHAR;TN:STRING;
BEGIN
NEW(E);E^.T:='Cat'; E^.N1:=NIL;
WHILE TRUE DO BEGIN
WRITE('Please figure out an animal ! ');
READLN;A:=E;
WHILE A^.N1<>NIL DO BEGIN
WRITE(A^.T,' ');
C1:=READKEY;WRITELN(C1);
IF (C1='J') OR (C1='j') THEN A:=A^.N1
ELSE A:=A^.N2;
END;
WRITE('Is it a ',A^.T,' ? ');
C:=READKEY;WRITELN(C);
IF (C='N') OR (C='n') THEN BEGIN
NEW(X);X^.N1:=NIL;X^.T:=A^.T;
NEW(Y);Y^.N1:=NIL;
WRITE ('What''s it''s name ? ');
READLN(Y^.T);WRITELN('What could I ask to distinguish between a ',X^.T,' and a ',Y^.T,' ? ');
READLN(A^.T);
REPEAT
WRITE('If I answer with No, which animal is it ? ');
READLN(TN);
UNTIL (TN=X^.T) OR (TN=Y^.T);
IF TN=X^.T THEN BEGIN
A^.N1:=X;A^.N2:=Y;
END ELSE BEGIN
A^.N1:=Y;A^.N2:=X;
END;
END ELSE BEGIN
WRITELN('Victory ! I guessed your animal.');
WRITE('Do you want to play another game ? ');C:=READKEY;
IF (C='N') OR (C='n') THEN HALT;
END;
END;
END.
0
 
davidmwilliamsCommented:
Note, by the way, that even if the code above does work correctly, it is not terribly elegantly formatted.

The person who marks your assignment may expect nice formatting, embedded comments and meaningful variable names.

Also, you may need to save your knowledge base (and re-load it on start) - that depends on the assignment specifications.

Still, hopefully it puts you on the right start!
0
 
moduloCommented:
Dear expert(s),

A request has been made to close this Q in CS:
http://www.experts-exchange.com/Community_Support/Q_20569276.html

Without a response in 72 hrs, a moderator will finalize this question by:

 - Saving this Q as a PAQ and refunding the points to the questionner

When you agree or disagree, please add a comment here.

Thank you.

modulo

Community Support Moderator
Experts Exchange
0
 
dbruntonCommented:
Disagree

PAQ but do NOT refund points

No reply from questioner.  Comments made by various experts.  Links suggested.  Code sample supplied.

NO REPLY OR FEEDBACK FROM QUESTIONER

PAQ but do NOT refund points
0
 
davidmwilliamsCommented:
Why does Bruno want to delete the question?  He's had sensible advice and guidelines - and even a starting piece of code - given by dbrunton, VGR, SimesA and myself.

I think - especially for a homework question - he's received some good responses.
0
 
davidmwilliamsCommented:
So, where's the points?
0
 
CleanupPingCommented:
bruno_carrulo:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
dbruntonCommented:
Split between VGR and davidmwilliams
0
 
VGRCommented:
(always agrees with dbrunton)
0
 
VGRCommented:
(always agrees with dbrunton)
0
 
davidmwilliamsCommented:
I'm happy with that suggestion - thanks :)
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 8
  • 4
  • 3
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now