/*
This is a random sentence generator. It attempts to create sentences in the style 
of Karen Elizabeth Gordon, l337 grammatician and author of "The New Well-
Tempered Sentence," "Paris Out of Hand," and the classic "Deluxe Transitive Vampire: 
The Ultimate Handbook of Grammar for the Innocent, the Eager, and the Doomed"
http://www.amazon.com/exec/obidos/search-handle-url/index=books&field-author=Gordon%2C%20Karen%20Elizabeth/107-3598112-6222913

To execute this script, somewhere between <head> and </head>...
	<script language="JavaScript" src="http://www.automatictaxistop.com/deluxe.js"></script>

And anyplace you want random sentences to show up...
	<script language="javascript">DeluxeTransitiveGenerator(x);</script>
Replace x with number of sentences you'd like.

This is a moderately-heavily modified version of somebody else's script. Unfortunately, 
the name wasn't listed, so I can't credit the poor bastard... 
http://javascript.internet.com/messages/sentence.html

-Cowboy X 6/29/2001 eric@automatictaxistop.com
*/

/* James hauls in the code, changes english to suit paintball battle, want to make things past tense, more action, shorter sentences */

RandMultiplier = 0x23232323
RandIncrement = 1
var now = new Date()
RandSeed = now.getTime() % 0xffffffff
FirstSentence = 1 // marks that first sentence has not been made yet; state altered on line 105
FirstAmerica = 1 // marks that the goofy "...america great" sentence has not been used yet; line 69
	
function qrand(n) 
	{
	RandSeed = (RandMultiplier * RandSeed + RandIncrement) % 0x7fffffff
	return (RandSeed >> 16) % n
	}
	
function DeluxeTransitiveGenerator(sentenceCount) 
	{
	for (x=1; x<=sentenceCount; x++)
		{
		var stemp = GenRandomSentenceTemplate()
		var s = ""
		for ( i=0; i<stemp.length; i++ ) 
			{
			var c = stemp.substring(i,i+1)
			var w = ""
			if      ( c == '0' )    w = GenNoun()
			else if ( c == '1' )    w = GenNounPhrase(0)
			else if ( c == '2' )    w = GenTransitiveVerbPhrase(2)
			else if ( c == '3' )    w = GenConjunction()
			else if ( c == '4' )    w = GenIntransitiveVerbPhrase()
			else if ( c == '5' )    w = GenTransitiveVerbPhrase(2)
			else if ( c == '6' )    w = GenAdjective()
			else if ( c == '7' )    w = GenAdverb()
			else if ( c == '8' )    w = GenProperName()
			else    w = c
			s += w
			}
		document.write(CapFirst(s) + " ");
		}
	}

