-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.php
64 lines (53 loc) · 1.21 KB
/
generate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Generates a puzzle of given length, and possibly starting
* at a given word (optional).
*/
include 'util.php';
// Get the words database.
$words = load();
$length = $argv[1];
// Get the start, either from the argument or randomly from
// word list.
$keys = array_keys($words);
if (count($argv) == 3) {
if (in_array($argv[2], $keys)) {
$start = $argv[2];
}
else {
echo "No such word, silly goose!\n";
}
}
else {
//echo "Random: " . count($words) . "\n";
echo "No starting word specified, using random word instead: ";
$start = $keys[rand(0, count($words))];
echo $start . "\n";
}
$chain = [$start];
print_r($chain);
$index = 0;
if (isset($start)) {
while ($length > 0) {
// Get the next set of words.
$next_parent = $words[$chain[$index]];
// Shuffle the array so that it's "random" at this scope.
shuffle($next_parent);
print_r($next_parent);
// Run through it.
foreach($next_parent as $child) {
}
$length -= 1;
$index += 1;
}
}
else {
echo "Couldn't $start for some reason. Dying...\n";
}
/**
* @param string $word
* thingy
*/
function test_word($word) {
}
?>