A Pen by Captain Anonymous on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
#Setting initial variables | |
winCount = 0 | |
throwCount = 0 | |
lossCount = 0 | |
drawCount = 0 | |
#The player's previous selection determines the current state for the next game. The initial state is used as the current state for the first game where there is no "last move." | |
initialState = ["rock", "paper", "scissors"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$state1 = array('Element1'=>2, 'Element2'=>5,'Element3' =>3); | |
$state2 = array('Element1'=>2, 'Element2'=>3,'Element3' =>5); | |
$state3 = array('Element1'=>5, 'Element2'=>2,'Element3' =>3); | |
$currentstate = $state1; | |
$markov = array(); | |
for($i = 0; $i < 10; $i++) { | |
$newState = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Current state is chosen based on the player's last move. The value of each element is equal to the number of times a player has chosen ROCK/PAPER/SCISSORS after the same previous move. | |
$initialState = array('ROCK'=>1, 'PAPER'=>1, 'SCISSORS'=>1); | |
$rockState = array('ROCK'=>1, 'PAPER'=>1, 'SCISSORS'=>1); | |
$paperState = array('ROCK'=>1, 'PAPER'=>1, 'SCISSORS'=>1); | |
$scissorState = array('ROCK'=>1, 'PAPER'=>1, 'SCISSORS'=>1); | |
$currentState =& $initialState; | |
if (isset($_POST['button'])==1) { | |
//This takes the current state and uses the value of each element to populate a new array with that many elements. So, 'ROCK'=>2, 'PAPER'=>1 would create array('ROCK', 'ROCK', 'PAPER'). |