private int winnerByManhattan() { int score0 = 0; int score1 = 0; for (int y = 0; y < IField.cFieldHeight; y++) { for (int x = 0; x < IField.cFieldWidth; x++) { IGhost g = getGhost(x, y); if (g == null) { continue; } if (g.getType() == GhostType.Good) { int team = g.getTeamId(); if (team == 0) { score0 += Math.Min(TPoint.manhattan(IField.GetGoalPositions(0)[0], x, y), TPoint.manhattan(IField.GetGoalPositions(0)[1], x, y)); } else { score0 += Math.Min(TPoint.manhattan(IField.GetGoalPositions(1)[0], x, y), TPoint.manhattan(IField.GetGoalPositions(1)[1], x, y)); } } } } return(score0 < score1 ? 0 : score1 < score0 ? 1 : 2); }
override public string ToString() { StringBuilder sb = new StringBuilder(); for (int y = 0; y < cFieldHeight; y++) { for (int x = 0; x < cFieldWidth; x++) { IGhost ghost = getGhost(x, y); if (ghost == null) { sb.Append("_"); } else if (ghost.isEvil()) { sb.Append(ghost.getTeamId() == 0 ? "E" : "e"); } else if (ghost.isGood()) { sb.Append(ghost.getTeamId() == 0 ? "G" : "g"); } else { sb.Append(ghost.getTeamId() == 0 ? "U" : "u"); } } sb.Append("\n"); } sb.Append("team0 fragged:"); for (int i = 0; i < getFraggedGoodNum(0); i++) { sb.Append("g"); } for (int i = 0; i < getFraggedEvilNum(0); i++) { sb.Append("e"); } sb.Append("\n"); sb.Append("team1 fragged:"); for (int i = 0; i < getFraggedGoodNum(1); i++) { sb.Append("G"); } for (int i = 0; i < getFraggedEvilNum(1); i++) { sb.Append("E"); } sb.Append("\n"); return(sb.ToString()); }
override public IGhost getGhost(int x, int y) { IGhost ghost = mMasterField.getGhost(x, y); if (ghost != null) { return(new PlayersGhost(ghost, mPlayerId)); } else { return(null); } }
virtual public bool canMove(int teamId, TPoint from, TPoint to) { if (TPoint.manhattan(from, to) != 1) { return(false); } IGhost tar = getGhost(from); if (tar == null || tar.getTeamId() != teamId) { return(false); } /* * if (isInGoal(teamId, to)) * { * if (tar.getType() == GhostType.Good) * { * return true; * } * else * { * return false; * } * } */ if (!isInField(to)) { return(false); } IGhost next = getGhost(to); if (next != null && next.getTeamId() == teamId) { return(false); } return(true); }
public MaxMinBitField(IField field, int myTeamId, int turn) { mMyPlayerId = myTeamId; mTurn = turn; mNextPlayerId = myTeamId; for (int y = 0; y < IField.cFieldHeight; y++) { for (int x = 0; x < IField.cFieldWidth; x++) { IGhost g = field.getGhost(x, y); if (g == null) { continue; } if (g.getTeamId() == myTeamId) { if (g.getType() == GhostType.Evil) { mMyEvilGhostBit |= Mask(x, y); } else { mMyGoodGhostBit |= Mask(x, y); } } else { mEnemyGhostBit |= Mask(x, y); } } } mEnemyEvilNum = field.getRemainEvilNum(1 - mMyPlayerId); mEnemyGoodNum = field.getRemainGoodNum(1 - mMyPlayerId); }
public PlayersGhost(IGhost ghost, int viewerPlayerId) { Debug.Assert(ghost != null); this.mViewerPlayerId = viewerPlayerId; this.mMasterGhost = ghost; }
public Ghost(IGhost other) { this.mTeamNo = other.getTeamId(); this.mType = other.getType(); }
public static Ghost Create(IGhost g) { return(Create(g.getTeamId(), g.getType())); }