Beispiel #1
0
 def test_tri_visual(self):
     unit = Unit.from_query("kaede2 nao4 rika4u uzuki3 anzu4 kaede2")
     np.testing.assert_equal(
         unit.leader_bonuses(),
         np.array([[0, 200, 0, 0, 0], [0, 200, 0, 0, 0], [0, 200, 0, 0,
                                                          0]]).transpose())
     unit = Unit.from_query("kaede2 nao4 rika4u uzuki3 anzu4")
     np.testing.assert_equal(
         unit.leader_bonuses(),
         np.array([[0, 100, 0, 0, 0], [0, 100, 0, 0, 0], [0, 100, 0, 0,
                                                          0]]).transpose())
Beispiel #2
0
    def test_2_reso(self):
        unit = Unit.from_query("sae4 rika4u uzuki1 uzuki3 anzu4 sae4")
        np.testing.assert_equal(
            unit.leader_bonuses(),
            np.array([[-100, 0, -100, 0, 0], [-100, 0, -100, 0, 0],
                      [-100, 0, -100, 0, 0]]).transpose())

        unit = Unit.from_query("sae4 rika4u uzuki1 uzuki3 anzu4 karen4")
        np.testing.assert_equal(
            unit.leader_bonuses(),
            np.array([[-100, -100, -100, 0, 0], [-100, -100, -100, 0, 0],
                      [-100, -100, -100, 0, 0]]).transpose())
Beispiel #3
0
 def test_mismatch_ens(self):
     unit = Unit.from_query("kyoko4 uzuki1 kanako1 uzuki3 anzu4 nao4")
     np.testing.assert_equal(
         unit.leader_bonuses(song_color=Color.CUTE),
         np.array([[55, 55, 55, 0, 0], [30, 30, 30, 0, 0],
                   [0, 0, 0, 0, 0]]).transpose())
     np.testing.assert_equal(
         unit.leader_bonuses(song_color=Color.COOL),
         np.array([[30, 30, 30, 0, 0], [55, 55, 55, 0, 0],
                   [0, 0, 0, 0, 0]]).transpose())
Beispiel #4
0
 def test_ens_and_princess(self):
     unit = Unit.from_query("kyoko4 uzuki1 kanako1 uzuki3 anzu4 uzuki3")
     np.testing.assert_equal(
         unit.leader_bonuses(song_color=Color.COOL),
         np.array([[80, 80, 80, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0,
                                                         0]]).transpose())
     np.testing.assert_equal(
         unit.leader_bonuses(song_color=Color.CUTE),
         np.array([[105, 105, 105, 0, 0], [0, 0, 0, 0, 0],
                   [0, 0, 0, 0, 0]]).transpose())
Beispiel #5
0
 def test_duo_ens(self):
     unit = Unit.from_query("kyoko4 uzuki1 kanako1 uzuki3 anzu4 kyoko4")
     np.testing.assert_equal(
         unit.leader_bonuses(song_color=Color.CUTE),
         np.array([[110, 110, 110, 0, 0], [0, 0, 0, 0, 0],
                   [0, 0, 0, 0, 0]]).transpose())
     np.testing.assert_equal(
         unit.leader_bonuses(song_color=Color.ALL),
         np.array([[60, 60, 60, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0,
                                                         0]]).transpose())
