更新 rating 算法;修复一些 BUG

This commit is contained in:
milimoe 2024-11-04 23:00:12 +08:00
parent cb09bca88d
commit 4affe4617a
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
8 changed files with 33 additions and 17 deletions

View File

@ -17,11 +17,12 @@ namespace Oshima.Core.Controllers
private readonly ILogger<UserDailyController> _logger = logger;
[HttpGet("test")]
public List<string> GetTest([FromQuery] bool? isweb = null, [FromQuery] bool? isteam = null)
public List<string> GetTest([FromQuery] bool? isweb = null, [FromQuery] bool? isteam = null, [FromQuery] bool? showall = null)
{
bool web = isweb ?? true;
bool team = isteam ?? false;
return FunGameSimulation.StartGame(false, web, team);
bool all = showall ?? false;
return FunGameSimulation.StartGame(false, web, team, all);
}
[HttpGet("stats")]
@ -103,12 +104,12 @@ namespace Oshima.Core.Controllers
builder.AppendLine($"每秒伤害:{stats.DamagePerSecond:0.##}");
builder.AppendLine($"总计击杀数:{stats.Kills}" + (stats.Plays != 0 ? $" / 场均:{(double)stats.Kills / stats.Plays:0.##}" : ""));
builder.AppendLine($"总计死亡数:{stats.Deaths}" + (stats.Plays != 0 ? $" / 场均:{(double)stats.Deaths / stats.Plays:0.##}" : ""));
builder.AppendLine($"击杀死亡比:{(stats.Deaths == 0 ? stats.Kills : (stats.Kills / stats.Deaths)):0.##}");
builder.AppendLine($"总计助攻数:{stats.Assists}" + (stats.Plays != 0 ? $" / 场均:{(double)stats.Assists / stats.Plays:0.##}" : ""));
builder.AppendLine($"总计首杀数:{stats.FirstKills}" + (stats.Plays != 0 ? $" / 首杀率:{(double)stats.FirstKills / stats.Plays * 100:0.##}%" : ""));
builder.AppendLine($"总计首死数:{stats.FirstDeaths}" + (stats.Plays != 0 ? $" / 首死率:{(double)stats.FirstDeaths / stats.Plays * 100:0.##}%" : ""));
builder.AppendLine($"总计参赛数:{stats.Plays}");
builder.AppendLine($"总计冠军数:{stats.Wins}");
builder.AppendLine($"总计前三数:{stats.Top3s}");
builder.AppendLine($"总计败场数:{stats.Loses}");
List<string> names = [.. FunGameSimulation.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key.GetName())];

View File

@ -22,12 +22,14 @@ namespace Oshima.Core.Utils
public static bool IsRuning { get; set; } = false;
public static bool IsWeb { get; set; } = false;
public static bool PrintOut { get; set; } = false;
public static bool DeathMatchRoundDetail { get; set; } = false;
public static string Msg { get; set; } = "";
public static List<string> StartGame(bool printout, bool isWeb = false, bool isTeam = false)
public static List<string> StartGame(bool printout, bool isWeb = false, bool isTeam = false, bool deathMatchRoundDetail = false)
{
PrintOut = printout;
IsWeb = isWeb;
DeathMatchRoundDetail = deathMatchRoundDetail;
try
{
if (IsRuning) return ["游戏正在模拟中,请勿重复请求!"];
@ -407,7 +409,7 @@ namespace Oshima.Core.Utils
if (characterToAct != null)
{
WriteLine($"=== Round {i++} ===");
WriteLine("现在是 [ " + characterToAct + " ] 的回合!");
WriteLine("现在是 [ " + characterToAct + (isTeam ? "" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + "" : "") + " ] 的回合!");
bool isGameEnd = actionQueue.ProcessTurn(characterToAct);
if (isGameEnd)
@ -450,11 +452,15 @@ namespace Oshima.Core.Utils
}
}
if (actionQueue.LastRound.Targets.Any(c => c.HP <= 0))
if (actionQueue.LastRound.HasKill)
{
string roundMsg = Msg;
if (!deathMatchRoundDetail)
{
roundMsg = actionQueue.LastRound.ToString();
}
if (!isWeb)
{
string roundMsg = Msg;
string[] strs = roundMsg.Split("==== 角色状态 ====");
if (strs.Length > 0)
{
@ -462,7 +468,10 @@ namespace Oshima.Core.Utils
}
result.Add(roundMsg);
}
else result.Add(Msg);
else
{
result.Add(roundMsg);
}
}
}
@ -824,7 +833,11 @@ namespace Oshima.Core.Utils
baseScore += 0.5;
}
}
else
{
baseScore = baseScore * 0.6 + 0.4 * (stats.Kills / (stats.Kills + stats.Deaths + 0.01));
}
// 伤害贡献
double logDamageContribution = Math.Log(1 + (stats.TotalDamage / (stats.TotalTakenDamage + 1e-6)));
@ -838,14 +851,14 @@ namespace Oshima.Core.Utils
teamContribution = (stats.Kills + stats.Assists) / (team.Score + 0.01);
if (team.IsWinner)
{
teamContribution += 0.2;
teamContribution += 0.15;
}
}
// 权重设置
double k = stats.Deaths > 0 ? 0.2 : 0.075; // 伤害贡献权重
double l = stats.Deaths > 0 ? 0.3 : 0.05; // 存活时间权重
double t = stats.Deaths > 0 ? 0.225 : 0.1; // 参团率权重
double l = stats.Deaths > 0 ? 0.2 : 0.05; // 存活时间权重
double t = stats.Deaths > 0 ? 0.2 : 0.075; // 参团率权重
// 计算最终评分
double rating = baseScore + k * logDamageContribution + l * liveTimeContribution + t * teamContribution;

