From: "Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org>
Subject: Re: [Beginner Problem] Varibles not getting assigned correctly
Date: Fri, 11 Jan 2008 17:51:58 GMT
Date: 2008-01-11T17:51:58+00:00 [thread overview]
Message-ID: <21Ohj.295340$Fc.165485@attbi_s21> (raw)
In-Reply-To: <13oe10uh39g0v85@corp.supernews.com>
Shane Smith wrote:
>
> type pits is array (1 .. 14) of Integer;
> type Score_Type is array (1 .. 2) of integer;
Your code would be easier to understand (and hence to comment on) if you were
consistent in your capitalization.
What does it mean for a pit or a score to be negative? Perhaps Natural or
another type or subtype based on the rules of the game would be better for the
component types here.
I presume the index of Score_Type represents a specific player. Using numbers is
probably not a good way to identify a player; an enumeration type might be better:
type Player_ID is (Human, Computer);
or some such.
> type arr_point is access pits;
> board : arr_point;
I see no reason to use access types in this program.
> procedure Status (Player : in integer)
It appears that the purpose of Status is to assign to Winner. It's usually
clearer to pass parameters than to modify global variables. I would think you'd
want something like
procedure Status
(Player : in Player_ID; Board : in Pits; Winner : out Player_ID);
Others have addressed your questions, so I won't repeat that here. I haven't
used a debugger for years, so I find it usually quicker to stick in some output
that to relearn how to use one. Given that gdb sometimes misbehaves, it can be
more effective, too.
--
Jeff Carter
"Propose to an Englishman any principle, or any instrument, however
admirable, and you will observe that the whole effort of the English
mind is directed to find a difficulty, a defect, or an impossibility
in it. If you speak to him of a machine for peeling a potato, he will
pronounce it impossible: if you peel a potato with it before his eyes,
he will declare it useless, because it will not slice a pineapple."
Charles Babbage
92
next prev parent reply other threads:[~2008-01-11 17:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-11 5:52 [Beginner Problem] Varibles not getting assigned correctly Shane Smith
2008-01-11 8:01 ` Niklas Holsti
2008-01-11 10:46 ` Peter Hermann
2008-01-11 17:51 ` Jeffrey R. Carter [this message]
2008-01-12 3:00 ` Steve
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox