【问题标题】:Roulette selection轮盘赌选择
【发布时间】:2018-07-04 18:53:29
【问题描述】:

我正在使用以下代码为 android 使用轮盘赌选择算法:

//int n=4;
//double [] weight = new double [n];
//weight[0]=9;
//weight[1]=8;
//weight[2]=10;
//weight[3]=1;
public void Roulette(double weight[],double max_weight){
    int index=0;
    while (true){
        index= (int)(weight.length*Math.random());
        if(Math.random()<weight[index]/max_weight) {break;}
    }
    Toast.makeText(getBaseContext(),"Chosen="+index,Toast.LENGTH_LONG).show();
}

是否可以使用 android studio 创建(图形和代码)如下图所示的内容?

【问题讨论】:

  • 您可以通过编程方式为可绘制对象充气并用不同的颜色绘制它,但您需要一个 xml 来定义要绘制的图形的不同部分
  • public static void main(String [] args) { 看起来不像 Android 代码。你确定吗?
  • is it possible to create 当然,这是可能的。为您创建它有什么问题?

标签: android roulette-wheel-selection


【解决方案1】:

您可以使用一些用于 android 的图表,例如: MPAndroidChart

【讨论】:

猜你喜欢
  • 2021-06-02
  • 2014-05-25
  • 1970-01-01
  • 2010-09-15
  • 2012-05-06
  • 1970-01-01
  • 2018-04-23
  • 2011-05-02
相关资源
最近更新 更多