
public class MorePoetics { 
	
	public static int ImAGlobalVariable = -1;
	
	public static String scriberize (int which, String [] a, String [] b, String [] c, String [] d) {
		// if 'which' = 0, 1, 2, or 3, then we had just used the words a, b, c, or d respectively
		String temp = "";
		
		/*
		 *  Markov matrix for this 'poem' = 
		 * 
		 *            A      B      C     newline
		 * 
		 *      A     0     .4     .2      1
		 * 
		 *      B    .5      0     .3      0
		 * 
		 *      C    .3     .1      0      0
		 *      
		 *      nl   .2     .5     .5      0
		 * 
		 */
		
		double p1=0, p2=0, p3=0;
		if ( which == 0 ) 
			{ p1 = 0;   p2 = 0.5; p3 = 0.8; } // kosher for 'which' = 0
		if ( which == 1 ) 
			{ p1 = 0.4; p2 = 0.4; p3 = 0.6; } // kosher for 'which' = 1
		if ( which == 2 ) 
			{ p1 = 0.2; p2 = 0.5; p3 = 0.5; } // kosher for 'which' = 2
		if ( which == 3 ) 
			{ p1 = 1;   p2 = 1;   p3 = 1;   } // kosher for 'which' = 3

		double crazy = Math.random();
		int pick = 0;
			
		if ( crazy < p1 )
				{ pick = (int) (Math.random() * a.length); temp = a[pick]; ImAGlobalVariable = 0; }
		
		else if ( crazy >= p1 && crazy < p2 )
				{ pick = (int) (Math.random() * b.length); temp = b[pick]; ImAGlobalVariable = 1; }
		
		else if ( crazy >= p2 && crazy < p3 )
				{ pick = (int) (Math.random() * c.length); temp = c[pick]; ImAGlobalVariable = 2; }
		
		else 
				{ pick = (int) (Math.random() * d.length); temp = d[pick]; ImAGlobalVariable = 3; }
		
		return temp;
	}
	
	public static void main ( String [ ] args ) {
		
		// String [ ]  B, C, D; // these are now arrays of strings
		String elWord;
		
		String [] A = {"red", "yellow", "warm", "tepid", "weird", "surprising"};
		String [] B = {"rose", "fish", "dog", "ghost"};
		String [] C = {"jumped", "slept", "swam", "yawned"};
		String [] D = {"\n"} ;
		
		ImAGlobalVariable = 0;
		
		for ( int i=1; i<=200; i++) {
			
			elWord = scriberize(ImAGlobalVariable, A, B, C, D);
			
			System.out.print(" " + elWord);
		}
		
		
		
	}

}