Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
dimon

Grouping array positions by the method of k-means clustering

Recommended Posts

Creating an array of positions spiral manner fnc_spiral faced with the problem of how to group on the course.

Writing a script for their needs how would you solve your problem:

ffa_fnc_arrays_dist

d481bb2f3434a416d97594634d3786be.jpeg

Thanks ArseniyK, I did a function that splits the array into subarrays by the method of k-means clustering

197px-K_Means_Example_Step_2.svg.png 197px-K_Means_Example_Step_1.svg.png

I led them to a practical mind (i.e. they do work in MP mission) and a bit of optimizing standard techniques.

1. option

ffa_fnc_kmean_clustering

arrays= [12,arrays] call ffa_fnc_kmean_clustering;

weed out the empty submassive get

ffa_fnc_otsev= {
_cnt = _this select 1;
_array = [];
{
   if (typeName _x == "ARRAY" && {(count _x) > _cnt}) then
   {
       _array set [count _array,_x];
   };
} foreach (_this select 0);
};
arrays= [arrays,0] call ffa_fnc_otsev;

2a72026d5aa6a31b331853959bdeb26e.jpeg

2. option (more is better)

ffa_fnc_kmean_clustering2

4975b4588e268fbf8910a8b545a38cef.jpeg

Credits:

-ArseniyK

Edited by Dimon

Share this post


Link to post
Share on other sites
Sign in to follow this  

×