更新 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; private readonly ILogger<UserDailyController> _logger = logger;
[HttpGet("test")] [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 web = isweb ?? true;
bool team = isteam ?? false; bool team = isteam ?? false;
return FunGameSimulation.StartGame(false, web, team); bool all = showall ?? false;
return FunGameSimulation.StartGame(false, web, team, all);
} }
[HttpGet("stats")] [HttpGet("stats")]
@ -103,12 +104,12 @@ namespace Oshima.Core.Controllers
builder.AppendLine($"每秒伤害:{stats.DamagePerSecond:0.##}"); builder.AppendLine($"每秒伤害:{stats.DamagePerSecond:0.##}");
builder.AppendLine($"总计击杀数:{stats.Kills}" + (stats.Plays != 0 ? $" / 场均:{(double)stats.Kills / stats.Plays: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}" + (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.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.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.FirstDeaths}" + (stats.Plays != 0 ? $" / 首死率:{(double)stats.FirstDeaths / stats.Plays * 100:0.##}%" : ""));
builder.AppendLine($"总计参赛数:{stats.Plays}"); builder.AppendLine($"总计参赛数:{stats.Plays}");
builder.AppendLine($"总计冠军数:{stats.Wins}"); builder.AppendLine($"总计冠军数:{stats.Wins}");
builder.AppendLine($"总计前三数:{stats.Top3s}");
builder.AppendLine($"总计败场数:{stats.Loses}"); builder.AppendLine($"总计败场数:{stats.Loses}");
List<string> names = [.. FunGameSimulation.TeamCharacterStatistics.OrderByDescending(kv => kv.Value.Winrates).Select(kv => kv.Key.GetName())]; 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 IsRuning { get; set; } = false;
public static bool IsWeb { get; set; } = false; public static bool IsWeb { get; set; } = false;
public static bool PrintOut { 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 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; PrintOut = printout;
IsWeb = isWeb; IsWeb = isWeb;
DeathMatchRoundDetail = deathMatchRoundDetail;
try try
{ {
if (IsRuning) return ["游戏正在模拟中,请勿重复请求!"]; if (IsRuning) return ["游戏正在模拟中,请勿重复请求!"];
@ -407,7 +409,7 @@ namespace Oshima.Core.Utils
if (characterToAct != null) if (characterToAct != null)
{ {
WriteLine($"=== Round {i++} ==="); WriteLine($"=== Round {i++} ===");
WriteLine("现在是 [ " + characterToAct + " ] 的回合!"); WriteLine("现在是 [ " + characterToAct + (isTeam ? "" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + "" : "") + " ] 的回合!");
bool isGameEnd = actionQueue.ProcessTurn(characterToAct); bool isGameEnd = actionQueue.ProcessTurn(characterToAct);
if (isGameEnd) if (isGameEnd)
@ -450,11 +452,15 @@ namespace Oshima.Core.Utils
} }
} }
if (actionQueue.LastRound.Targets.Any(c => c.HP <= 0)) if (actionQueue.LastRound.HasKill)
{
if (!isWeb)
{ {
string roundMsg = Msg; string roundMsg = Msg;
if (!deathMatchRoundDetail)
{
roundMsg = actionQueue.LastRound.ToString();
}
if (!isWeb)
{
string[] strs = roundMsg.Split("==== 角色状态 ===="); string[] strs = roundMsg.Split("==== 角色状态 ====");
if (strs.Length > 0) if (strs.Length > 0)
{ {
@ -462,7 +468,10 @@ namespace Oshima.Core.Utils
} }
result.Add(roundMsg); result.Add(roundMsg);
} }
else result.Add(Msg); else
{
result.Add(roundMsg);
}
} }
} }
@ -824,6 +833,10 @@ namespace Oshima.Core.Utils
baseScore += 0.5; 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))); 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); teamContribution = (stats.Kills + stats.Assists) / (team.Score + 0.01);
if (team.IsWinner) if (team.IsWinner)
{ {
teamContribution += 0.2; teamContribution += 0.15;
} }
} }
// 权重设置 // 权重设置
double k = stats.Deaths > 0 ? 0.2 : 0.075; // 伤害贡献权重 double k = stats.Deaths > 0 ? 0.2 : 0.075; // 伤害贡献权重
double l = stats.Deaths > 0 ? 0.3 : 0.05; // 存活时间权重 double l = stats.Deaths > 0 ? 0.2 : 0.05; // 存活时间权重
double t = stats.Deaths > 0 ? 0.225 : 0.1; // 参团率权重 double t = stats.Deaths > 0 ? 0.2 : 0.075; // 参团率权重
// 计算最终评分 // 计算最终评分
double rating = baseScore + k * logDamageContribution + l * liveTimeContribution + t * teamContribution; 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) 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 ); IEnumerable<Effect> effects = enemy.Effects.Where(e => e is );

View File

@ -54,7 +54,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
return false; return false;
} }
public override void OnSkillCasting(Character caster) public override void OnSkillCasting(Character caster, List<Character> targets)
{ {
= caster.EP; = 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) 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); 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) 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} ] 发动了心灵之火!额外进行一次普通攻击!"); 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) 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} ] 发动了敏捷之刃!将造成额外伤害!"); WriteLine($"[ {character} ] 发动了敏捷之刃!将造成额外伤害!");
= true; = true;

View File

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