Beispiel #6
0
    def test_mplus(self):
        c1 = Card.from_query("sae4", custom_pots=(10, 10, 10, 10, 10))
        c2 = Card.from_query("chieri2", custom_pots=(10, 10, 10, 10, 10))
        c3 = Card.from_query("chieri2u", custom_pots=(10, 10, 10, 10, 10))
        c4 = Card.from_query("rika4", custom_pots=(10, 10, 10, 10, 10))
        c5 = Card.from_query("yoko1", custom_pots=(10, 10, 10, 10, 10))
        cg = Card.from_query("kaede2", custom_pots=(10, 10, 10, 10, 10))
        unit = Unit.from_list([c1, c2, c3, c4, c5, cg])

        live = Live()
        live.set_music(music_name="EVERMORE", difficulty=Difficulty.MPLUS)
        live.set_unit(unit)
        self.assertEqual(live.get_appeals(), 134140)
        self.assertEqual(live.get_life(), 394)
 def test_bless1(self):
     c0 = Card.from_query("kaede5", custom_pots=(10, 10, 5, 0, 10))
     c1 = Card.from_query("natalia1", custom_pots=(10, 0, 0, 0, 10))
     c2 = Card.from_query("yoshino3", custom_pots=(0, 10, 10, 0, 10))
     c3 = Card.from_query("sarina1", custom_pots=(0, 0, 0, 0, 0))
     c4 = Card.from_query("shiki3", custom_pots=(10, 0, 10, 0, 10))
     guest = Card.from_query("kaede2", custom_pots=(10, 10, 10, 0, 0))
     unit = Unit.from_list([c0, c1, c2, c3, c4, guest])
     live = Live()
     live.set_music(music_name="印象", difficulty=Difficulty.MPLUS)
     live.set_unit(unit)
     sim = Simulator(live)
     sim._setup_simulator(support=110319)
     self.assertEqual(sim.total_appeal, 279476)
Beispiel #8
0
    def test_master(self):
        c1 = Card.from_query("karen4", custom_pots=(0, 6, 10, 0, 10))
        c2 = Card.from_query("sachiko2", custom_pots=(0, 0, 8, 0, 0))
        c3 = Card.from_query("koume2", custom_pots=(0, 0, 10, 0, 10))
        c4 = Card.from_query("miho4", custom_pots=(0, 4, 10, 0, 10))
        c5 = Card.from_query("fumika1", custom_pots=(0, 6, 10, 0, 0))
        cg = Card.from_query("sae4", custom_pots=(0, 10, 0, 5, 10))
        unit = Unit.from_list([c1, c2, c3, c4, c5, cg])

        live = Live()
        live.set_music(music_name="印象", difficulty=Difficulty.MASTER)
        live.set_unit(unit)
        self.assertEqual(live.get_appeals(), 38965)
        self.assertEqual(live.get_life(), 272)
 def test_bless3(self):
     # For some reason, with reso, the other bonuses can only be 0 or -100
     c0 = Card.from_query("kaede5", custom_pots=(10, 10, 5, 0, 10))
     c1 = Card.from_query("karen4", custom_pots=(0, 6, 10, 0, 10))
     c2 = Card.from_query("syuko4", custom_pots=(0, 0, 8, 0, 10))
     c3 = Card.from_query("asuka4", custom_pots=(10, 10, 0, 0, 10))
     c4 = Card.from_query("shiki3", custom_pots=(10, 0, 10, 0, 10))
     guest = Card.from_query("yui2", custom_pots=(10, 10, 10, 0, 0))
     unit = Unit.from_list([c0, c1, c2, c3, c4, guest])
     live = Live()
     live.set_music(music_name="印象", difficulty=Difficulty.MPLUS)
     live.set_unit(unit)
     sim = Simulator(live)
     sim._setup_simulator(support=110319)
     self.assertEqual(sim.total_appeal, 189565)
 def set_cards(self, event):
     cards = event.cards
     self.cards = cards
     try:
         custom_pots = eventbus.eventbus.post_and_get_first(GetCustomPotsEvent())
         if len(cards) == 15:
             unit = GrandUnit.from_list(self.cards, custom_pots)
             self.live = GrandLive()
             self.live.set_unit(unit)
         else:
             unit = Unit.from_list(self.cards, custom_pots)
             self.live = Live()
             self.live.set_unit(unit)
     except InvalidUnit:
         return False
     return True
