Here is a quick debug 101 for problems like this, or how I would approach finding out what is wrong.
First, add log messages. This way you can easily see what is happening during runtime (the debugger has tool that can do similar stuff, but I am a bit old school). These log messages are displayed in browsers log and tell you what exactly is going on in your variables.
<img src="https://dl.dropboxusercontent.com/u/19921470/debug2.PNG" border="0" />
Here is the output:
<img src="https://dl.dropboxusercontent.com/u/19921470/debug.PNG" border="0" />
This suggests your problem is related to the second comparison in the event.
Another thing: It seems you use separate functions (copy pasted?) for AI and player movement. It's generally bad practice to copy paste same code to two places, and you should look for a way to use same functions for AI and player programs if they do the same thing.
And also; commenting your events is very, very useful when you come back to your project after two week vacation or show it off to people in the forums :P. I generally write short comment above every function about what it should do, what do the input variables mean and describe any return variables. At least for me this is a must, that way I don't have to spend anytime wondering what these events do :)
Hope this helps, your game keeps getting better every time I see it!