?
Solved

Guess the animal game in pascal

Posted on 2003-02-27
20
Medium Priority
?
461 Views
Last Modified: 2008-01-09
Can anyone help me making the animal guessing game in pascal.
Please help me.
0
Comment
Question by:bruno_carrulo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 3
  • +4
20 Comments
 
LVL 15

Expert Comment

by:VGR
ID: 8036922
???
what's this ?
0
 
LVL 3

Expert Comment

by:ILE
ID: 8038586
what is the animal game?
0
 
LVL 49

Expert Comment

by:dbrunton
ID: 8038656
Questions like

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

No source code offered here for perusal.  Homework?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
LVL 15

Assisted Solution

by:VGR
VGR earned 100 total points
ID: 8040138
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
 
LVL 1

Expert Comment

by:SimesA
ID: 8053336
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
 
LVL 4

Accepted Solution

by:
davidmwilliams earned 100 total points
ID: 8233556
Here's technical information on the Animal game - http://efsa.sourceforge.net/archive/bielak/animal_guess.htm
0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 8233561
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
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 8233562
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
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 8233574
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
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 8233593
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
 

Expert Comment

by:modulo
ID: 8241452
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
 
LVL 49

Expert Comment

by:dbrunton
ID: 8242027
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
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 8242158
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
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 8796295
So, where's the points?
0
 

Expert Comment

by:CleanupPing
ID: 9314377
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
 
LVL 49

Expert Comment

by:dbrunton
ID: 9316772
Split between VGR and davidmwilliams
0
 
LVL 15

Expert Comment

by:VGR
ID: 9324130
(always agrees with dbrunton)
0
 
LVL 15

Expert Comment

by:VGR
ID: 9324131
(always agrees with dbrunton)
0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 9324946
I'm happy with that suggestion - thanks :)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New style of hardware planning for Microsoft Exchange server.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question