Beispiel #11
0
 def hook_cards(self, all_cards, redraw=True):
     try:
         if len(all_cards) == 15:
             unit = GrandUnit.from_list(all_cards)
         else:
             unit = Unit.from_list(cards=all_cards[:5])
     except InvalidUnit:
         return
     # Skip drawing if same unit else reset drawing
     if not self.grand and isinstance(unit, GrandUnit):
         unit = unit.ua
     if unit == self.unit:
         return
     self.p.fillRect(0, 0, self.x_total, self.y_total, Qt.black)
     self.unit = unit
     self.paint_skill()
     self.draw()
     if redraw:
         self.label.repaint()
 def test_bonus_chara(self):
     sae4 = Card.from_query("sae4", custom_pots=(0, 10, 10, 0, 10))
     chieri4 = Card.from_query("chieri4", custom_pots=(0, 10, 10, 0, 10))
     yoshino3 = Card.from_query("yoshino3", custom_pots=(0, 10, 10, 0, 10))
     rika4 = Card.from_query("rika4", custom_pots=(0, 10, 10, 0, 10))
     mio4 = Card.from_query("mio4", custom_pots=(0, 10, 10, 0, 10))
     kaede2_guest = Card.from_query("kaede2",
                                    custom_pots=(10, 10, 10, 0, 0))
     unit = Unit.from_list(
         [sae4, chieri4, yoshino3, rika4, mio4, kaede2_guest])
     live = Live()
     live.set_music(music_name="印象", difficulty=Difficulty.MPLUS)
     live.set_unit(unit)
     sim = Simulator(live)
     sim.simulate()
     self.assertEqual(live.get_appeals(), 155135)
     live.reset_attributes()
     live.set_chara_bonus({262}, 500)
     live.special_option = APPEAL_PRESETS["Event Idols"]
     self.assertEqual(live.get_appeals(), 238635)
     live.reset_attributes()
     live.set_chara_bonus({262}, 5000)
     live.special_option = APPEAL_PRESETS["Event Idols"]
     self.assertEqual(live.get_appeals(), 973137)
Beispiel #13
0
        self.p.drawConvexPolygon(polygon)

    def draw_notes(self):
        for group_idx, group in enumerate(self.note_groups):
            for note in group:
                x = self.get_x(note.lane + note.span / 2,
                               group_idx) - note.note_pic.width() // 2
                y = self.get_y(note.sec,
                               group_idx) - note.note_pic.height() // 2
                self.p.drawImage(QPoint(x, y), note.note_pic)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setApplicationName("Bruh")
    main_window = QMainWindow()
    main_window.show()
    unit = Unit.from_list([100936, 100708, 100914, 100584, 100456, 100964])
    live = Live()
    live.set_music(score_id=637, difficulty=5)
    live.set_unit(unit)
    sim = Simulator(live)
    res: MaxSimulationResult = sim.simulate_theoretical_max()
    cpg = BaseChartPicGenerator.get_generator(637,
                                              Difficulty(5),
                                              main_window,
                                              mirrored=True)
    cpg.hook_cards(unit.all_cards())
    cpg.hook_abuse(unit.all_cards(), res.abuse_df)
    app.exec_()
 def from_list(cls, card_list, custom_pots=None):
     return cls(Unit.from_list(card_list[0:5], custom_pots),
                Unit.from_list(card_list[5:10], custom_pots),
                Unit.from_list(card_list[10:15], custom_pots))
 def test_princess_all_passion(self):
     unit = Unit.from_query("mio1 mio2 mio3 mio4 rika4")
     self.assertEqual(unit.get_card(2).skill.probability, 8000)
 def test_syn_all_passion(self):
     unit = Unit.from_query("mio1 mio2 mio3 mio4 rika4")
     self.assertEqual(unit.get_card(4).skill.probability, 0)
Beispiel #17
0
 def test_fail_princess(self):
     unit = Unit.from_query("uzuki3 nao4 kanako1 uzuki3 anzu4 uzuki3")
     np.testing.assert_equal(
         unit.leader_bonuses(),
         np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0,
                                                      0]]).transpose())
 def test_princess_mismatch(self):
     unit = Unit.from_query("mio1 mio2 mio3 mio4 rin2")
     self.assertEqual(unit.get_card(2).skill.probability, 0)
from logic.grandlive import GrandLive
from logic.grandunit import GrandUnit
from logic.live import Live
from logic.unit import Unit
from simulator import Simulator
from static.song_difficulty import Difficulty

logger.print_debug()

