The calculation of the values within the Pascal trianlge, that is, the placing of the cloverleafs by Kara, is quite simple: Kara calculates the Pascal trianlge line by line, from left to right. When Kara reaches the end of a line, marked by a tree, he walks back to the beginning of the next row in the state "next row".
How can Kara calculate the value of a single field within the Pascal triangle? Kara uses the sensor "leaf on the ground?" to determine whether he stands on a field with a cloverleaf or on a field without a cloverleaf (field b in the above image). He now only needs to know if there is cloverleaf on the field to the right behind him (field a in the above image; the circled fields in the two images to the right) or not. Kara saves this information using two states:
carry0:
There is no cloverleaf on the field to the right behind Kara (an even number).
carry1:
There is a cloverleaf on the field to the right behind Kara (an odd number).