/** * 勝敗が決した場合は勝ったチームのidを返す * そうでない場合は-1を返す */ public int move(int teamId, TPoint from, TPoint to) { Debug.Assert(TPoint.manhattan(from, to) == 1); Ghost tar = getGhostImpl(from); Debug.Assert(tar != null); Debug.Assert(tar.getTeamId() == teamId); Debug.Assert(isInField(to) || (tar.getType() == GhostType.Good && isInGoal(teamId, to))); Ghost next = getGhostImpl(to); if (next != null) { Debug.Assert(next.getTeamId() != teamId); if (next.isEvil()) { fragedEvilNum[teamId]++; } else { fragedGoodNum[teamId]++; } } setGhost(from, null); setGhost(to, tar); if (getFraggedEvilNum(teamId) >= cTeamGhostNum / 2) { //悪ゴーストを全部取った。負け mDetail = CauseOfResult.FragAllEvil; return(1 - teamId); } else if (getFraggedGoodNum(teamId) >= cTeamGhostNum / 2) { //善ゴーストを全部取った。勝ち。 mDetail = CauseOfResult.FragAllGood; return(teamId); } //相手側の善ゴーストがゴールしてたら相手の勝ち foreach (TPoint p in IField.GetGoalPositions(1 - teamId)) { var g = getGhost(p); if (g == null) { continue; } if (g.getType() == GhostType.Good && g.getTeamId() == 1 - teamId) { mDetail = CauseOfResult.Goal; return(1 - teamId); } } //まだ決着がついていない return(-1); }
public int calcJudgeWinner() { //判定勝ちを調べる mDetail = CauseOfResult.Judge; int winByCount = IField.winnerByGhostCount(getRemainGoodNum(0), getRemainEvilNum(0), getRemainGoodNum(1), getRemainEvilNum(1)); if (winByCount >= 0) { return(winByCount); } //マンハッタン勝負 return(winnerByManhattan()); }
public void setup(GhostType[] team0Posisions, GhostType[] team1Possisions) { mDetail = CauseOfResult.None; //MasterFieldでは上チームを1,下チームを0とする for (int teamId = 0; teamId < 2; teamId++) { TPoint[] firstPos = (teamId == 0) ? cLowerTeamFirstPositions : cUpperTeamFirstPositions; GhostType[] teamPos = (teamId == 0) ? team0Posisions : team1Possisions; for (int id = 0; id < cTeamGhostNum; id++) { setGhost(firstPos[id], new Ghost(teamId, teamPos[id])); } } }