I did a recreation of the prisoner's dilemma in JavaScript for my artificial cultures class. It was thrown together in one evening, so it may not be perfect, but it should give a feel for the simulation.
The computer's strategies consist of: cooperate (computer always cooperates) compete (computer always competes) tit for tat (computer optimistically cooperates first, and then does what the player did on the previous turn. the golden rule) tit for two tats (computer has a memory span of two turns and always cooperates unless the player competes for two turns straight).