Has anyone programmed an AI to win Nethack? It seems like an obvious thing to try.

Yes!

https://github.com/krajj7/BotHack

https://www.reddit.com/r/nethack/comments/2tluxv/yaap_fullau...

Edit: I remember looking at BotHack at the time and being surprised at how extensively and elaborately hard-coded the strategy and evaluations were. This is definitely not machine learning!

Edit 2: HN discussion at the time: https://news.ycombinator.com/item?id=8990869