One of the games that I've done more than a little bit of poking around at is The Legend of Zelda: Ocarina of Time for the Nintendo 64. One particularly interesting part of the game is the battle against Dark Link during the quest through the Water Temple. A typical battle with Dark Link plays out like this video on YouTube, uploaded by mtiller2006.
Dark Link's usual behavior in the Water Temple is to wait until you've gone to the opposite end of the room before even appearing. Then it just waits for you to get close to it, or target it, or try to attack it from a distance before it springs into life. It runs away if you get too close to it, and comes toward you if you get too far away. Dark Link isn't aggressive to begin with, but with enough time or enough prodding by the player, it begins trying to kick your ass.
Normal sword swipes get canceled out by Dark Link's sword swipes. Stab at Dark Link and he jumps up on top of your sword (and if he's feeling aggressive, he'll slash at you from up there too before jumping off). When attacked, he suffers damage, falls through the floor and then respawns, usually behind you.
Besides that, though, Dark Link's role is pretty simple. You battle him inside a boring square room. All Dark Link needs to do is walk around and use his sword, and do a couple of his own moves that the player can't do, such as standing on top of the other one's sword.
When placed in the Kokiri Forest by using actor replacement cheat codes, you see how Dark Link behaves when put into a room he wasn't intended to be put into. His home in the Water Temple is a simple, empty room, but in the Kokiri Forest there's deep water to swim in, fences to climb over, things to jump off of, and even a wall to climb (note that he doesn't make it to the top of the wall, but he does latch onto it and climb left and right pretty well).
Why would Dark Link be able to do all these things if the developers didn't intend him to? Well, this is one example where tweaking the game provides some insight into how the game was programmed. It's unlikely that the developers programmed Dark Link to be able to do all these things; it would be a waste of time, considering the room Dark Link was put into for the final game.
My theory is that Dark Link is basically a complete clone of Link himself -- programmatically. Only, instead of having a physical N64 controller held by a human that controls Link's moves, it's a "virtual" N64 controller operated by a simple program. So, when Dark Link approaches Link, the program basically moves its virtual control stick on its virtual controller in the general direction of Link. When Dark Link swings its sword at Link, the program just presses the "B" button on its virtual controller.
This explains why Dark Link is able to swim, climb fences, climb walls, and jump off ledges; all of these actions (for the player) only require you to use the control stick. So, because Dark Link has its own virtual control stick, it can do all these things too (not always perfectly; it couldn't make it to the top of that wall I had it climb).
I just think it's interesting how the developers used this kind of approach to programming Dark Link. Every other enemy in the game has a more proper program to dictate how it behaves. One would assume that Dark Link had a program just like all the other enemies. But as you can see here, Dark Link is the one enemy in the game that stands out, and therefore is the most interesting.
The general code behind Dark Link, I theorize, was also ported over to The Legend of Zelda: Majora's Mask for use with the character Kafei. In Majora's Mask, during a certain side quest you're allowed to take control of Kafei, and the entire sequence involves switching control back and forth between Kafei and Link. This implementation is done poorly and is prone to many glitches, indicating that the Zelda 64 engine wasn't designed to allow switching of characters. Also there are some cheats to switch places with Kafei while in Clock Town, similar to the cheat to switch places with Dark Link, evidencing further that Kafei's code likely evolved from Dark Link's.