[Yasal Uyarı: PHP için yeni ve ben sadece bir çözüm ya da bilgi bulmak için çalışıyor, bu yüzden gerçekten öğrenme sürecini engelleyen hiçbir flamers lütfen, öğreniyorum, teşekkür ederim, ve kod bulmaca açısından çalışıyor , sadece gerçekten görmeye yanlış ve ne yapıyorum biri verilen bilgilerle çapraz bir yönelim alır beni nasıl baffling ya değil mi?]
Bir anahtar Verilen:
switch ($dir){
case "E":
//col from 0 to board width - word width
//row from 0 to board height
$newCol = rand(0, $boardData["width"] - 1 - strlen($theWord));
$newRow = rand(0, $boardData["height"]-1);
for ($i = 0; $i < strlen($theWord); $i++){
//new character same row, initial column + $i
$boardLetter = $board[$newRow][$newCol + $i];
$wordLetter = substr($theWord, $i, 1);
//check for legal values in current space on board
if (($boardLetter == $wordLetter) ||
($boardLetter == ".")){
$board[$newRow][$newCol + $i] = $wordLetter;
} else {
$itWorked = FALSE;
} // end if
} // end for loop
break;
VE:
case "N":
//col from 0 to board width
//row from word length to board height
$newCol = rand(0, $boardData["width"] -1);
$newRow = rand(strlen($theWord), $boardData["height"]-1);
for ($i = 0; $i < strlen($theWord); $i++){
//check for a legal move
$boardLetter = $board[$newRow - $i][$newCol];
$wordLetter = substr($theWord, $i, 1);
if (($boardLetter == $wordLetter) ||
($boardLetter == ".")){
$board[$newRow - $i][$newCol] = $wordLetter;
} else {
$itWorked = FALSE;
} // end if
} // end for loop
break;
Ben NE almak için (veya diyagonal metin ekrana Çıktılanan olan) iki birleştirmek mümkün olmalıdır
HOWEVER, when I try this, it's not working, and I have been trying different combinations of N and E to get NE or a diagonal NE orientation with no luck, what gives?
#Tried multiple different combination's of N & E, I am out of ideas
switch ($dir){
case "E":
$newCol = rand(0, $boardData["width"] - 1 - strlen($theWord));
$newRow = rand(strlen($theWord), $boardData["height"]-1);
for ($i = 0; $i < strlen($theWord); $i++){
#Combined but no luck, WTF:
$boardLetter = $board[$newRow][$newRow - $i];
$boardLetter = $board[$newCol][$newCol + $i];
$wordLetter = substr($theWord, $i, 1);
//check for legal values in current space on board
if (($boardLetter == $wordLetter) ||
($boardLetter == ".")){
$board[$newRow][$newRow - $i] = $wordLetter;
$board[$newCol][$newCol + $i] = $wordLetter;
} else {
$itWorked = FALSE;
} // end if
} // end for loop
break;