If all the Wi-Fi routers that you were able to connect to previously were on and working, then something on your Mac is goofy.
All I can suggest is maybe doing an SMC and PRAM Reset, and if none of those work or improve the situation, then something is broken or just not working on your Mac and I would suggest getting it off to some Mac hospital where they should be able to do some tests and confirmations. If that is not possible, then I would pick up a USB Wi-Fi Dongle and see if it works,
There is a chance that the Wi-Fi airport card in your Mac is kaput, or at least sometimes goofy as it seems to work sometimes, but definitely not consistently, neither of which is very good, but definitely annoying.
- Patrick
======