Skip to content

Commit

Permalink
Merge pull request #11 from telecomadm1145/taiko_ruleset_test
Browse files Browse the repository at this point in the history
Taiko ruleset test(not finished)
  • Loading branch information
telecomadm1145 authored Nov 19, 2023
2 parents 4d01d97 + bfb0da4 commit a4c1063
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 25 deletions.
1 change: 1 addition & 0 deletions cmania/TaikoObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct TaikoObject : public HitObject {
Spinner = 4,// 2λ
Barline = 8,
SliderTick = 16,
Slider = 32,
} ObjectType;
double EndTime;
int RemainsHits;
Expand Down
45 changes: 36 additions & 9 deletions cmania/TaikoRuleset.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
to.StartTime = obj.StartTime;
auto tp = GetTimingPointTiming(orig_bmp, obj.StartTime);
auto bpm = tp.BPM();
auto blen = 60.0 / bpm;
auto blen = 1000 / (bpm / 60.0);
auto vec = GetTimingPointNonTiming(orig_bmp, obj.StartTime).SpeedMultiplier();
auto odd_s = std::abs(orig_bmp.SliderTickRate - 3) < 0.01;
bool isKat = HasFlag(obj.SoundType, HitSoundType::Whistle) || HasFlag(obj.SoundType, HitSoundType::Clap);
Expand All @@ -151,14 +151,15 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
auto snap = odd_s ? 6 : (bpm <= 125.0 ? 8 : 4);
blen /= snap;
auto duration = obj.Length / velocity;
for (auto i = obj.StartTime + blen; i < duration; i += blen) {
for (auto i = obj.StartTime + blen; i < obj.StartTime + duration; i += blen) {
TaikoObject to{};
to.StartTime = i;
to.ObjectType = TaikoObject::SliderTick;
to.Velocity = vec;
Beatmap.push_back(to);
}
continue;
to.EndTime = to.StartTime + duration;
to.Velocity = vec;
}
else if (HasFlag(obj.Type, HitObjectType::Spinner)) {
auto snap = odd_s ? 6 : (bpm <= 125.0 ? 8 : 4);
Expand Down Expand Up @@ -218,9 +219,11 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
if (pressed) {
auto rx = HasFlag(Mods, OsuMods::Relax);
auto first_hit = Beatmap > Where([&](TaikoObject& obj) -> bool {
return !obj.HasHit && (obj.StartTime - clock < miss_offset);
return !obj.HasHit && (obj.StartTime - clock < miss_offset) && !HasFlag(obj.ObjectType, TaikoObject::Barline);
}) > FirstOrDefault();
if (first_hit != 0) {
if (HasFlag(first_hit->ObjectType, TaikoObject::Slider))
return;
auto kat = HasFlag(first_hit->ObjectType, TaikoObject::Kat);
auto large = HasFlag(first_hit->ObjectType, TaikoObject::Large);
// miss if a wrong action has been pressed
Expand Down Expand Up @@ -315,13 +318,33 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
// }
// }
// }
auto tick = HasFlag(obj.ObjectType, TaikoObject::SliderTick);
if (tick) {
if (time > obj.StartTime + miss_offset && !obj.HasHit) {
obj.HasHit = true;
}
}
auto spin = HasFlag(obj.ObjectType, TaikoObject::Spinner);
if (spin) {
if (obj.RemainsHits <= 0) {
obj.HasHit = true;
}
}
auto large = HasFlag(obj.ObjectType, TaikoObject::Large);
if (large) {
if (obj.RemainsHits == -1 && time > obj.StartTime + miss_offset) {
obj.HasHit = true;
}
}
if (!obj.HasHit) {
if (HasFlag(obj.ObjectType, TaikoObject::Slider))
{
if (time > obj.EndTime)
{
obj.HasHit = true;
}
return;
}
if (!obj.HasHit && !HasFlag(obj.ObjectType, TaikoObject::Slider) && !HasFlag(obj.ObjectType, TaikoObject::Barline)) {
if (time > obj.StartTime + miss_offset) {
RulesetScoreProcessor->ApplyHit(obj, 1.0 / 0 * 0);
LastHitResult = HitResult::Miss;
Expand Down Expand Up @@ -349,8 +372,7 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
return 1;
auto hd = HasFlag(mods, OsuMods::Hidden);
auto fo = HasFlag(mods, OsuMods::FadeOut);
if (hd && fo)
{
if (hd && fo) {
if (ratio < 0.7) {
return pow(ratio / 0.7, 3);
}
Expand Down Expand Up @@ -380,7 +402,7 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
buf.FillRect(0, buf.Height / 4, buf.Width, buf.Height * 2 / 4, { {}, { 255, 40, 40, 40 }, ' ' });
for (size_t i = 0; i < 4; i++) {
buf.FillRect(hitpos.X - ((double)i - 1) * scale * 5 - scale * 10, buf.Height / 4, hitpos.X - (i)*scale * 5 - scale * 10, buf.Height * 2 / 4, { {}, { 120, 80, 80, 80 }, ' ' });
KeyHighlight[i].Update(e_ms, [&](double v) {
KeyHighlight[3-i].Update(e_ms, [&](double v) {
Color clr{ 220, 20, 212, 255 };
if ((i == 1) || (i == 2)) {
clr = { 220, 255, 30, 30 };
Expand All @@ -401,6 +423,10 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
}
if (HasFlag(obj.ObjectType, TaikoObject::SliderTick)) {
fill = { 220, 255, 237, 77 };
sz = scale * 3;
}
if (HasFlag(obj.ObjectType, TaikoObject::Slider)) {
fill = { 220, 255, 237, 77 };
}
if (HasFlag(obj.ObjectType, TaikoObject::Large)) {
sz = scale * 8;
Expand All @@ -411,7 +437,8 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
continue;
outter.Alpha = fill.Alpha = (unsigned char)(CalcFlashlight(Mods, 1 - v) * 255) * std::clamp((1 - v) * 3, 0.0, 1.0);
buf.FillCircle(objx, hitpos.Y, sz, rt, { {}, fill, ' ' });
buf.DrawCircle(objx, hitpos.Y, sz, 0.25, rt, { {}, outter, ' ' });
if (!HasFlag(obj.ObjectType, TaikoObject::SliderTick) && !HasFlag(obj.ObjectType,TaikoObject::Slider))
buf.DrawCircle(objx, hitpos.Y, sz, 0.25, rt, { {}, outter, ' ' });
}

LastHitResultAnimator.Update(e_ms, [&](double val) {
Expand Down
39 changes: 23 additions & 16 deletions cmania/TaikoScoreProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TaikoScoreProcessor : public ScoreProcessor<TaikoObject> {
double reference_rating = 1;
double pp_m = 1;
double score_m = 1;
int bonus_score = 0;

public:
virtual void ApplyBeatmap(double ref_rating) override {
Expand All @@ -36,6 +37,7 @@ class TaikoScoreProcessor : public ScoreProcessor<TaikoObject> {
// ͨ¹ý ScoreProcessor ¼Ì³Ð
virtual HitResult ApplyHit(TaikoObject& to, double err) override {
auto large = HasFlag(to.ObjectType, TaikoObject::Large);
auto tick = HasFlag(to.ObjectType, TaikoObject::SliderTick);
auto is_hold = to.EndTime != 0;
if (to.HasHit && !is_hold) {
// need more code there.
Expand All @@ -53,6 +55,12 @@ class TaikoScoreProcessor : public ScoreProcessor<TaikoObject> {
}
});
}
if (tick) {
to.HasHit = true;
bonus_score += 300;
UpdateScore();
return HitResult::None;
}
if (res > HitResult::None) {
if (!is_hold && to.RemainsHits == 0 && large)
{
Expand All @@ -62,34 +70,33 @@ class TaikoScoreProcessor : public ScoreProcessor<TaikoObject> {
{
to.HasHit = true;
}
Combo++;

Combo++;
if (res == HitResult::Miss)
Combo = 0;
MaxCombo = std::max(Combo, MaxCombo);

RawAccuracy += std::min(GetBaseScore(res), GetBaseScore(HitResult::Great));
AppliedHit++;

Accuracy = (double)RawAccuracy / AppliedHit / GetBaseScore(HitResult::Great);

Rating = reference_rating * std::pow(((double)MaxCombo / BeatmapMaxCombo), 0.3) * pow(Accuracy, 1.3) * pow(pp_m, 1.2) * pow(0.95, ResultCounter[HitResult::Miss]);

ResultCounter[res]++;
RawScore += GetBaseScore(res);

RawAccuracy += std::min(GetBaseScore(res), GetBaseScore(HitResult::Great));
if (res != HitResult::Miss) {
RawError += err;
Errors.push_back(err);
Mean = (double)RawError / Errors.size();
Error = variance(Mean, Errors);
}

Score = (((double)RawScore / BeatmapMaxCombo / GetBaseScore(HitResult::Perfect)) * 0.7 + ((double)MaxCombo / BeatmapMaxCombo) * 0.3) * score_m;

ResultCounter[res]++;
UpdateScore();
}
return res;
}
void UpdateScore() {

MaxCombo = std::max(Combo, MaxCombo);

Accuracy = (double)RawAccuracy / AppliedHit / GetBaseScore(HitResult::Great);

Rating = reference_rating * std::pow(((double)MaxCombo / BeatmapMaxCombo), 0.3) * pow(Accuracy, 1.3) * pow(pp_m, 1.2) * pow(0.95, ResultCounter[HitResult::Miss]);
Mean = (double)RawError / Errors.size();
Error = variance(Mean, Errors);
Score = (((double)RawScore / BeatmapMaxCombo / GetBaseScore(HitResult::Perfect)) * 0.7 + ((double)MaxCombo / BeatmapMaxCombo) * 0.3) * score_m + bonus_score / 1000000.0;
}
virtual double GetHealthIncreaseFor(HitResult res) override {
return 0.0;
}
Expand Down

0 comments on commit a4c1063

Please sign in to comment.