[Haskell-cafe] My old chess player

paolo veronelli paolo_veronelli at yahoo.it
Thu Jul 1 13:02:06 EDT 2004


Ok Crypt Master give the hint to pronounce something ,because I feel a 
complete stupid in front of Functional Programming' though I'm a trained 
imperative one.

I've read the nice paper www.cs.chalmers.se/~rjmh/Papers/whyfp.html  and 
remember may years ago the hard job done to make my chess engine work ,but 
that was imperative C that's why it was hard ,isn't it?

John Huges say the way for trees is

data Albero position=Foglia position |Ramo position [Albero position]

This is like Quantum-Mechanics for my head but it works ,I've tried.

figliatore creatore (Foglia position) =
	Ramo position (map (figliatore creatore) (creatore (Foglia Position))

This I don't know how to try it but I'm faithfully blind........

Now I would like to make a change to fit my player,but the wall is too 
high.
My function 'creatore' in fact would take a list of moves and a starting 
position as argument, not a nice ready position.
My imperative engine stored leaves with a pointer to their mothers so that 
it was easy to track the list of moves.
Now maybe I have to change Albero definition in

data Albero move mother=Foglia move mother |Ramo move mother [Albero move 
mother]

Is this the way?

the road tracker is going to be

pather (Foglia move mother)=
	if mother==() = ()
	else = (pather madre ):madre

This doesn't compile!!

And I don't write the new 'figliatore' not to insult anyone


						Thanks For Comments Paolino

Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/



More information about the Haskell-Cafe mailing list