Archived

This topic is now archived and is closed to further replies.

Convict@Large

Function Tree Notation

Recommended Posts

I've been reading the interesting article on this site about "Application of Genetic Programming to the 'Snake Game'" in the AI section: http://www.gamedev.net/reference/articles/article1175.asp I can follow most of it but I am having trouble understanding the notation that the author uses for showing the function trees of the varous solutions that were generated (this is the solution for the zig-zagger from the results section): (ifFoodAhead (ifDangerLeft (right )(ifDangerRight (1forward )(ifDangerAhead (left )( 1forward )))) (ifDangerAhead (ifDangerLeft (right )(left )) (ifDangerLeft (ifDangerRight (forward )( 2right )) (progn2 (left )(right ))))) I understand that it is a tree of functions, like the usually 'tree' used in computing: R |1 2 /|3 4 5 But how do you tell from the notation above which branch is which? Cheers, Convict@Large PS: ack can't get any indenting to work [edited by - convict@large on March 5, 2003 4:35:43 AM] [edited by - convict@large on March 5, 2003 4:36:02 AM]

Share this post


Link to post
Share on other sites
The code is built with nested function-calls, each taking two arguments, and returning true or false.

The first ifFoodAhead is the tree root, and every function call branch left and right with the first and second argument.

The leafs of the tree are the actions: left, right, forward.

Share this post


Link to post
Share on other sites