예제 #1
0
 private function getPossibleCombinations(BoggleGrid $grid)
 {
     $results = new ArrayList("ArrayList");
     $results->add(new ArrayList("integer"));
     foreach ($this->word as $char) {
         $newResults = new ArrayList("ArrayList");
         foreach ($grid->getIndices($char) as $index) {
             foreach ($results as $result) {
                 if ($result->contains($index) || !$result->isEmpty() && !$grid->isIndicesAdjacent($result->getLast(), $index)) {
                     continue;
                 }
                 /*
                 $newResult = new ArrayList("integer");
                 $newResult->addAll($result);
                 $newResult->add($index);
                 */
                 $newResult = clone $result;
                 $newResult->add($index);
                 $newResults->add($newResult);
             }
         }
         $results = clone $newResults;
         //$results = new ArrayList("ArrayList");
         //$results->addAll($newResults);
     }
     return $results;
 }
예제 #2
0
 public function create($name, $lang, BoggleGrid $grid, $points)
 {
     $hscore = $this->createBoggleHighScore();
     $hscore->setName($name);
     $hscore->setLang($lang);
     $hscore->setGrid($grid->getChars());
     $hscore->setPlayDate(Date::createNow());
     $hscore->setPoints($points);
     return $this->updateBoggleHighScore($hscore);
 }
예제 #3
0
 public function start()
 {
     $this->millis = self::TIMER;
     $this->grid = BoggleGrid::create($this->lang);
     $this->dictionary = Dictionary::create($this->lang, "4x4");
     $this->words = new ArrayList("BoggleWord");
     return "games/boggle/boggle";
 }
예제 #4
0
 public function getPossibleWords(BoggleGrid $grid)
 {
     $result = array();
     foreach ($this->words as $word) {
         $w = new BoggleWord($word);
         $possible = true;
         foreach ($w->getWord() as $char) {
             if (!$grid->getLayout()->contains($char)) {
                 $possible = false;
                 break;
             }
         }
         if (!$possible) {
             continue;
         }
         if ($w->isPossibleInLayout($grid)) {
             $result[] = $w->getWord();
         }
     }
     return $result;
 }