Спасибо автору за тему, думал написать что-то подобное под диамант 3 в ряд, но нашел этот код. Большую часть взял за основу своего ядра, но процедуру OBRABOTKA_CELL так и не смог понять. Пришлось ее написать по своему. для упрощения были добавлены доп. массивы к массиву $map, $mapX и $mapY в которых просто находится положение ячейки в числах 0-9 по горизонтали и вертикали которые помогают ориентироваться на поле и не искать за его пределами. Также с их помощью в логе генерируется отчет о каждой комбинации в виде
2:27:08 4-кл 4-0 4-1 3-2 4-3
2:27:08 3-кл 0-4 2-4 3-4
2:27:08 3-кл 2-4 3-4 4-3
также были добавлены доп массивы-карты аналогичные Map из исходного кода с координатами каждой ячейки. По перебору вариантов и нахождения каждой комбинации из них сразу же копируются две пары координат откуда-куда переместить элемент. Набиваются они в 3 итоговых массива 5-кл, 4-кл, 3-кл. на основании которых потом делается отчет в логе типа:
2:27:08 найдено 5-кл комбинаций: 0
2:27:08 найдено 4-кл комбинаций: 1
2:27:08 найдено 3-кл комбинаций: 7
и также на основании 3х итоговых массивов уже можно гибко программировать стратегию автоигры либо по макс комбинациям либо по приоритетным элементам или по определенному порядку действий
если что ниже также картинка из моей игры для нагрядности
SUB(OBRABOTKA_CELL2)
// print("îáðàáîòêà")
if($mapX[$cell]<5) //ïÿòèêëåòî÷íàÿ ïî ãîðèçîíòàëè
if(($map[$cell+1]=1)&($map[$cell+3]=1)&($map[$cell+4]=1))
if($mapY[$cell]>0)
if($map[$cell+2-9]=1)
print("5-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1],"-",$mapY[$cell+1]," ",$mapX[$cell+2-9],"-",$mapY[$cell+2-9]," ",$mapX[$cell+3],"-",$mapY[$cell+3]," ",$mapX[$cell+4],"-",$mapY[$cell+4]," ")
arrpush($5kl,$mapcordX[$cell+2-9])
arrpush($5kl,$mapcordY[$cell+2-9])
arrpush($5kl,$mapcordX[$cell+2])
arrpush($5kl,$mapcordY[$cell+2])
end_if
end_if
if($mapY[$cell]<8)
if($map[$cell+2+9]=1)
// print($map[$cell+3])
print("5-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1],"-",$mapY[$cell+1]," ",$mapX[$cell+2+9],"-",$mapY[$cell+2+9]," ",$mapX[$cell+3],"-",$mapY[$cell+3]," ",$mapX[$cell+4],"-",$mapY[$cell+4]," ")
arrpush($5kl,$mapcordX[$cell+2+9])
arrpush($5kl,$mapcordY[$cell+2+9])
arrpush($5kl,$mapcordX[$cell+2])
arrpush($5kl,$mapcordY[$cell+2])
end_if
end_if
end_if
end_if
$klass=0
if($mapY[$cell]<5) //ïÿòèêëåòî÷íàÿ ïî âåðòèêàëè
if(($map[$cell+1*9]=1)&($map[$cell+3*9]=1)&($map[$cell+4*9]=1))
if($mapX[$cell]>0)
if($map[$cell+2*9-1]=1)
print("5-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1*9],"-",$mapY[$cell+1*9]," ",$mapX[$cell+2*9-1],"-",$mapY[$cell+2*9-1]," ",$mapX[$cell+3*9],"-",$mapY[$cell+3*9]," ",$mapX[$cell+4*9],"-",$mapY[$cell+4*9]," ")
arrpush($5kl,$mapcordX[$cell+2*9-1])
arrpush($5kl,$mapcordY[$cell+2*9-1])
arrpush($5kl,$mapcordX[$cell+2*9])
arrpush($5kl,$mapcordY[$cell+2*9])
end_if
end_if
if($mapX[$cell]<8)
if($map[$cell+2*9+1]=1)
// print($map[$cell+3*9])
print("5-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1*9],"-",$mapY[$cell+1*9]," ",$mapX[$cell+2*9+1],"-",$mapY[$cell+2*9+1]," ",$mapX[$cell+3*9],"-",$mapY[$cell+3*9]," ",$mapX[$cell+4*9],"-",$mapY[$cell+4*9]," ")
arrpush($5kl,$mapcordX[$cell+2*9+1])
arrpush($5kl,$mapcordY[$cell+2*9+1])
arrpush($5kl,$mapcordX[$cell+2*9])
arrpush($5kl,$mapcordY[$cell+2*9])
end_if
end_if
end_if
end_if
if($mapX[$cell]<6) //÷åòûðåõêëåòî÷íàÿ ïî ãîðèçîíòàëè
if(($map[$cell+1]=1)&($map[$cell+3]=1))
if($mapY[$cell]>0)
if($map[$cell+2-9]=1)
print("4-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1],"-",$mapY[$cell+1]," ",$mapX[$cell+2-9],"-",$mapY[$cell+2-9]," ",$mapX[$cell+3],"-",$mapY[$cell+3]," ")
arrpush($4kl,$mapcordX[$cell+2-9])
arrpush($4kl,$mapcordY[$cell+2-9])
arrpush($4kl,$mapcordX[$cell+2])
arrpush($4kl,$mapcordY[$cell+2])
end_if
end_if
if($mapY[$cell]<8)
if($map[$cell+2+9]=1)
print("4-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1],"-",$mapY[$cell+1]," ",$mapX[$cell+2+9],"-",$mapY[$cell+2+9]," ",$mapX[$cell+3],"-",$mapY[$cell+3]," ")
arrpush($4kl,$mapcordX[$cell+2+9])
arrpush($4kl,$mapcordY[$cell+2+9])
arrpush($4kl,$mapcordX[$cell+2])
arrpush($4kl,$mapcordY[$cell+2])
end_if
end_if
end_if
if(($map[$cell+2]=1)&($map[$cell+3]=1))
if($mapY[$cell]>0)
if($map[$cell+1-9]=1)
print("4-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1-9],"-",$mapY[$cell+1-9]," ",$mapX[$cell+2],"-",$mapY[$cell+2]," ",$mapX[$cell+3],"-",$mapY[$cell+3]," ")
arrpush($4kl,$mapcordX[$cell+1-9])
arrpush($4kl,$mapcordY[$cell+1-9])
arrpush($4kl,$mapcordX[$cell+1])
arrpush($4kl,$mapcordY[$cell+1])
end_if
end_if
if($mapY[$cell]<8)
if($map[$cell+1+9]=1)
print("4-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1+9],"-",$mapY[$cell+1+9]," ",$mapX[$cell+2],"-",$mapY[$cell+2]," ",$mapX[$cell+3],"-",$mapY[$cell+3]," ")
arrpush($4kl,$mapcordX[$cell+1+9])
arrpush($4kl,$mapcordY[$cell+1+9])
arrpush($4kl,$mapcordX[$cell+1])
arrpush($4kl,$mapcordY[$cell+1])
end_if
end_if
end_if
end_if
if($mapY[$cell]<6) //÷åòûðåõêëåòî÷íàÿ ïî âåðòèêàëè
if(($map[$cell+1*9]=1)&($map[$cell+3*9]=1))
if($mapX[$cell]>0)
if($map[$cell+2*9-1]=1)
print("4-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1*9],"-",$mapY[$cell+1*9]," ",$mapX[$cell+2*9-1],"-",$mapY[$cell+2*9-1]," ",$mapX[$cell+3*9],"-",$mapY[$cell+3*9]," ")
arrpush($4kl,$mapcordX[$cell+2*9-1])
arrpush($4kl,$mapcordY[$cell+2*9-1])
arrpush($4kl,$mapcordX[$cell+2*9])
arrpush($4kl,$mapcordY[$cell+2*9])
end_if
end_if
if($mapX[$cell]<8)
if($map[$cell+2*9+1]=1)
print("4-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1*9],"-",$mapY[$cell+1*9]," ",$mapX[$cell+2*9+1],"-",$mapY[$cell+2*9+1]," ",$mapX[$cell+3*9],"-",$mapY[$cell+3*9]," ")
arrpush($4kl,$mapcordX[$cell+2*9+1])
arrpush($4kl,$mapcordY[$cell+2*9+1])
arrpush($4kl,$mapcordX[$cell+2*9])
arrpush($4kl,$mapcordY[$cell+2*9])
end_if
end_if
end_if
if(($map[$cell+2*9]=1)&($map[$cell+3*9]=1))
if($mapX[$cell]>0)
if($map[$cell+1*9-1]=1)
print("4-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1*9-1],"-",$mapY[$cell+1*9-1]," ",$mapX[$cell+2*9],"-",$mapY[$cell+2*9]," ",$mapX[$cell+3*9],"-",$mapY[$cell+3*9]," ")
arrpush($4kl,$mapcordX[$cell+1*9-1])
arrpush($4kl,$mapcordY[$cell+1*9-1])
arrpush($4kl,$mapcordX[$cell+1*9])
arrpush($4kl,$mapcordY[$cell+1*9])
end_if
end_if
if($mapX[$cell]<8)
if($map[$cell+1*9+1]=1)
print("4-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1*9+1],"-",$mapY[$cell+1*9+1]," ",$mapX[$cell+2*9],"-",$mapY[$cell+2*9]," ",$mapX[$cell+3*9],"-",$mapY[$cell+3*9]," ")
arrpush($4kl,$mapcordX[$cell+1*9+1])
arrpush($4kl,$mapcordY[$cell+1*9+1])
arrpush($4kl,$mapcordX[$cell+1*9])
arrpush($4kl,$mapcordY[$cell+1*9])
end_if
end_if
end_if
end_if
if($mapX[$cell]<6) //òðåõêëåòî÷íàÿ ïî ãîðèçîíòàëè
if($map[$cell+1]=1)
if($map[$cell+3]=1)
print("3-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1],"-",$mapY[$cell+1]," ",$mapX[$cell+3],"-",$mapY[$cell+3]," ")
arrpush($3kl,$mapcordX[$cell+3])
arrpush($3kl,$mapcordY[$cell+3])
arrpush($3kl,$mapcordX[$cell+2])
arrpush($3kl,$mapcordY[$cell+2])
end_if
end_if
end_if
if($mapX[$cell]<7) //òðåõêëåòî÷íàÿ ïî ãîðèçîíòàëè
if($map[$cell+1]=1)
if($mapY[$cell]>0)
if($map[$cell+2-9]=1)
print("3-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1],"-",$mapY[$cell+1]," ",$mapX[$cell+2-9],"-",$mapY[$cell+2-9]," ")
arrpush($3kl,$mapcordX[$cell+2-9])
arrpush($3kl,$mapcordY[$cell+2-9])
arrpush($3kl,$mapcordX[$cell+2])
arrpush($3kl,$mapcordY[$cell+2])
end_if
end_if
if($mapY[$cell]<8)
if($map[$cell+2+9]=1)
print("3-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1],"-",$mapY[$cell+1]," ",$mapX[$cell+2+9],"-",$mapY[$cell+2+9]," ")
arrpush($3kl,$mapcordX[$cell+2+9])
arrpush($3kl,$mapcordY[$cell+2+9])
arrpush($3kl,$mapcordX[$cell+2])
arrpush($3kl,$mapcordY[$cell+2])
end_if
end_if
end_if
if($map[$cell+2]=1)
if($map[$cell+3]=1)
print("3-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+2],"-",$mapY[$cell+2]," ",$mapX[$cell+3],"-",$mapY[$cell+3]," ")
arrpush($3kl,$mapcordX[$cell])
arrpush($3kl,$mapcordY[$cell])
arrpush($3kl,$mapcordX[$cell+1])
arrpush($3kl,$mapcordY[$cell+1])
end_if
if($mapY[$cell]>0)
if($map[$cell+1-9]=1)
print("3-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1-9],"-",$mapY[$cell+1-9]," ",$mapX[$cell+2],"-",$mapY[$cell+2]," ")
arrpush($3kl,$mapcordX[$cell+1-9])
arrpush($3kl,$mapcordY[$cell+1-9])
arrpush($3kl,$mapcordX[$cell+1])
arrpush($3kl,$mapcordY[$cell+1])
end_if
end_if
if($mapY[$cell]<8)
if($map[$cell+1+9]=1)
print("3-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1+9],"-",$mapY[$cell+1+9]," ",$mapX[$cell+2],"-",$mapY[$cell+2]," ")
arrpush($3kl,$mapcordX[$cell+1+9])
arrpush($3kl,$mapcordY[$cell+1+9])
arrpush($3kl,$mapcordX[$cell+1])
arrpush($3kl,$mapcordY[$cell+1])
end_if
end_if
end_if
if($mapY[$cell]>0)
if(($map[$cell+1-9]=1)&($map[$cell+2-9]=1))
print("3-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1-9],"-",$mapY[$cell+1-9]," ",$mapX[$cell+2-9],"-",$mapY[$cell+2-9]," ")
arrpush($3kl,$mapcordX[$cell])
arrpush($3kl,$mapcordY[$cell])
arrpush($3kl,$mapcordX[$cell-9])
arrpush($3kl,$mapcordY[$cell-9])
end_if
end_if
if($mapY[$cell]<8)
if(($map[$cell+1+9]=1)&($map[$cell+2+9]=1))
print("3-êë ",$mapX[$cell],"-",$mapY[$cell]," ",$mapX[$cell+1+9],"-",$mapY[$cell+1+9]," ",$mapX[$cell+2+9],"-",$mapY[$cell+2+9]," ")
arrpush($3kl,$mapcordX[$cell])
arrpush($3kl,$mapcordY[$cell])
arrpush($3kl,$mapcordX[$cell+9])
arrpush($3kl,$mapcordY[$cell+9])
end_if
end_if
end_if
end_sub