Check-in [b4c948b5ca]
Not logged in
Overview
SHA1 Hash:b4c948b5cac5f2e7fb053b13047f02cc876f6eaa
Date: 2012-07-16 13:36:50
User: kinaba
Comment:Death move avoider for Sovler-wind.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/solver.d from [ee76621ab7188714] to [cc3cdceae20eed85].

607 607 this(in Game g) 608 608 { 609 609 this.g = g.clone(); 610 610 } 611 611 612 612 char single_step() 613 613 { 614 - char c = think(g); 614 + auto dm = death_move(g); 615 + 616 + char c = think(g, dm[0]); 617 + if(c == 'W') { 618 + wait_counter++; 619 + if(dm[0].count(c) || wait_counter>=3) { 620 + c = 'A'; 621 + foreach(char cc; "DLRU") 622 + if(dm[0].count(cc) == 0) 623 + c = cc; 624 + } 625 + if(wait_counter > 20) 626 + c = 'A'; 627 + } else { 628 + wait_counter = 0; 629 + } 615 630 if(c != 'A') 616 631 g.command(c); 617 632 return c; 618 633 } 619 634 620 635 void force(char c) 621 636 { 622 637 if(c != 'A') 623 638 g.command(c); 624 639 } 625 640 626 - char think(in Game g) 627 - { 641 + int wait_counter = 0; 628 642 643 + char think(in Game g, string death) 644 + { 629 645 auto Q = new Queue!(Tuple!(Pos,Pos)); 630 646 Q.push(tuple(g.map.robot.clone(), g.map.robot.clone()), 0); 631 647 Pos[][] V = new Pos[][](g.map.H+2, g.map.W+2); 632 648 while(!Q.empty) { 633 649 auto tup = Q.pop(); 634 650 Pos p = tup[0][0]; 635 651 Pos prev = tup[0][1]; ................................................................................ 652 668 p=q; 653 669 } 654 670 } 655 671 656 672 int[4] dy=[-1,+1,0,0]; 657 673 int[4] dx=[0,0,-1,+1]; 658 674 char[] ds=['D','U','L','R']; 659 - for(int i=0; i<4; ++i) 660 - { 675 + for(int i=0; i<4; ++i) { 676 + if(g.map.robot==p && death.count(ds[i])) 677 + continue; 661 678 int y=p.y+dy[i], x=p.x+dx[i]; 662 679 if((g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||g.map[y,x]=='O')&&!V[y][x]) { 663 680 Q.push(tuple(new Pos(y,x),p), dist+1); 664 681 } 665 682 } 666 683 } 667 - return 'A'; 684 + 685 + return 'W'; 668 686 } 669 687 } 670 688 671 689 //alias 侵掠如火!(疾如風) MainSolver; 672 -alias 侵掠如火!(徐如林) MainSolver; 673 -//alias 疾如風 MainSolver; 690 +//alias 侵掠如火!(徐如林) MainSolver; 691 +alias 疾如風 MainSolver; 674 692 //alias 徐如林 MainSolver; 675 693 //alias 不動如山 MainSolver;