Advertisement

Function Tree Notation

Started by March 05, 2003 03:34 AM
2 comments, last by Convict@Large 21 years, 8 months ago
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]
DanielB - Slayer of Bugs
Tree was ment to be:
     R    / \     1   2        /|\           1 2 3     


Edit: Please use the 'code' tag for overriding the auto formatting of the forum, Timkin.

[edited by - Timkin on March 5, 2003 6:39:34 PM]
DanielB - Slayer of Bugs
Advertisement
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.
Timkin and TinOmen thanks for your help!

Convict@Large
DanielB - Slayer of Bugs

This topic is closed to new replies.

Advertisement