creating rules for updating states and getting neighbors