In many larger WLAN setups you’ll find repeaters or extenders which spread the WLAN to farther places on the floor. Often they are set up in such a way that they use the same WLAN name (SSID) and password. In that case the WLAN hardware on your laptop will pick the best access point and connect to it. As far as I understand, Ubuntu won’t influence that decision but instead leave it to the WLAN driver / hardware. If there are multiple access points in reach there might be several outcomes:
1. Your laptop connects to the strongest WLAN and stays there and everything is fine.
2. Your laptop connects to the strongest WLAN and stays with it even if the signal deteriorates so much that it would be better to connect to a different AP (access point). Now you’re stuck with a bad connection.
3. Your laptop immediately drops a bad AP for a good one, constantly reconnecting and thus dropping your network connections all the time. Now you’re stuck with an unstable connection.
I found myself stuck with the 2nd situation and wrote the wifi-picker script  which will pick the best AP that serves a specific SSID. For example, assume you are already connecting to a WLAN called “home_wifi” which consists of a router in the living room and a repeater in the kitchen. You switch your laptop on in the living room, so it connects to the router AP. Now you take the laptop to the kitchen, but it stays connected to the router AP instead of connecting to the repeater AP.
Now run the wifi-picker script, as root, from the command line:
sudo wifi-picker wlan0 home_wifi
It will construct a list of all APs serving the home_wifi WLAN and reconnect to the one with the best signal as reported by the iwlist tool.