Problems reconnecting to WiFi if connection is lost
The WiFi on your MBP is, by design, supposed to reconnect to known networks automatically without the intervention of the user and/or an automated script.

That said, WiFi issues seem to have been an ongoing issue for Apple:  How do I connect my Mac to wifi automatically?

Now, I am assuming that this is a simple home network where you just have to select the network you want to connect to and provided you have the right passphrase or key, you get connected and away you go.  

Given that you have a MacBook and it's portable, have you tried different networks - like gone over to a friends or a relatives home and see if the systems exhibit there?  If so, then the issue is limited to your MB, and not the router.

Also, does anyone else report having the issue with your router?  If not, it will again confirm that the problem is with your MBP and not the router itself.

What you can try:  Delete the Airport .plist

To  delete the plist file associated to the Airport,


Disable Airport
Delete the plist file; /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist
Re-enable airport and select your favorite network again


This will delete ALL connections of the connections in your saved WiFi networks. You will need to save all of the passwords for all the networks that you want to connect to later.



How to get your WiFi Passwords

Before you delete the plist, you will want to make a copy of all your SSID passwords.  They are stored in your Keychain.

When you open your Keychain (CommandSpace and type "Keychain" to use Spotlight to open it) you will see a list of saved credentials from websites, to network passwords and of course the one we are interested in, Airport Passwords.



If you right click on the WiFi network you are interested in, you will have the option to "Copy the Password to the Clipboard" (how convenient is that?!?!)



You will be then asked to authenticate 2 times.  The first time because OS X will want to "make changes to your computer" and then a second time because it wants access to your "System Keychain"



This will require you to type your user name and password of an Administrator (if that's you, then your username and password).

You can now paste that password anywhere...



Or maybe in a spreadsheet for safekeeping...