Diff
Not logged in

Differences From Artifact [9428bbab7d2bc9a8]:

To Artifact [eaa7866c864bed8a]:


542 air_left_ = max_air_; 542 air_left_ = max_air_; 543 } 543 } 544 544 545 @property const { 545 @property const { 546 int H() { return H_; } 546 int H() { return H_; } 547 int W() { return W_; } 547 int W() { return W_; } 548 char trampoline(char c) { return (c in trampoline_ ? trampoline_ 548 char trampoline(char c) { return (c in trampoline_ ? trampoline_ > 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 int water_level() { 557 int water_level() { 550 return water_pace_ ? water_base_ + turn_/water_pace_ : w 558 return water_pace_ ? water_base_ + turn_/water_pace_ : w 551 } 559 } 552 int water_until_rise() { 560 int water_until_rise() { 553 return water_pace_ ? water_pace_ - turn_%water_pace_ : i 561 return water_pace_ ? water_pace_ - turn_%water_pace_ : i 554 } 562 } 555 int hige_until_rise() { 563 int hige_until_rise() { ................................................................................................................................................................................ 559 return hige_pace_ ? turn_%hige_pace_ == hige_pace_-1 : f 567 return hige_pace_ ? turn_%hige_pace_ == hige_pace_-1 : f 560 } 568 } 561 int hp() { return air_left_; } 569 int hp() { return air_left_; } 562 int num_razor() { return num_razor_; } 570 int num_razor() { return num_razor_; } 563 bool cleared() { return cleared_; } 571 bool cleared() { return cleared_; } 564 bool dead() { return dead_; } 572 bool dead() { return dead_; } 565 long score() { return num_lambda_*(dead_ ? 25L : cleared_ ? 75L 573 long score() { return num_lambda_*(dead_ ? 25L : cleared_ ? 75L > 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 const { 596 const { 568 char opIndex(in Pos p) { return opIndex(p.y, p.x); } 597 char opIndex(in Pos p) { return opIndex(p.y, p.x); } 569 char opIndex(int y, int x) { return map_get(y, x); } 598 char opIndex(int y, int x) { return map_get(y, x); } 570 } 599 } 571 600 572 public: 601 public: ................................................................................................................................................................................ 578 if(c == 'U') command_move(+1, 0); 607 if(c == 'U') command_move(+1, 0); 579 if(c == 'D') command_move(-1, 0); 608 if(c == 'D') command_move(-1, 0); 580 if(c == 'L') command_move(0, -1); 609 if(c == 'L') command_move(0, -1); 581 if(c == 'R') command_move(0, +1); 610 if(c == 'R') command_move(0, +1); 582 if(c == 'S') use_razor(); 611 if(c == 'S') use_razor(); 583 if(c == 'W') {} 612 if(c == 'W') {} 584 613 585 if(cleared) | 614 if(!cleared) 586 return; < 587 | 615 { 588 map_update(); | 616 map_update(); 589 water_update(); | 617 water_update(); > 618 } 590 turn_ ++; 619 turn_ ++; 591 } 620 } 592 621 593 void command_move(int dy, int dx) 622 void command_move(int dy, int dx) 594 { 623 { 595 int y = robot_pos_.y, x = robot_pos_.x; 624 int y = robot_pos_.y, x = robot_pos_.x; 596 char c = this[y+dy, x+dx]; 625 char c = this[y+dy, x+dx]; ................................................................................................................................................................................ 787 816 788 void map_set_empty(int y, int x) 817 void map_set_empty(int y, int x) 789 { 818 { 790 if( y<1 || H<y || x<1 || W<x ) return; 819 if( y<1 || H<y || x<1 || W<x ) return; 791 if( x<0 || raw_data_[y].length<=x ) return; 820 if( x<0 || raw_data_[y].length<=x ) return; 792 raw_data_[y][x] = ' '; 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 private: 858 private: 796 int H_; 859 int H_; 797 int W_; 860 int W_; 798 char[][] raw_data_; 861 char[][] raw_data_; 799 Pos[char] trampoline_pos_; 862 Pos[char] trampoline_pos_; 800 Pos[] razor_pos_; 863 Pos[] razor_pos_;