<< 32/50 >>
First Last

ザラキマ

実装もややこしい…

    void zarakima2() {
      int zaraki_start = findBestZarakiStart();
      LOG(INFO) << "ZARAKIMA! from " << zaraki_start;
      if (zaraki_start < 0) {
        zarakima_failed_ = true;
        return;
      }
  
      vector<int> o = zarakima_slots_;
  
      // K(n)
      setNumberFromZero(zaraki_start, o[0]);
      c2s(K, o[0]);
  
      // S(K(loop))(K(n))
      s2c(o[2], ZERO);
  
      setCard(ZERO, o[0]);
      // Move 2 => 0
      setNumberFromZero(o[2], o[0]);
      c2s(GET, o[0]);
  
      // Launch! S(zombie(0))(get)(zero)
      setCard(ZOMBIE, o[2]);
      s2c(o[2], ZERO);
      c2s(K, o[2]);
      c2s(S, o[2]);
      s2c(o[2], GET);
      addSetNumber(o[2], o[0]);
  
      if (opp_->slot(255).v == 1) {
        set<int> except(o.begin(), o.end());
        vector<int> o2;
        if (!getLiveNWorkerExcept(224, 1, except, &o2)) {
          state_ = STATE_NORMAL;
          zarakima_failed_ = true;
          ops_.clear();
          return;
        }
        setCard(ZERO, o2[0]);
        c2s(DEC, o2[0]);
      } else if (opp_->slot(255).v > 1) {
        set<int> except(o.begin(), o.end());
        vector<int> o2;
        if (!getLiveNWorkerExcept(224, 3, except, &o2)) {
          state_ = STATE_NORMAL;
          zarakima_failed_ = true;
          ops_.clear();
          return;
        }
  
        set<int> used;
        int ni = o2[0];
        int ai = o2[1];
        int mi = o2[2];
        int v = opp_->slot(255).v;
        bool first = true;
        while (v > 0) {
          int sac = -1;
          for (int i = 0; i < 256; i++) {
            int j = (i + 5) % 256;
            if (me_->slot(j).v > 8192 && used.insert(j).second) {
              sac = j;
              break;
            }
          }
  
          if (sac < 0) {
            state_ = STATE_NORMAL;
            zarakima_failed_ = true;
            ops_.clear();
            return;
          }
  
          if (first) {
            setCard(ZERO, mi);
            setNumberFromZero(sac, mi);
            c2s(ATTACK, mi);
            s2c(mi, ZERO);
          } else {
            setCard(ZERO, ai);
            setNumberFromZero(sac, ai);
            c2s(ATTACK, ai);
            s2c(ai, ZERO);
  
            c2s(S, mi);
            addArgFilterSlot(mi, ai);
          }
  
          first = false;
          v -= 7372;
        }
  
        setCard(ZERO, ni);
        setNumberFromZero(8192, ni);
        addArgFilterSlot(mi, ni);
      }
  
      s2c(o[2], ZERO);
  
      setSpell("ZARAKIMA2");
      state_ = STATE_ZARAKIMA3;
    }