I'm trying to write a simulation for snakes and ladders in Matlab but I'm stuck.
How would I write something to check if the player is on a square that has a snake or ladder? I read somewhere that in Python you can just use something like "if newposition in snakes" (where snakes is an array of all the snake related moves), but I don't think the "in" command works in Matlab?
I was thinking I could just do "if newposition = 2, position=5" but I'm sure there's an easier way than making 100 if statements right...
Any help would be great, thanks
if isladder(position) == 1. Also, the commandsany,all, andisequalmay be helpful. And learn to combine short-circuiting operators&&and||in singleifstatements. – horchler Sep 27 '13 at 18:27