Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How will I use k-means alghorithm in my game?

Discussion in '2D' started by eozdeveci, Oct 22, 2015.

  1. eozdeveci

    eozdeveci

    Joined:
    May 15, 2015
    Posts:
    8
    I need help. I am creating a game like candy crush and i have to use k-means alghorithm in my game. But i have no idea how will i choose centers of clusters.How should i start and how should i proceed?
     
  2. bestellenpreis

    bestellenpreis

    Joined:
    Mar 15, 2015
    Posts:
    26
    K-means and other clustering algorithms shine when you have multivariate data. They will "work" with 1-dimensional data, but they are not very smart anymore.

    One-dimensional data is ordered. If you sort your data (or it even is already sorted), it can be processed much more efficiently than with k-means. Complexity of k-means is "just" O(n*k*i), but if your data is sorted and 1-dimensional you can actually improve k-means to O(k*i). Sorting comes at a cost, but there are very good sort implementations everywhere...

    Plus, for 1-dimensional data there is a lot of statistics you can use that are not very well researched or tractable on higher dimensions. One statistic you really should try is kernel density estimation. Maybe also try Jenks Natural Breaks Optimization.

    However, if you want to just split your data into poor/medium/high, why don't you just use two thresholds?
     
    eozdeveci likes this.
  3. eozdeveci

    eozdeveci

    Joined:
    May 15, 2015
    Posts:
    8
    Thank you very much for informations ! Yes i just want split my data but unfortuanetly i have to use k-means for my school project. I think they want teach us K-means alghorithm. Thank you again.