Consider the following approach to defining a “person” in a legal and moral sense:
A person is an individual in any form that shows at least some signs of internally created intention, rather than only simple automatic mechanical responses, in its action.
In other words, if a thing changes it’s responses to external input through some apparently internal process, and isn’t clearly entirely and directly being controlled by external forces, then we might say that this thing is an individual person with what appears to be at least some awareness of it’s own actions (it is self-aware, at some level) and thus probably has some personally driven motivation.
This doesn’t mean that things that by our assessment don’t show unpredictable behavior, and thus some internally motivated intention, don’t have any rights, it simply means that we have an option for a simple test of how to prioritize our morality and relationship with other individual things in our environment. We can still value things that are simple and mechanical, but we might choose to place more value on things that do show uniqueness and variability of action.
In other words, we might value diversity!