Example #1
0
    public int Check()
    {
        int start_priest = (start_land.GetRoleNum())[0];
        int start_devil  = (start_land.GetRoleNum())[1];
        int end_priest   = (end_land.GetRoleNum())[0];
        int end_devil    = (end_land.GetRoleNum())[1];

        if (end_priest + end_devil == 6)     //获胜
        {
            return(2);
        }

        int[] boat_role_num = boat.GetRoleNumber();
        if (boat.GetBoatSign() == 1)         //在开始岸和船上的角色
        {
            start_priest += boat_role_num[0];
            start_devil  += boat_role_num[1];
        }
        else                                  //在结束岸和船上的角色
        {
            end_priest += boat_role_num[0];
            end_devil  += boat_role_num[1];
        }
        if (start_priest > 0 && start_priest < start_devil) //失败
        {
            return(1);
        }
        if (end_priest > 0 && end_priest < end_devil)        //失败
        {
            return(1);
        }
        return(0);                                             //未完成
    }
Example #2
0
    public int Check()
    {
        int[] priest_num = new int[2] {
            (start_land.GetRoleNum())[0], (end_land.GetRoleNum())[0]
        };
        int[] devil_num = new int[2] {
            (start_land.GetRoleNum())[1], (end_land.GetRoleNum())[1]
        };

        if (priest_num[1] + devil_num[1] == 6)
        {
            return(2);
        }

        int[] boat_role_num = boat.GetRoleNumber();
        if (boat.GetBoatSign() == 1)
        {
            priest_num[0] += boat_role_num[0];
            devil_num[0]  += boat_role_num[1];
        }
        else
        {
            priest_num[1] += boat_role_num[0];
            devil_num[1]  += boat_role_num[1];
        }
        if (priest_num[0] > 0 && priest_num[0] < devil_num[0])
        {
            return(1);
        }
        if (priest_num[1] > 0 && priest_num[1] < devil_num[1])
        {
            return(1);
        }
        return(0);
    }
Example #3
0
    public void AI()
    {
        int         side       = boat.GetBoatSign() == 1 ? 0 : 1;
        LandModel   land       = side == 0 ? start_land : end_land;
        int         p          = (start_land.GetRoleNum())[0] + (1 - side) * (boat.GetRoleNumber())[0];
        int         d          = (start_land.GetRoleNum())[1] + (1 - side) * (boat.GetRoleNumber())[1];
        SolverState cur_state  = new SolverState(p, d, side);
        SolverState next_state = Solve.solve(cur_state);
        int         move_p     = next_state.p - p > 0 ? next_state.p - p : p - next_state.p;
        int         move_d     = next_state.d - d > 0 ? next_state.d - d : d - next_state.d;

        while (move_p < boat.GetRoleNumber()[0])
        {
            MoveRole(boat.GetRoleByType(0));
            return;
        }
        while (move_d < boat.GetRoleNumber()[1])
        {
            MoveRole(boat.GetRoleByType(1));
            return;
        }
        while (move_p > boat.GetRoleNumber()[0])
        {
            MoveRole(land.GetRoleByType(0));
            return;
        }
        while (move_d > boat.GetRoleNumber()[1])
        {
            MoveRole(land.GetRoleByType(1));
            return;
        }
        MoveBoat();
    }
Example #4
0
    void Update()
    {
        int start_priest = (start_land.GetRoleNum())[0];
        int start_devil  = (start_land.GetRoleNum())[1];
        int end_priest   = (end_land.GetRoleNum())[0];
        int end_devil    = (end_land.GetRoleNum())[1];

        if (end_priest + end_devil == 6)     //获胜
        {
            myJudge.setStatus(2);
        }

        int[] boat_role_num = boat.GetRoleNumber();
        if (boat.GetBoatSign() == 1)         //在开始岸和船上的角色
        {
            start_priest += boat_role_num[0];
            start_devil  += boat_role_num[1];
        }
        else                                  //在结束岸和船上的角色
        {
            end_priest += boat_role_num[0];
            end_devil  += boat_role_num[1];
        }
        if (start_priest > 0 && start_priest < start_devil) //失败
        {
            myJudge.setStatus(1);
        }
        if (end_priest > 0 && end_priest < end_devil)        //失败
        {
            myJudge.setStatus(1);
        }
        myJudge.setStatus(0);
    }
Example #5
0
    public int Check()
    {
        //0-游戏继续,1-失败,2-成功
        int startPriests = (startLand.GetRoleNum())[0];
        int startDevils  = (startLand.GetRoleNum())[1];
        int endPriests   = (endLand.GetRoleNum())[0];
        int endDevils    = (endLand.GetRoleNum())[1];

        if (endPriests + endDevils == 6)
        {
            return(2);
        }
        int[] boatNum = boat.GetRoleNumber();
        //加上船上的人
        if (boat.GetBoatSign() == 1)
        {
            startPriests += boatNum[0];
            startDevils  += boatNum[1];
        }
        else
        {
            endPriests += boatNum[0];
            endDevils  += boatNum[1];
        }
        if ((endPriests > 0 && endPriests < endDevils) || (startPriests > 0 && startPriests < startDevils))
        {
            return(1);
        }
        return(0);
    }
Example #6
0
    public int Check()
    {
        int start_priest = (start_land.GetRoleNum())[0];
        int start_devil  = (start_land.GetRoleNum())[1];
        int end_priest   = (end_land.GetRoleNum())[0];
        int end_devil    = (end_land.GetRoleNum())[1];

        if (end_priest + end_devil == 6)
        {
            return(2);
        }

        int[] boat_role_num = boat.GetRoleNum();
        if (boat.GetBoatSign() == true)
        {
            start_priest += boat_role_num[0];
            start_devil  += boat_role_num[1];
        }
        else
        {
            end_priest += boat_role_num[0];
            end_devil  += boat_role_num[1];
        }

        if ((start_priest > 0 && start_priest < start_devil) || (end_priest > 0 && end_priest < end_devil))
        {
            return(1);
        }

        return(0);
    }
Example #7
0
 public int Check()
 {
     return(judge.Check((start_land.GetRoleNum())[0], (start_land.GetRoleNum())[1],
                        (end_land.GetRoleNum())[0], (end_land.GetRoleNum())[1],
                        boat.GetRoleNumber(), boat.GetBoatSign()));
 }