I see no definition for 'rooks' in the code you posted. It could be that it doesn't like that. Another problem could be the case where 'locust' is 'undefined' (as it might be for most moves). I don'tknow how the match operator handles that. If there still is an error after defining rooks, try to insert an extra
#locust and
Directly after
def BadZone
This might make the code more efficient anyway, because it would never get to the match parts (which might be expensive) for moves other than castling or e.p..
I see no definition for 'rooks' in the code you posted. It could be that it doesn't like that. Another problem could be the case where 'locust' is 'undefined' (as it might be for most moves). I don'tknow how the match operator handles that. If there still is an error after defining rooks, try to insert an extra
Directly after
This might make the code more efficient anyway, because it would never get to the match parts (which might be expensive) for moves other than castling or e.p..