Diff
Not logged in

Differences From Artifact [9428bbab7d2bc9a8]:

To Artifact [eaa7866c864bed8a]:


542 542 air_left_ = max_air_; 543 543 } 544 544 545 545 @property const { 546 546 int H() { return H_; } 547 547 int W() { return W_; } 548 548 char trampoline(char c) { return (c in trampoline_ ? trampoline_[c] : 0); } 549 + const(Pos)[] trampoline_rev(char c) { 550 + const(Pos)[] pp; 551 + if(c in trampoline_rev_) { 552 + foreach(ch; trampoline_rev_[c]) 553 + pp ~= trampoline_pos_[ch]; 554 + } 555 + return pp; 556 + } 549 557 int water_level() { 550 558 return water_pace_ ? water_base_ + turn_/water_pace_ : water_base_; 551 559 } 552 560 int water_until_rise() { 553 561 return water_pace_ ? water_pace_ - turn_%water_pace_ : int.max; 554 562 } 555 563 int hige_until_rise() { ................................................................................ 559 567 return hige_pace_ ? turn_%hige_pace_ == hige_pace_-1 : false; 560 568 } 561 569 int hp() { return air_left_; } 562 570 int num_razor() { return num_razor_; } 563 571 bool cleared() { return cleared_; } 564 572 bool dead() { return dead_; } 565 573 long score() { return num_lambda_*(dead_ ? 25L : cleared_ ? 75L : 50L) - turn_; } 574 + const(Pos) robot() { return robot_pos_; } 575 + const(Pos) lift() { return lift_pos_; } 576 + Pos[] lambdas() { 577 + Pos[] pp; 578 + foreach(p; lambda_pos_) 579 + pp ~= p.clone(); 580 + return pp; 581 + } 582 + Pos[] razors() { 583 + Pos[] pp; 584 + foreach(p; razor_pos_) 585 + pp ~= p.clone(); 586 + return pp; 587 + } 588 + const(Pos)[] higes() { 589 + const(Pos)[] pp; 590 + foreach(p,c; dynamic_objects_) 591 + if(c=='W') 592 + pp ~= p; 593 + return pp; 594 + } 566 595 } 567 596 const { 568 597 char opIndex(in Pos p) { return opIndex(p.y, p.x); } 569 598 char opIndex(int y, int x) { return map_get(y, x); } 570 599 } 571 600 572 601 public: ................................................................................ 578 607 if(c == 'U') command_move(+1, 0); 579 608 if(c == 'D') command_move(-1, 0); 580 609 if(c == 'L') command_move(0, -1); 581 610 if(c == 'R') command_move(0, +1); 582 611 if(c == 'S') use_razor(); 583 612 if(c == 'W') {} 584 613 585 - if(cleared) 586 - return; 587 - 588 - map_update(); 589 - water_update(); 614 + if(!cleared) 615 + { 616 + map_update(); 617 + water_update(); 618 + } 590 619 turn_ ++; 591 620 } 592 621 593 622 void command_move(int dy, int dx) 594 623 { 595 624 int y = robot_pos_.y, x = robot_pos_.x; 596 625 char c = this[y+dy, x+dx]; ................................................................................ 787 816 788 817 void map_set_empty(int y, int x) 789 818 { 790 819 if( y<1 || H<y || x<1 || W<x ) return; 791 820 if( x<0 || raw_data_[y].length<=x ) return; 792 821 raw_data_[y][x] = ' '; 793 822 } 823 + 824 +public: 825 + Game clone() const { return new Game(this); } 826 + this(in Game g) { 827 + H_ = g.H_; 828 + W_ = g.W_; 829 + raw_data_ = new char[][g.raw_data_.length]; 830 + foreach(i,d; g.raw_data_) raw_data_[i] = d.dup; 831 + trampoline_pos_ = cast(Pos[char]) g.trampoline_pos_; 832 + razor_pos_ = (cast(Game)g).razor_pos_.dup; 833 + lambda_pos_ = (cast(Game)g).lambda_pos_.dup; 834 + lift_pos_ = g.lift_pos_.clone(); 835 + robot_pos_ = g.robot_pos_.clone(); 836 + dynamic_objects_ = dup(g.dynamic_objects_); 837 + trampoline_ = (cast(Game)g).trampoline_; 838 + trampoline_rev_ = (cast(Game)g).trampoline_rev_; 839 + water_base_ = g.water_base_; 840 + water_pace_ = g.water_pace_; 841 + max_air_ = g.max_air_; 842 + hige_pace_ = g.hige_pace_; 843 + num_razor_ = g.num_razor_; 844 + num_lambda_ = g.num_lambda_; 845 + turn_ = g.turn_; 846 + air_left_ = g.air_left_; 847 + cleared_ = g.cleared_; 848 + dead_ = g.dead_; 849 + may_update_ = dup(g.may_update_); 850 + } 851 + 852 + V[K] dup(V,K)(in V[K] aa) { 853 + V[K] aa2; 854 + foreach(k,v; aa) aa2[k] = v; 855 + return aa2; 856 + } 794 857 795 858 private: 796 859 int H_; 797 860 int W_; 798 861 char[][] raw_data_; 799 862 Pos[char] trampoline_pos_; 800 863 Pos[] razor_pos_;