这是一个界面应用化后的抽卡,目前只能抽金,只有基础概率加保底概率
适合界面化应用初学者。
这是展示图:
使用的是WPF不是winform,我也是第一次做WPF内容,就可以试一试,代码都在这里了,简单来说,复制过去就能用。XAML就是界面设计的描述性语言,和界面一样的。
看到左下角那个XAML了吗,点进去复制粘贴就行了
代码:
using System;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace 抽卡只有金_带保底
{/// <summary>/// Interaction logic for MainWindow.xaml/// </summary>public partial class MainWindow : Window{public static List<double> randomNumbers = new List<double>();public MainWindow(){InitializeComponent();Random random = new Random(); // 不使用种子值int Length = 60000;randomNumbers.Clear();for (int j = 0; j < Length; j++){//minValue 是包含的下界(即可以生成该值),而 maxValue 是不包含的上界(即不会生成该值)。randomNumbers.Add(random.NextDouble()); // 生成0到999之间的随机数}}//保底记录static int minimumGuarantee = 0;//保底概率static double guaranteeProbability = 0;static int i = 0;//抽中总数static int num2 = 0;//抽取总数static int num = 0;static double realp = 0;static double p = 0.6 * 0.01;private void Button_Click(object sender, RoutedEventArgs e){for (int n = 0; n < 10; n++, i++){minimumGuarantee = minimumGuarantee + 1;if (randomNumbers[i] <= p + guaranteeProbability){//Console.WriteLine("***抽中了***");num2 = num2 + 1;minimumGuarantee = 0;guaranteeProbability = 0;}else{//Console.WriteLine("没抽中");}//第59抽结尾增加概率并一次性减去p,第60抽开始使用高概率,结果实际计算时发现去掉这个p才是实际的1.605%if (minimumGuarantee == 73){guaranteeProbability = 0;}if (minimumGuarantee >= 73){guaranteeProbability = guaranteeProbability + (double)1 / 17;}}//更新十次抽取总数num = num + 10;realp = (double)num2 / num * 100;Console.WriteLine("已经抽了{0},抽中{1},概率{2:0.000}%", num, num2, realp);Label1.Content = ($"已经抽了{num},抽中{num2},概率{realp:0.000}%");}}
}
XAML:
<Window x:Class="抽卡只有金_带保底.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:抽卡只有金_带保底"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid><Button Content="一次十连" HorizontalAlignment="Left" Margin="205,163,0,0" VerticalAlignment="Top" Click="Button_Click" Height="45" Width="120" FontSize="24"/><Label x:Name="Label1" Content="结合保底综合命中率1.6%" HorizontalAlignment="Left" Margin="360,165,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" FontSize="22"><Label.RenderTransform><TransformGroup><ScaleTransform/><SkewTransform/><RotateTransform Angle="-0.356"/><TranslateTransform/></TransformGroup></Label.RenderTransform></Label></Grid>
</Window>