How to Make a Randomly Assembled Text

php script from the Algorithmic Walk by Broken City Lab

Back at the end of March, we went on an Algorithmic Walk with some brave folks (who not only trusted in our custom software generated algorithm, but also ignored the weather). I had previously posted a link to where you could find a custom-assembled algorithm, should you be curious to try it on your own, but I also wanted to post the code, in case anyone has any need for generating  a randomly assembled text.

So, after the jump, there’s the PHP code for those interested. I’ve tried to make helpful comments throughout, and the text is sized to fit on an 8.5 x 11″ page if you want to print it out.

And here’s that code:

[php]
<?php
// this script was used to create the SCAVENGE THE CITY algorithm for a walk throughout Windsor on March 29, 2009
// it was hacked together by Broken City Lab from some tutorials that we’ve since lost track of

$steps = array(
0 => ‘Take a photo of whatever is to the left of the next Transit Windsor bus stop, include some indication of the bus stop’,
1 => ‘From here on, every time you see a Denial sticker, turn right’,
2 => ‘Take a picture of the next person you see’,
3 => ‘Draw a picture of the next piece of trash that you see’,
4 => ‘Get a picture of anyone sitting on a bus bench’,
5 => ‘Get someone outside of your group to take a picture of your group’,
6 => ‘Walk until you see a vacant storefront, keep a running tally of all the vacant storefronts you see from here on’,
7 => ‘Make the next fence you see prettier and take a picture’,
8 => ‘Ask the next person you see if they are American, if yes, genuinely inquire about the reason behind their visit’,
9 => ‘Walk until you see a public sculpture, then draw it’,
10 => ‘Turn left’,
11 => ‘Cross the street’,
12 => ‘Walk to Starbucks, count and note how many people are inside, then do the same at Milk or the Coffee Exchange’,
13 => ‘Insist on giving the next person you see a high-five’,
14 => ‘Walk one block to the east’,
15 => ‘When you see a Caesars sign on a streetlight post, go to the nearest restaurant and take note of their drink special’,
16 => ‘Wherever you are, claim this as your territory’,
17 => ‘Please note the number of trees you can see from where you are right now’,
18 => ‘Walk south until you a see a Chrysler car, then cross the street’,
19 => ‘Walk 1 block south’,
20 => ‘Stop, face the north and take a picture’,
21 => ‘Walk 3 blocks east’,
22 => ‘Turn right and walk for a block as a human chain, one person can be unchained to document this’,
23 => ‘Walk north until you see someone dressed inappropriately for the weather, then head south’,
24 => ‘Enter the next restaurant you see and make a very quick diagram of the floorplan’,
25 => ‘Walk down the next alley you see, do not take a photo of any graffiti’,
26 => ‘Go to the top floor of the next parking garage you see, and take a photo of something other than Detroit’,
27 => ‘In the next restaurant you pass, ask what the special of the day is and record it’,
28 => ‘Stop at the next bar, go to the bathroom and record something from the stall walls’,
29 => ‘Stop at the next bar, ask the bartender to tell you a genuine story about their favourite customer ever’,
30 => ‘Try to draw the Caesars sign from where you are’,
31 => ‘Stop at the next Convenience store and contribute to the local economy’,
32 => ‘Find the nearest surveillance camera and act out a favourite movie scene, have someone record a script as you play it’,
33 => ‘Ask someone for directions to the heart of the city’,
34 => ‘Buy a coffee and give to the first taxi driver that will take it’,
35 => ‘Get a hug from someone who is not drunk ‘,
36 => ‘Walk away from Caesars for 2 blocks in any direction’,
37 => ‘Walk north until you see a Ford car or truck’,
38 => ‘Walk east until you feel safe’,
39 => ‘If you see the feather hat man, ask him for a dollar or a smoke’,
40 => ‘Walk to the riverfront’,
41 => ‘Go to Charles Clark Square and have two people run a race’,
42 => ‘Write your own algorithm and leave it at Charles Clark Square, spend 3 minutes looking for another group\’s algorithm’,
43 => ‘Go into the next convenience store you see’,
44 => ‘Write down the time’,
45 => ‘Walk 3 blocks west’,
46 => ‘Walk for 1 block on the north side of the street’,
47 => ‘Make a note of the next street sign you see’,
48 => ‘Try to make your phone number by taking photos of individual numbers’,
49 => ‘Take a postcard photo’,
50 => ‘Walk on the south side of the next north-south street you come to for 2 minutes’,
51 => ‘Turn left when you see a bench’,
52 => ‘Call the parents of one of the people in the group and tell them what you\’re doing’,
53 => ‘Take a picture of the bridge from wherever you are right now’,
54 => ‘Draw a map of your ideal movements between downtown places you frequent (erase barriers)’,
55 => ‘Find a house you would actually move into if you had the chance, and draw a picture of it’,
56 => ‘If your group knows where a drug dealer lives around where you are, make a drawing of their place’,
57 => ‘Write on a legible service, \’To change this city, please call (519) 255-6315\”,
58 => ‘Identify the type of the tree nearest to you’,
59 => ‘Count and make note of all the vacant storefronts and rented storefronts you can’,

);

$al = count($steps); // count the number of values in the steps array

echo "<font size=\"2px\"><u>SCAVENGE THE CTIY (March 29, 2009) </u> –
Your Custom Algorithm!!! (document everything) <u>http://www.brokencitylab.org</u>

"; // spit this out at the top of each page

$range_min=0; // we can’t have less than zero
$range_max=$al-1; // because arrays start at zero, we need to get the total number then subtract one
$n=$al; //number of random numbers required

if($n>($range_max-$range_min+1))
$n=$range_max-$range_min+1;

$arr = array();
while ( count($arr) < $n )
{
$x = mt_rand($range_min,$range_max);
if ( !in_array($x,$arr) )
{$arr[] = $x; echo "<font size=\"2px\">__ $steps[$x] and then
";} // spits out each step
}

echo "__ You’re Done, head back to Phog, 157 University Avenue West, 519-253-1605!!!</font>"; // spits this out at the bottom of each page
?>
[/php]