-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pentagoo_ai.php
60 lines (56 loc) · 1.39 KB
/
pentagoo_ai.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
<?
$matrix = $_GET['m'];
$player = $_GET['p'];
$level = $_GET['l'];
// str_split function for PHP < 5
if (!function_exists("str_split"))
{
function str_split($string, $length = 1)
{
if ($length <= 0)
{
trigger_error(__FUNCTION__."(): The the length of each segment must be greater then zero:", E_USER_WARNING);
return false;
}
$splitted = array();
$str_length = strlen($string);
$i = 0;
if ($length == 1)
{
while ($str_length--)
$splitted[$i] = $string[$i++];
}
else
{
$j = $i;
while ($str_length > 0)
{
$splitted[$j++] = substr($string, $i, $length);
$str_length -= $length;
$i += $length;
}
}
return $splitted;
}
}
// Convert matrix string to array
$matrix_arr = str_split($matrix);
$matrix_arr1 = $matrix_arr;
for($c = 0; $c < 6; ++$c)
for($r = 0; $r < 6 ; ++$r)
$matrix_arr2[$c][$r] = array_shift($matrix_arr);
$dir_path = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR;
/*
switch($level)
{
case '0':
include_once($dir_path.'ai/ai_0.php'); // AI - Minimax
break;
case '1':
include_once($dir_path.'ai/ai_1.php'); // AI - Minimax
break;
}
*/
include_once($dir_path.'ai/ai_1.php'); // AI by Mickael ROUVIER
echo $x.$y.$t.$d;
?>