Jump to content
  • Advertisement
Sign in to follow this  

Caml Light - Blocks World

This topic is 4905 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've been around with a lot of CAML light code and haven't figured out a way to create the Blocks World game... I've programmed this game before in Prolog, but now I'm trying to do it in Caml Light. The main problem is that in Prolog I used the "compiler built in tree" to run through all possible moves because I understand the way prolog files are read by the compiler. In Caml Light, how is the code file read? Is it read straightforward? Does it have e built-in tree I can use? Thanks for any help you can offer in programming this game in Caml Light. VisualFX

Share this post

Link to post
Share on other sites

Caml light has a built-in tree. You can build a tree as follows:

Binary Tree:

type 'a Tree = Lf of 'a | Nd of ('a * 'a Tree * 'a Tree );

//Initialize a tree
let tree = Nd(4, Nd(2, Nd( 6, Lf(7), Lf(8)), Lf(10) ), Lf(3) );;

To give you an example, you could traverse a tree in postorder and put all the elements in a list as follows:

let rec postorder = fun
(Lf x) -> [x] |
(Nd (a, b, c)) -> (postorder b)@(postorder c)@[a];;

I don't know much about your experience with Caml Light, but should you have any further questions, I would be glad to help!



Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!