Skip to content

Instantly share code, notes, and snippets.

@radiosilence
Created November 14, 2009 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save radiosilence/234685 to your computer and use it in GitHub Desktop.
Save radiosilence/234685 to your computer and use it in GitHub Desktop.
<?php
// Algotest
/*
For PN,
Assign next in line as target
End For
For PN,
If targets available are only self/other target restart
Assign random target (not self/other target)
If targets available are only self/other target restart
Assign random target (not self/other 2 targets)
End For
*/
$players = array(
"Adam",
"Boris",
"Caroline",
"Deiniol",
"Edward",
"Francesca",
"Gunther",
"Harriet",
"Imogen",
"James",
"Karl",
"Louis",
"Mike",
"Norman",
"Oscar",
"Paris",
"Quentin",
"Ralph",
"Steven",
"Tomas",
"Urma",
"Vera",
"Xandria",
"Yusef",
"Zacharia"
);
for( $i = 0; $i < count( $players ); $i++ )
{
$j = $i+1;
for( $j = $i+1; $j < $i+4; $j++ )
{
$targets[ $players[ $i ] ][] = $players[ ( $j < count( $players ) ? $j : $j-$i ) ];
}
}
for( $i = 0; $i < count( $players ); $i++ )
{
}
print_r( $targets );
/*
other bit
1: Was the killer a target of the killed?
If yes, killer gets random target out of the other two
If no, killer gets random target.
2: Who had killed as a target? (call them A,B)
3: Was A a target of the killed?
If yes, A gets target that isn't him
If no, A gets no target yet
4: Was B a target of the killed?
If yes, B gets target that isn't him
If no, B gets random target.
5: A gets remaining
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment