Here I am again with one more bug ;)
In file chess2.txt the 'stalemated' subroutine doesn't recognise en
passant captures. I tested this with my Squirrel chess preset. In a
position where the only legal move is an ep capture, it says
'stalemate'.
By experimenting I found that it should work if in the functions P and p
'#ep' is replaced by 'var ep'.
It seems that '#' inside a function inserts the value of the variable at
the time the function is defined, while 'var' is reading the value when
the function is executed. But this seems not to be so for subroutines.
Here # and var have the same effect (at least I haven't observed a
difference yet).