sae4 = Card.from_query("sae4", custom_pots=(2, 10, 0, 0, 10))
chieri4 = Card.from_query("chieri4", custom_pots=(0, 10, 9, 0, 10))
yoshino3 = Card.from_query("yoshino3", custom_pots=(8, 10, 0, 0, 10))
rika4 = Card.from_query("rika4", custom_pots=(8, 10, 0, 0, 10))
mio4 = Card.from_query("mio4", custom_pots=(0, 5, 0, 0, 10))
kaede2_guest = Card.from_query("kaede2", custom_pots=(10, 10, 10, 0, 5))
unit = Unit.from_list([sae4, chieri4, yoshino3, rika4, mio4, kaede2_guest])

live = Live()
live.set_music(music_name="印象", difficulty=Difficulty.MPLUS)
live.set_unit(unit)
sim = Simulator(live)
assert sim.simulate(times=100, appeals=270000).perfect_score == 1736810

unitA = Unit.from_query("kaede2 chieri4 kyoko4 rika4 rika4u")
unitB = Unit.from_query("sae4 kozue2 momoka3 frederica3 sachiko4")
unitC = Unit.from_query("atsumi2 anzu3 anzu3u miku4 miku3")
gu = GrandUnit(unitA, unitB, unitC)
live = GrandLive()
live.set_music(music_name="Starry-Go-Round", difficulty=Difficulty.PIANO)
live.set_unit(gu)
sim = Simulator(live)
Beispiel #20
0
 def test_fail_reso(self):
     unit = Unit.from_query("sae4 rika4u kaede2 yui2 anzu4 rin2")
     np.testing.assert_equal(
         unit.leader_bonuses(),
         np.array([[100, 0, 0, 0, 0], [100, 0, 0, 0, 0], [100, 0, 0, 0,
                                                          0]]).transpose())
Beispiel #21
0
 def test_tri_visual_vocal(self):
     unit = Unit.from_query("kaede2 rika4u uzuki1 uzuki3 anzu4 rin2")
     np.testing.assert_equal(
         unit.leader_bonuses(),
         np.array([[100, 100, 0, 0, 0], [100, 100, 0, 0, 0],
                   [100, 100, 0, 0, 0]]).transpose())
    def simulate_internal(self,
                          perfect_play,
                          left_inclusive,
                          right_inclusive,
                          theoretical_simulation,
                          score_id,
                          diff_id,
                          times,
                          all_cards,
                          custom_pots,
                          appeals,
                          support,
                          extra_bonus,
                          special_option,
                          special_value,
                          mirror,
                          autoplay,
                          autoplay_offset,
                          doublelife,
                          row=None):
        """
        :type all_cards: List[CardsWithUnitUuid]
        """
        results = list()
        if len(all_cards) == 0:
            logger.info("Nothing to simulate")
            return
        extra_return = None

        # Initialize song first because SQLite DB thread lock
        # Live objects are mutable so create one for each simulation
        # TODO: Minor optimize by calling set_music only once then clone, but set_music shouldn't take too long to run so this is on low priority
        live_objects = list()
        for card_with_uuid in all_cards:
            cards = card_with_uuid.cards
            if len(cards) == 15:
                live = GrandLive()
            else:
                live = Live()
            live.set_music(score_id=score_id, difficulty=diff_id)
            groove_song_color = eventbus.eventbus.post_and_get_first(
                GetGrooveSongColor())
            if groove_song_color is not None:
                live.color = groove_song_color
            live_objects.append(live)

        # Load cards
        for live, card_with_uuid in zip(live_objects, all_cards):
            cards = card_with_uuid.cards
            try:
                if len(cards) == 15:
                    unit = GrandUnit.from_list(cards, custom_pots)
                else:
                    if cards[5] is None:
                        cards = cards[:5]
                    unit = Unit.from_list(cards, custom_pots)
            except InvalidUnit:
                logger.info("Invalid unit: {}".format(cards))
                results.append(None)
                continue

            eventbus.eventbus.post(SimulationEvent(
                card_with_uuid.uuid, card_with_uuid.short_uuid, row is not None
                and theoretical_simulation, appeals, autoplay, autoplay_offset,
                doublelife, extra_bonus, extra_return, live, mirror,
                perfect_play, results, special_option, special_value, support,
                times, unit, left_inclusive, right_inclusive,
                theoretical_simulation),
                                   high_priority=True,
                                   asynchronous=True)