Not sure what version of OS X you are running, but some of the following suggestions have helped some users:
WiFi Problems:
Wifi problems seem to crop up a lot on here and unfortunately there doesn't seem to be a 'one fix' solution.
However, sometimes any one of the following can help although, unfortunately, not always. In no particular order:
Check wifi security - if it's WEP change it to WPA or WPA2 (preferably, as it's more secure)
Change the wifi channel on the router
Create a new Network Location: http://support.apple.com/kb/HT5289
Reboot the router
Also take a look at this link and the links within the article for other ideas. They mainly reference Lion, but still seem to be relevant to Mountain Lion and perhaps Mavericks:
http://osxdaily.com/2011/11/06/lion-wi-fi-problems-solution-mac/?utm_source=feed burner&utm_medium=feed&utm_campaign=Feed%3A+osxdaily+%28OS+X+Daily%29&utm_conte n t=FaceBook
...and this link:
http://osxdaily.com/2012/11/30/resolving-stubborn-wi-fi-connection-problems-in-m ac-os-x/