function GenRandomSentenceTemplate() 
	{
	var w = ""
	var r = qrand(50)
	if ( r > 45)    w = "1 2 1." // NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r >40 )    w = "8 2 1." // NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r >35 )    w = "1 2 8." // NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r >30 )    w = "8 2 8." // NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r >26 )    w = "1 4." // NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r >22 )    w = "0 2 8." // NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r >17 )    w = "8 2 0." // NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r == 1 )      w = "1 2 1, 3 1 2 1." // NounPhrase TransitiveVerbPhrase NounPhrase, Conjuction NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r == 2 )      w = "When 1 4, 1 4." // When NounPhrase IntransitiveVerbPhrase, NounPhrase IntransitiveVerbPhrase.
	//else if ( r == 3 )      w = "When 1 2 1, then 1 4." // If NounPhrase TransitiveVerbPhrase NounPhrase, then NounPhrase IntransitiveVerbPhrase.
	//else if ( r == 3 )      w = "Then 1 4." // If Then NounPhrase IntransitiveVerbPhrase.
	else if ( r == 3 )      w = "1 4!" // Sometimes NounPhrase IntransitiveVerbPhrase, but NounPhrase always TransitiveVerbPhrase NounPhrase.
	else if ( r == 4 )      w = "1 always 2 1!" // NounPhrase always TransitiveVerbPhrase NounPhrase.
	else if ( r == 5 )      w = "1 7 1 4." // NounPhrase Adverb NounPhrase IntransitiveVerbPhrase
	else if ( r == 6 ) 
		{
		if ( FirstAmerica ) 
			{
			FirstAmerica = 0
			w = "1, 1, and 1 are what got 8 into trouble." 
			} 
		else 
			{w = "1 2 1."} // NounPhrase TransitiveVerbPhrase NounPhrase.
		}
	else if ( r == 7 )      w = "1 4, 3 1 2 1." // NounPhrase IntransitiveVerbPhrase, Conjuction NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r == 8 )      w = "1 2 1." // Now and then, NounPhrase TransitiveVerbPhrase NounPhrase.
	else if ( r == 9 )      w = "1 4, and 1 4." // Noun IntransitiveVerbPhrase, and Noun IntransitiveVerbPhrase; however, NounPhrase TransitiveVerbPhrase NounPhrase..
	else if ( r == 10 ) 
		{
		if ( FirstSentence ) 
			{w = "1 2 1."}  // NounPhrase TransitiveVerbPhrase NounPhrase.
		else 
			{w = "Indeed, 1 2 1."} // Indeed, NounPhrase TransitiveVerbPhrase NounPhrase.
		}
	else if ( r == 11 ) 
		{
		if ( FirstSentence ) 
			{w = "0 2 1."} // NounPhrase TransitiveVerbPhrase NounPhrase.
		else 
			{w = "8, was soothed by 1 and 1."} // 
		}
	else if ( r == 12 ) 
		{
		if ( FirstSentence ) 
			{w = "1 2 1."}  // NounPhrase TransitiveVerbPhrase NounPhrase.
		else 
			{w = "He 2 8 (or was it 8?)."} // For example, NounPhrase indicates that NounPhrase TransitiveVerbPhrase NounPhrase.
		}
	else if ( r == 13 )     w = "0s remained 6." // 
	else if ( r == 14 )     w = "8 and I took 1 (with 1, 1, a few 0s, and 1)." // 
	else if ( r == 15 )     w = "1 was 6." 
	else if ( r == 16 )     w = "8 2 1." 
	FirstSentence = 0
	return (w);
	}



function GenNoun() 
	{
	w = new Array(
	"girl","boy","soldier","casualty",
	"coward","ruffian","onlooker","referee",

	"fence","tree","barrel", "flag", "paint-gun",
        "gun", "helmet",

	"mud", "leaves", "stick", "stone", "bank", "hut", "bridge", "fallen tree", 
	"log", "bench", "net", "face-mask", "combats", "boot",
	"burger and chips",

	"hand","leg","arm","thigh","neck","head","finger","ankle","foot",
	"guardian angel","lunatic","curse");
	return w[qrand(w.length)]
	}
	
function GenPreposition() 
	{	
	w = new Array(
	"from","near","about","around","for","toward","over","behind","beyond","inside",
	"north of", "south of", "east of", "west of", 
        "over", "under", "around", "left of", "right of",
   	"forwards of", "backwards of", "sideways by", "across",
   	"away from", "behind", "on top of"   
	);
	return w[qrand(w.length)]
	}

function GenNounPhrase(depth) 
	{
	var phraseKind = qrand(3)
	var s = ""
	if ( phraseKind == 0 || depth>0 ) 
		{s = GenNoun()} 
	else if ( phraseKind == 1 ) 
		{s = GenAdjective() + " " + GenNoun()} 
	else if ( phraseKind == 2 ) 
		{s = GenNoun() + " " + GenPreposition() + " " + GenNounPhrase(depth+1)}
	var r = qrand(100)
	if ( r < 30 ) 
		{s = "the " + s} 
	else if ( r < 35 ) 
		{s = "another " + s} 
	else if ( r < 40 ) 
		{s = "some " + s} 
	else 
		{
		var c = s.substring(0,1).toLowerCase()
		if ( (s.substring(0,8) != "Eurasian") && (c=='a' || c=='e' || c=='i' || c=='o' || c=='u') ) 
			{s = "an " + s} 
		else 
			{s = "a " + s}
		}
	return s
	}

function GenProperName() 
	{
	s = new Array(
	"John","JC","Bill","Harry","Ridgeway",
   	"Jer","Donal","Berny","Fiona","Eoin","referee",
        "Derek","James","Hoagy","another guy","one of the other guys");
	return s[qrand(s.length)]
	}
	
function GenAdverb() 
	{
	s = new Array("weirdly","strangely",
	"greedily","hesitantly","secretly","carelessly","thoroughly","barely","ridiculously",
	"non-chalantly","hardly","eagerly","feverishly","lazily","accurately","accidentally","completely",
	"single-handledly","underhandedly","almost","overwhelmingly","quickly","crazily","messily","muddily",
	"mercilessly","hungrily");
	return s[qrand(s.length)]
	}
	
