Skip to content

Instantly share code, notes, and snippets.

View billychappell's full-sized avatar

Billy Chappell billychappell

  • Self-employed/Contractor
  • Twin Falls, Idaho
View GitHub Profile
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"]
@billychappell
billychappell / gist:21f1ff1451a82005bf71
Last active August 29, 2015 14:07
markovchaintext
<?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();
@billychappell
billychappell / gist:c83cf81d574265cc5e62
Last active August 29, 2015 14:07
RPS AI Arrays not holding value increases between throws
<?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').