View File

@ -33,7 +33,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
public override void AfterDamageCalculation(Character character, Character enemy, double damage, bool isNormalAttack, bool isMagicDamage, MagicType magicType, DamageResult damageResult)
{
if (character == Skill.Character && damageResult != DamageResult.Evaded && !)
if (character == Skill.Character && damageResult != DamageResult.Evaded && ! && enemy.HP > 0)
{
// 叠标记
IEnumerable<Effect> effects = enemy.Effects.Where(e => e is );

View File

@ -54,7 +54,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
return false;
}
public override void OnSkillCasting(Character caster)
public override void OnSkillCasting(Character caster, List<Character> targets)
{
= caster.EP;
}

View File

@ -31,7 +31,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
public override void AfterDamageCalculation(Character character, Character enemy, double damage, bool isNormalAttack, bool isMagicDamage, MagicType magicType, DamageResult damageResult)
{
if (character == Skill.Character && damageResult != DamageResult.Evaded && !)
if (character == Skill.Character && damageResult != DamageResult.Evaded && ! && enemy.HP > 0)
{
// 减少能量
double EP = Random.Shared.Next(7, 15);

View File

@ -34,7 +34,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
public override void AfterDamageCalculation(Character character, Character enemy, double damage, bool isNormalAttack, bool isMagicDamage, MagicType magicType, DamageResult damageResult)
{
if (character == Skill.Character && isNormalAttack && == 0 && ! && GamingQueue != null)
if (character == Skill.Character && isNormalAttack && == 0 && ! && GamingQueue != null && enemy.HP > 0)
{
WriteLine($"[ {character} ] 发动了心灵之火!额外进行一次普通攻击!");
= ;

View File

@ -33,7 +33,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
public override void AfterDamageCalculation(Character character, Character enemy, double damage, bool isNormalAttack, bool isMagicDamage, MagicType magicType, DamageResult damageResult)
{
if (character == Skill.Character && isNormalAttack && damageResult != DamageResult.Evaded && !)
if (character == Skill.Character && isNormalAttack && damageResult != DamageResult.Evaded && ! && enemy.HP > 0)
{
WriteLine($"[ {character} ] 发动了敏捷之刃!将造成额外伤害!");
= true;

View File

@ -11,6 +11,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
public override double EPCost => 60;
public override double CD => 35;
public override double HardnessTime { get; set; } = 5;
public override bool CanSelectSelf => true;
public (Character? character = null) : base(SkillType.Skill, character)
{
@ -73,6 +74,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
{
if (!caster.Effects.Contains(this))
{
GamingQueue?.LastRound.Effects.Add(caster, EffectType.Unselectable);
= true;
= false;
RemainDuration = Duration;