reset password
Author Message
layla08
Posts: 70
Posted 17:57 Oct 22, 2015 |

When defining the (up-and-down y-pos-pair), the goal is to make one ball go down at double speed and another ball go up at regular speed. 

The method is receiving the state of world, y-pos-pair, which consists of 2 ball objects with the structure (color, y-axis, velocity). 

I figured out how to modify the y-pos using the velocity, but that just returns a number, not a ball object with the modified number.

Can anyone point me in the right direction on how to make this happen? I've checked all over the book and notes and can't seem to figure it out.

Thanks!

rabbott
Posts: 1649
Posted 18:08 Oct 22, 2015 |

Not quite sure what you are asking, but the update function normally returns something that has the same structure as what it received. If it received a list with two numbers, it should return a list with two numbers. If it received a list with two ball objects it should return a list with two ball objects. The changes it makes is not in the stucture of the world state but in the values stored in it, e.g., the y-pos of the two balls.

layla08
Posts: 70
Posted 00:32 Oct 23, 2015 |

Thanks! Error is fixed, but for anyone else who is struggling with something similar, I was getting an error that said:

Expecting: ball

Getting: 50

(paraphrasing)

It was because I was modifying the y positions and trying to returns numbers instead of using those numbers to update the ball objects and returning a list of balls. Like you said, the update function should output the same structure as it's input.