I want to play D&D but have no one to play it with. Is there a virtual DM that creates the adventure as you play? If not, is anybody good enough at programming to do it?
Nothing quite like that exists.
What you are talking about would be a D&D simulator, the closest thing to it might be Neverwinter, an MMO built on 4e's ruleset, but its not the same thing as playing 4e as a pen and paper game.
However there are ways to find others to game with
Discussion boards on sites like rpg.net or WOTC's 4e boards are a great place to find people to play with online. Once you find another group of players whose game and times match your desires then you can play with them over the internet using free software platforms developed for RPG gaming like roll20.net (You can also find players on roll20.net's forums).
Not really, no.
Creating the adventure as you play is simply too hard for modern software. It would have to actually understand what you're doing in order to generate appropriate content in the fly. Speech recognition, textual analysis, and procedural generation have come a long way, but they're still nowhere near where they'd need to be for a good virtual DM to be possible.
Your best bet is to either find other people near you (or online) who play or are willing to learn to play, or to use a video game that allows people to create their own adventures for other people to run (Neverwinter Nights 2 comes to mind).
The equivalent to this is any of the various adventure or RPG games available for computers. Games like Skyrim, Diablo, or upcoming games like Pillars of Eternity. Then there are the MMO ones like WoW and so many more.
None of these capture the true possibility and flexibility of role-playing games though.
A face-to-face game is best but you are not the only one who finds it hard or impossible to set up one of those. There are plenty of ways to play online with other people though using Play-by-post or tools like MapTools and Roll20.
For example I run a MapTools game online having found players on the giantitp forums:
I've only ever met one member of my group IRL and yet we have a good Pathfinder game running.
(Note: the following is copied and pasted from my review of these products)
The difference between the two versions is that Mythic Role Playing is a complete game system, and Mythic Game Master Emulator is systemless to be used to adapt other game systems to be GM-less, using the same methods set forth in the game system.
The basic concepts used to drive Mythic are Logic, Interpretation, Improvisation, and the Fate table (no relation to the game). Anything that should be asked to the GM is asked to the GM emulation engine instead, in a yes/no fashion. The Fate table is set up so that you look at the odds of getting a Yes answer and roll. This will let you know the actual yes/no of the question.
Taking that basic principle, Logic is used to get an idea of what would logically be able to happen next. This frames the question to be asked to the GM, i.e. there’s a door ahead in the dungeon. Is the door locked? Is it trapped? Is anyone behind it? Is who is behind it hostile?
Interpretation is the next used concept, as you interpret the yes/no answer according to the rules system and what makes sense. Mythic provides a framework for asking and answering the questions- those answers have to be interpreted logically.
Improvisation then becomes a very important concept. To drive the questions and the narrative, the players need to be able to improvise among themselves. This is an important role of the GM- to set the scene- that cannot be simulated. So the players must take it on themselves. As the questions are asked, the game world becomes more solid. But the players have to be able to ask the questions.
Mythic drives the creation of the game world and the random generation of the details based on the players’ improvisation and the questions that they ask. It won’t generate anything that is not imagined beforehand by the players, but this just makes the game more a narrative experience.
I’ve personally used it with great success with Fate; I’d imagine that any narrative system has a leg up on using this emulator. I’ve not even attempted it with games that are not driven that way, but in theory it should work for those also.
It’s a very well done implementation of a very esoteric tool, and very well presented to boot!
A demo of the emulator is available for free.
There was also a kickstarter for The Covetous Poet's Adventure Creator and Solo GM Guidebook. I just received the rewards for this and haven't had a chance to look at it closely, which is why I didn't write up a recommendation for it. More information can also be found at the official site.
It Requires AI
To give you anything close to the experience of a human DM would require an artificial intelligence capable of adapting to what you do on the fly, including when you do something not covered by the rules. This requires AI, and if you want an actual emotional connection it may require what is termed "strong AI".
While we have some hope for this for the future, I would not expect it anytime soon.
Depending on what type of experience exactly you want, you can consider some of the actual video games out there. I personally recommend Planescape: Torment highly. This is plotted out and does not allow the improvisation that a real GM allows. However, it does have an excellent plot with both tactical and emotional elements and the combat system follows AD&D 2e quite closely. There are other, newer games that follow later versions of the D&D rules with varying degrees of fidelity.
You can also try distance play using things like IRC, play-by-email, and play-by-post. These all have weaknesses when it comes to things requiring a battlemat, but there are ways around that. And for anything that is combat-light or runs combat as "theater of the Mind" they work quite well. These give you the full experience of everything except actually sitting around and sharing the same space with your partners.
As said, you will find nothing like a true gaming experience, but if you want to roll dices and hack monsters, you could try a dungeon generator. There are many, this is one quite good.
The main weakness of those generators is that you know the map even if you don't read what is there in each room before entering. There are game systems that generate the rooms and corridors as you explore them. I can recall that many MERP modules contained one of those systems. I think it is also the idea behind The Solo Dungeon, maybe you can use these rules, even adapt them to your source books.
If you are looking for something like a story generator, I only now Mythic, which is suggested in another answer.
Sorry that none of these proposals are software, but I hope they serve your purposes. Consider editing the question to narrow if this kind of resources solves your problem.