function GenAdjective() 
	{
	w = new Array("paint-splattered","halfhearted","botched","unruffled",
	"wobbly","terrified","hungry","dirty","muddy","wet","coloured","orange","blue","red","green","yellow",
	//shorty:
	"sprightly","slovenly","friendly","gingerly","unseemly","saintly","ungodly","lovely","unsightly","surly","womanly","ghastly","wily")
	if ( qrand(10) > 7 ) 
		{
		return (GenAdverb() + " " + w[qrand(w.length)]);
		}
	else
		{
		return w[qrand(w.length)]
		}
	}
	

// James wants past tense which not easy to convert to present or future
// so "shout$" becomes shout shouts shouted   shoot shoots shot doesn't work 
function GenTransitiveVerbPhrase(tense) 
	{
	sArray = new Array("splashed the","ran over a body with","squelched the","scrambled to","clambered over","climbed","crouched behind",
	"crept behind","walked on","rushed behind","scampered behind","screamed at","yelled about","fell behind","jumped over","leapt behind",
	"shout* at","shot at","conquer$","rubbed the","bounce$ the","mourn*","taught","preferred","pour* freezing cold water on","scraped paint off","scraped mud off","looked for","ignored","dance$ around","recognize$","approach*","negotiate$ a truce with","assimilate$","bestow$ great honor upon","derive$ satisfaction from","stole paintballs from","tr& to paint","went behind a tree with","found a problem with","laugh* with","befriend*","made a truce with","gave a hand to","pound*","trade$ shots with","sold " + GenNounPhrase(0) + " to","^ a change of heart about","played with","share$ a " + GenNounPhrase(0) + " with","bought more balls for","roast*","took a peek at","piss* on","wrote a love letter in paint to","fell in love with","avoid* getting painted on the",") a big fan of","crawled","crept","borrow* from","charge$ with","threw " + GenNounPhrase(0) + " at","bur&","was nasty to","learnt a hard lesson from","planned an escape from " + GenNounPhrase(0),"made love to");
	vt = "" 
	var i
	s = sArray[qrand(sArray.length)];
	for (i=0; i<s.length; i++ ) 
		{
		var c = s.substring(i,i+1)      
		var w = c
		if ( c == '$' ) 
			{
			if ( tense == 0 )       w = ""
			else if ( tense == 1 )  w = "s"
			else if ( tense == 2 )  w = "d"
			} 
		else if ( c == '*' ) 
			{
			if ( tense == 0 )       w = ""
			else if ( tense == 1 )  w = "es"
			else if ( tense == 2 )  w = "ed"
			}
		else if ( c == ')' ) 
			{
			if ( tense == 0 )       w = "be"
			else if ( tense == 1 )  w = "is"
			else if ( tense == 2 )  w = "was"
			}
		else if ( c == '^' ) 
			{
			if ( tense == 0 )       w = "have"
			else if ( tense == 1 )  w = "has"
			else if ( tense == 2 )  w = "had"
			}
		else if ( c == '&' ) 
			{
			if ( tense == 0 )       w = "y"
			else if ( tense == 1 )  w = "ies"
			else if ( tense == 2 )  w = "ied"
			}
		vt += w
		}
	if ( qrand(10) < 3 ) 
		{
		vt = GenAdverb() + " " + vt
		}
	return vt
	}

function GenIntransitiveVerbPhrase() 
	{
	w = new Array("ran","walked","scampered","left","creamed","killed","slaughtered","peppered",
	"shot","hit","thumped","whacked","smashed","pelted",
	"splashed","ran","squelched","scrambled","clambered","climbed","crouched",
	"crept","walked","rushed","scampered","screamed","yelled","fell","jumped","leapt",
	"dived","rolled",
	"flew into a rage","hid", "returned to base",
	"panicked","grinned insanely","laughed out loud","got stinking drunk on adrenalin",
	"woke up","hesitated","trembled","ruminated","died","stroked")
	return w[qrand(w.length)]
	}

function GenConjunction() 
	{
	var r = qrand(4)
	var s = ""
	if ( r == 0 )   s = "and"
	else if ( r == 1 )      s = "or"
	else if ( r == 2 )      s = "but"
	else if ( r == 3 )      s = "because"
	return s
	}

function CapFirst(s) 
	{
	return s.substring(0,1).toUpperCase() + s.substring(1,s.length); 
	}


