$PP "; // generate ambiguity game //print_r($_POST); $V=@$_POST['V']; // level if ($V=='') $V=1; if (@$_GET['level']) $V=$_GET['level']; // overide $Z=@$_POST['z']; // size if ($Z=='') $Z=@$_GET['z']; // overides if ($Z=='') $Z=200; $screenW=@$_POST['SW']; $screenH=@$_POST['SH']; $F=@$_POST['f']; // font if ($F=='') $F='TEMPSITC'; $FZ=@$_POST['fz']; // font size if ($FZ=='') $FZ=99; // H,W $dlevels=array( array(0,0,0), array(2,2,1), //array(2,2,0), array(2,3,1), array(2,4,1), array(3,3,1), array(2,5,1), array(3,5,1), array(4,4,1), array(3,6,1), array(4,5,1), array(4,6,1), array(5,5,1), array(5,6,1), array(4,8,2), array(4,9,2), array(4,10,2), array(5,10,3), array(6,10,3), array(7,10,3), array(8,10,3), array(9,10,3), array(10,10,4), array(10,12,5) ); $mlevels=array( array(0,0,0), array(2,2,1), //array(2,2,0), array(3,2,1), array(4,2,1), array(3,3,1), array(5,2,1), array(5,3,1), array(5,3,1), array(6,3,1), array(5,4,1), array(6,4,1), array(5,5,1), array(6,5,1), array(8,4,2), array(9,4,2), array(10,4,2), array(10,5,3), array(10,6,3), array(10,7,3), array(10,8,3), array(10,9,3), array(10,10,4), array(12,10,4) ); if ($screenH=='') { // assume mobile to start $screenH=480; $screenW=320; } if ($screenH>$screenW) $levels=$mlevels; else $levels=$dlevels; //$levels=$mlevels; if (@$_POST['next']=='Play Next Level') { $V++; // for next button push if ($V>count($levels)) $V=count($levels)-1; } $H=$levels[$V][0]; $W=$levels[$V][1]; $LOCKED=$levels[$V][2]; if ($H>$W) { $Z=round(($screenH-100)/$H); if ($Z*$W>$screenW-100) $Z=round(($screenW-100)/$W); } else { //$Z=round(($screenW-10)/$W); $Z=round(($screenW-100)/$W); if ($Z*$W>$screenH-100) $Z=round(($screenH-100)/$H); } if ($Z>300) $Z=300; if ($Z>200) $Z=200; //print_r($_POST); //print_r($levels); //echo "$V $H $W"; $N=$W*$H; $hw=$Z; $words=array(); $roots=array(); //$r = file_get_contents("classic wip 124.txt"); $r = file_get_contents("printandplay/$PP.txt"); $lines=explode("\n",$r); $i=0; foreach ($lines as $line) { $a=explode('=',$line); $b=explode(',',$a[1]); $words[$a[0]]=$b; // array(strtoupper($a[0]),strtoupper($a[1])); $roots[$i]=$a[0]; $i++; } $pairs=array(); //echo count($words); print_r($words); exit; //echo $roots[7];exit; $p2=$roots[rand(0,count($words)-1)]; // seed word for ($i=0; $i<$N*4; $i++) { // generate a matching pair $p1=''; while ($p1=='') { $r=rand(0,count($roots)-1); $p1=$roots[$r]; } $p2=$words[$p1][rand(0,count($words[$p1])-1)]; $roots[$r]=''; $pairs[]=array($p1,$p2); } //print_r($roots); //print_r($pairs); exit; $quads=array(); $q=0; for ($h=0; $h<$H; $h++) for ($w=0; $w<$W; $w++) { $quads[$q]=array('','','',''); $q++; } /* quad 2x2 +---0---+ +---0---+ | | | | 3 #0 1 3 #1 1 | | | | +---2---+ +---2---+ +---0---+ +---0---+ | | | | 3 #2 1 3 #3 1 | | | | +---2---+ +---2---+ */ $q=0; for ($y=0; $y<$H; $y++) for ($x=0; $x<$W; $x++) { if ($y==0 || $y==$H-1 || $x==0 || $x==$W-1) { $pair=array_pop($pairs); // populate top in top row if ($y==0) $quads[$q][0]=$pair[0]; // populate bottom in bottom row if ($y==$H-1) $quads[$q][2]=$pair[1]; $pair=array_pop($pairs); // populate left if left side if ($x==0) $quads[$q][3]=$pair[0]; // populate right if right side if ($x==$W-1) $quads[$q][1]=$pair[1]; } $pair=array_pop($pairs); if ($quads[$q][1]=='') { $quads[$q][1]=$pair[0]; $quads[$q+1][3]=$pair[1]; } $pair=array_pop($pairs); if ($quads[$q][2]=='') { $quads[$q][2]=$pair[0]; $quads[$q+$W][0]=$pair[1]; } $q++; } //if ($_POST['trace']) print_r($quads); echo "
"; // set locked location(s) $q=array(); $R=array(); $RR=array(); for ($r=0; $r<$N; $r++) { $RR[]=0; $R[]=-1; } for ($r=0; $r<$N; $r++) $q[$r]=$r; // quads shuffle($q); //echo "

Q "; print_r($q); for ($r=0; $r<$LOCKED; $r++) { $locked=array_pop($q); //echo "

Locked = $locked"; $R[$locked]=$locked; $RR[$locked]=0; } $n=count($q); for ($r=0; $r<$n; $r++) { //echo " r=$r nq=".count($q).' '; $unlocked=array_pop($q); for ($j=0; $j<$N; $j++) { if ($R[$j]==-1) { $R[$j]=$unlocked; //echo "
unlocked = $unlocked"; $RR[$j]=rand(1,2); break; } } } //echo "

Q "; print_r($q); //echo "

R "; print_r($R); //echo "

RR "; print_r($RR); // $R indicates which quad to use at current location // $RR indicates # rotations // a locked quad is in correct location and not rotated $i=0; for ($y=0; $y<$H; $y++) { echo "

"; for ($x=0; $x<$W; $x++) { $I=$R[$i]; $c1=strtoupper($quads[$i][0]); $c2=strtoupper($quads[$i][1]); $c3=strtoupper($quads[$i][2]); $c4=strtoupper($quads[$i][3]); $r1=strtoupper($quads[$I][0]); $r2=strtoupper($quads[$I][1]); $r3=strtoupper($quads[$I][2]); $r4=strtoupper($quads[$I][3]); $r=0; if ($RR[$i]==1) // rotate once ? { $r1=strtoupper($quads[$I][1]); $r2=strtoupper($quads[$I][2]); $r3=strtoupper($quads[$I][3]); $r4=strtoupper($quads[$I][0]); $r=1; } if ($RR[$i]==2) // rotate twice ? { $r1=strtoupper($quads[$I][2]); $r2=strtoupper($quads[$I][3]); $r3=strtoupper($quads[$I][0]); $r4=strtoupper($quads[$I][1]); $r=2; } echo "
"; $locked='n'; if ($I==$i && $r==0) $locked='Y'; echo " "; echo "
"; $i++; } echo "
"; } echo "
"; echo "

"; echo "

NO SCORE
"; if ($screenW=='') { echo "

 
"; } else { echo "

 
"; } echo "

Change Theme to: [GO]"; ?>

YOU ARE ON LEVEL

How To Play
h=$screenH w=$screenW $Z hw=$hw w=$W h=$H v=$V $LOCKED echo "
"; echo "
 

To get on the leaderboard and qualify for monthly prizes,
please enter your email address:

No Spam Policy in Effect
Register with your first name or initials:
Prizes from
"; ?>