protected static PassiveAct GetRollTo(Direction oldDir, Direction newDir) { int delta = (int)oldDir - (int)newDir; PassiveAct result = (PassiveAct)((delta + 4) % 4); return(result); }
protected Direction GetDirection(Direction dir, PassiveAct roll) { if (roll == PassiveAct.NONE) { return(dir); } return((Direction)(((int)dir + ((int)roll) + 2) % 4)); }
private Move GetKillMonsterMove() { Direction dir = m_info.currentDir; int currRow = m_mapPhysics.cave.row; int currColl = m_mapPhysics.cave.coll; int monsterRow = m_mapPhysics.monsterRow; int monsterColl = m_mapPhysics.monsterColl; PassiveAct passive = GetRollTo(currRow, currColl, dir, monsterRow, monsterColl); return(new Move(passive, ActiveAct.SHOOT)); }
private Move GetToGoldMove() { foreach (Cave dstCave in m_cavesMap.ToList()) { if (dstCave.isGold) { List <Direction> way = new List <Direction>(); if (GetWay(m_mapPhysics.cave, dstCave, ref way, freeLives)) { PassiveAct rotation = GetRollTo(m_info.currentDir, way[0]); return(new Move(rotation, ActiveAct.GO)); } } } return(new Move(GetRandomPassive(), GetRandomActive())); }
private Move GetToMonsterLineMove() { foreach (Cave dstCave in m_cavesMap.ToList()) { if (dstCave.isAvailable && IsOnLineWithMonster(dstCave)) { List <Direction> way = new List <Direction>(); if (GetWay(m_mapPhysics.cave, dstCave, ref way, freeLives)) { PassiveAct rotation = GetRollTo(m_info.currentDir, way[0]); return(new Move(rotation, ActiveAct.GO)); } } } return(GetRandomMove()); }
private string ToRequest(PassiveAct passive, ActiveAct active) { string act = "act="; switch (passive) { case PassiveAct.ON_LEFT: act += "onLeft"; break; case PassiveAct.ON_RIGHT: act += "onRight"; break; case PassiveAct.ROLL: act += "upSideDn"; break; default: act += "noAct"; break; } act += "%20"; switch (active) { case ActiveAct.GO: act += "Go"; break; case ActiveAct.SHOOT: act += "Shoot"; break; case ActiveAct.TAKE: act += "Take"; break; default: act += "noAct"; break; } return(act); }
private Move GetKillMonsterMove() { Cave monsterCave = new Cave(); if (!GetMonsterCave(ref monsterCave)) { throw new GameException("GetKillMonsterMove", "Monster cave not found."); } Direction dir = m_info.currentDir; int row = m_mapPhysics.cave.row; int coll = m_mapPhysics.cave.coll; int mRow = monsterCave.row; int mColl = monsterCave.coll; PassiveAct roll = GetRollTo(row, coll, dir, mRow, mColl); return(new Move(roll, ActiveAct.SHOOT)); }
private Move ScoutTactic() { Cave cave = m_mapPhysics.cave; Direction dir = m_info.currentDir; List <Direction> way = null; if ((m_isScout || GetBestCave(ref m_scoutCell)) && GetBestWay(cave, m_scoutCell, ref way, freeLives)) { PassiveAct rotation = GetRollTo(dir, way[0]); return(new Move(rotation, ActiveAct.GO)); } try { PassiveAct scoutPass = GetRollTo(cave, dir, m_scoutCell); return(new Move(scoutPass, ActiveAct.GO)); } catch (GameException) {} return(GetRandomMove()); }
private Move TryDoFinalShoot(Move finalMove) { Cave currCave = m_mapPhysics.cave; List <Cave> caves = m_cavesMap.GetSemilineCaves(currCave); Cave monsterCave = caves[0]; foreach (Cave cave in caves) { int currentChance = m_cavesMap.GetMonsterChance(cave); int newChance = m_cavesMap.GetMonsterChance(cave); Direction dir = m_info.currentDir; if (newChance != 0 && currentChance >= newChance && !cave.isVisible) { PassiveAct roll = GetRollTo(currCave, dir, cave); finalMove = new Move(roll, ActiveAct.SHOOT); } } return(finalMove); }
private Move TakeTactic() { if (m_mapPhysics.cave.isGold) { Move move = new Move(PassiveAct.NONE, ActiveAct.TAKE); move = TryDoFinalShoot(move); m_cavesMap.ClearMonsterMarks(); return(move); } Cave goldCave = new Cave(); List <Direction> way = new List <Direction>(); if (m_cavesMap.GetGoldCave(ref goldCave) && GetWay(m_mapPhysics.cave, goldCave, ref way, freeLives)) { PassiveAct rotation = GetRollTo(m_info.currentDir, way[0]); return(new Move(rotation, ActiveAct.GO)); } return(GetRandomMove()); }
public Move(PassiveAct passive, ActiveAct active) { this.passive = passive; this.active = active; }