private static CellState[,] InitializeForestFire(int height, int width) { // Create our state array, initialize all indices as Empty, and return it. var state = new CellState[height, width]; state.Initialize(); return state; }
private Brush GetCellBrush(CellState state) { if (state == CellState.Live) return this.liveCellStyle ?? (this.liveCellStyle = Application.Current.FindResource("LiveCellBrush") as Brush); return this.deadCellStyle ?? (this.deadCellStyle = Application.Current.FindResource("DeadCellBrush") as Brush); }
public GameTile (GameObject tile, int x, int y) { Go = tile; cellState = CellState.WhiteHidden; locX = x; locY = y; }
public void SetCell( CellState cs, int row, int col ) { Util.RangeCheck(row, 1, width); Util.RangeCheck(col, 1, width); d_board[ToIndex(row), ToIndex(col)] = cs; }
public PlaceRecordItem( OverturnableInfo placeAndTurnableInfo, CellState stoneColor) { PlaceAndTurnableInfo = placeAndTurnableInfo; StoneColor = stoneColor; }
public void move_to_next() { hasChanges = state == next_state ? false : true; last_state = state; state = next_state; next_state = CellState.Unknown; }
public int DrainEnergy() { if (State != CellState.Dead) { Energy--; if (Energy <= 4) { State = CellState.Sick; } if (Energy <= 0) { SoundManager.PlaySound(GameAssets.CellDeadSound, Position, 1F); State = CellState.Dead; this.Tint = new Color(50, 50, 50, 128); GameStats.IncrementDeadCellCount(); } return 1; } else { return 0; } }
public static CellState[,] GenerateSong(Automatone automatone, Random random, MusicTheory theory) { InputParameters.Instance.Tempo = (ushort)(theory.MIN_TEMPO + InputParameters.Instance.SongSpeed * (theory.MAX_TEMPO - theory.MIN_TEMPO)); InputParameters.Instance.TimeSignatureN = (int)(2 + random.NextDouble() / 4 * (13 - 2)); InputParameters.Instance.TimeSignatureD = (int)Math.Pow(2, (int)(1 + random.NextDouble() * 2)); Song s = new Song(theory, random); NoteThread thread = new NoteThread(s.Notes, InputParameters.Instance.TimeSignature); int gridWidth = s.MeasureCount * s.MeasureLength; CellState[,] grid = new CellState[Automatone.PIANO_SIZE,gridWidth]; foreach (List<Note> nts in s.Notes) { foreach (Note n in nts) { grid[n.GetOctave() * MusicTheory.OCTAVE_SIZE + n.GetNoteName().ChromaticIndex - Automatone.LOWEST_NOTE_CHROMATIC_NUMBER, (int)Math.Min(n.GetStartMeasure() * s.MeasureLength + n.GetStartBeat() * Automatone.SUBBEATS_PER_WHOLE_NOTE, gridWidth - 1)] = CellState.START; for (int i = 1; i < n.GetRemainingDuration() * Automatone.SUBBEATS_PER_WHOLE_NOTE; i++) { if (grid[n.GetOctave() * MusicTheory.OCTAVE_SIZE + n.GetNoteName().ChromaticIndex - Automatone.LOWEST_NOTE_CHROMATIC_NUMBER, (int)Math.Min(n.GetStartMeasure() * s.MeasureLength + n.GetStartBeat() * Automatone.SUBBEATS_PER_WHOLE_NOTE + i, gridWidth - 1)] == CellState.SILENT) { grid[n.GetOctave() * MusicTheory.OCTAVE_SIZE + n.GetNoteName().ChromaticIndex - Automatone.LOWEST_NOTE_CHROMATIC_NUMBER, (int)Math.Min(n.GetStartMeasure() * s.MeasureLength + n.GetStartBeat() * Automatone.SUBBEATS_PER_WHOLE_NOTE + i, gridWidth - 1)] = CellState.HOLD; } } } } automatone.MeasureLength = s.MeasureLength; return grid; }
/// <summary> /// In this constructor main cycle is performed /// </summary> /// <param name="fold">path to game folder</param> /// <param name="player">player symbol</param> /// <param name="time">permited time</param> public Program(string fold, CellState player, int time) { start = DateTime.Now; Field field = new Field(fold); int delta = 0; # if DEBUG delta = (new Random()).Next(Field.SIZE);//col shift, makes game more different #endif Solution root = new Solution(field, Solution.invertCell(player)); for (int i = 0; i < Field.SIZE; i++) { Solution buf = new Solution(root, (i + delta) % Field.SIZE); branch[i] = buf; if (!buf.isFinalized) que.Enqueue(buf); } while ((DateTime.Now - start).TotalMilliseconds + 300 < time && que.Count != 0)//main cycle Solve(que.Dequeue()); Solution max = branch[0]; for (int i = 1; i < Field.SIZE; i++) if (branch[i] != null) max = branch[i].isGreater(max); int turn = Directory.GetFiles(fold).Length / 2 + 1; string path = fold + (player == CellState.Cross ? "X" : "O") + turn.ToString() + ".txt"; File.WriteAllLines(path, new String[] { max.getTurn() }); }
public Cell(Texture2D texture, Rectangle drawBounds) : base(texture, drawBounds) { this.Type = SpriteType.Cell; this.Energy = 7; this.State = CellState.Living; }
public void Clicked(CellController cell) { if (!Attack) { switch (this.state) { case CellState.None: if (SelectedCells.Count < ShipAmount.TotalCellAmount) { this.state = CellState.Selected; SelectedCells.Add(this); } break; case CellState.Selected: this.state = CellState.None; SelectedCells.Remove(this); break; } this.Invalidate(); } else { if (!Locked) { if (EnemyCell) { state = CellState.Selected; Invalidate(); ShipAmount.TotalCellAmount--; } MainController.DoAttack(); } } }
public static void Render(object item, int count, bool isExpanded, IDrawingToolkit tk, IContext context, Area backgroundArea, Area cellArea, CellState state) { if (item is EventType) { RenderAnalysisCategory (item as EventType, count, isExpanded, tk, context, backgroundArea, cellArea); } else if (item is SubstitutionEvent) { SubstitutionEvent s = item as SubstitutionEvent; RenderSubstitution (s.Color, s.EventTime, s.In, s.Out, s.Selected, isExpanded, tk, context, backgroundArea, cellArea, state); } else if (item is TimelineEvent) { TimelineEvent p = item as TimelineEvent; RenderPlay (p.Color, p.Miniature, p.Players, p.Selected, p.Description, count, isExpanded, tk, context, backgroundArea, cellArea, state); } else if (item is Player) { RenderPlayer (item as Player, count, isExpanded, tk, context, backgroundArea, cellArea); } else if (item is Playlist) { RenderPlaylist (item as Playlist, count, isExpanded, tk, context, backgroundArea, cellArea); } else if (item is PlaylistPlayElement) { PlaylistPlayElement p = item as PlaylistPlayElement; RenderPlay (p.Play.EventType.Color, p.Miniature, null, p.Selected, p.Description, count, isExpanded, tk, context, backgroundArea, cellArea, state); } else if (item is IPlaylistElement) { IPlaylistElement p = item as IPlaylistElement; RenderPlay (Config.Style.PaletteActive, p.Miniature, null, p.Selected, p.Description, count, isExpanded, tk, context, backgroundArea, cellArea, state); } else { Log.Error ("No renderer for type " + item.GetType ()); } }
public override Point SelectBestCell(CellState color) { foreach(Point attempt in Board.EnumerateCells()) { if(Board.GetStone(attempt) == CellState.None) return attempt; } return Draw; }
public OverTurnStonesPhase(CellState colorToTurn) { _placePos = new System.Drawing.Point(-1, -1); _turnPosList = new List<System.Drawing.Point>(); _colorToTurn = colorToTurn; Init(); }
// Update is called once per frame void Update() { // なにやら蠢く感じを出したいなぁと思ってとりあえず回してみる transform.Rotate (1.0f, 1.0f, 1.0f); switch(m_State) { case CellState.CELL_STATE_BORN: // 生まれた時は 1.0 の大きさになるまでは膨らみます m_Size += 0.1f; if(m_Size > 1.0f) { m_Size = 1.0f; m_State = CellState.CELL_STATE_IDLE; } transform.localScale = new Vector3(m_Size, m_Size, m_Size); break; case CellState.CELL_STATE_DEATH: // 死ぬときは 0.0 以下になるまで縮みます. m_Size -= 0.1f; if(m_Size < 0.0f) { m_Size = 0.0f; Destroy(gameObject); } transform.localScale = new Vector3(m_Size, m_Size, m_Size); break; default: // 通常時は特に膨らみもしぼみもしません. break; } }
private Value v; // Up to date if state==Uptodate public Formula(Workbook workbook, Expr e) { Debug.Assert(workbook != null); Debug.Assert(e != null); this.workbook = workbook; this.e = e; this.state = CellState.Uptodate; }
public Cell(int r, int c) { rowPos = r; colPos = c; state = CellState.empty; connectCells = new SortedDictionary<int, List<Cell>>(); observers = new SortedDictionary<int, HashSet<Cell>>(); }
public CellState GetOpponentColor(CellState myColor) { if(myColor == CellState.White) return CellState.Black; if(myColor == CellState.Black) return CellState.White; throw new ArgumentException(); }
public void Reset() { g = 0; h = 0; parent = null; State = CellState.Empty; Path = PathState.None; }
public DefaultCell(int x, int y, CellState state) { this.state = state; next_state = CellState.Unknown; last_state = CellState.Unknown; this.location = location; location = new XY(x, y); hasChanges = false; }
//Copy Constructor public Cell(Cell cell) { rowPos = cell.rowPos; colPos = cell.colPos; playable = cell.isPlayable(); state = cell.state; connectCells = new SortedDictionary<int, List<Cell>>(); observers = new SortedDictionary<int, HashSet<Cell>>(); }
internal void changeState() { if (nextState == CellState.Null) { throw new Exception("Cannot change state while nextState is CellState.Null"); } this.currentState = this.nextState; this.nextState = CellState.Null; }
public Group( int row, int col, CellState cs ) { d_lowerLeftBound = Tuple.Create(row, col); d_upperRightBound = Tuple.Create(row, col); d_color = cs; d_members = new List<Tuple<int, int>>(); AddCore(row, col); }
internal void determineNextState() { Dictionary<String, Cell> neighbors = getNeighborList(); nextState = (Cell.CellState)rule.ruleIndex[ (int)currentState, (int)neighbors["Up"].State, (int)neighbors["Right"].State, (int)neighbors["Down"].State, (int)neighbors["Left"].State]; }
public void ShouldCountTheBombsAround() { var board = new Board(2); board.AddBombAt(1, 1); var result = board.Open(1, 0); var cell = new Cell(new CellContents(false), new Position(1, 0)); cell.Open(); var expectedResult = new CellState(cell, 1); Assert.AreEqual(expectedResult, result); }
internal IComparable EstimateForStageOne(Point location, CellState color) { int selfScore = 1 + CalcScore(location, color); int opponentScore = 1 + CalcScore(location, GetOpponentColor(color)); if(selfScore >= GameSize) selfScore = int.MaxValue; return Math.Max(selfScore, opponentScore); }
public OverTurnStonesPhase(System.Drawing.Point placePos, System.Drawing.Point[] turnPosArray, CellState colorToTurn) { _placePos = placePos; _turnPosList = turnPosArray.ToList(); _colorToTurn = colorToTurn; _turnPosList.Add(_placePos); Init(); }
/// <summary> /// Initializes a new <see cref="CAEnvironment"/> object. /// </summary> /// <param name="size">The size of the grid.</param> /// <param name="endless">Is the grid endless.</param> /// <param name="ruleName">The name of the rule, which will operate.</param> /// <param name="neighbourhoodName">The name of the neighbourhood for all <see cref="Cell"/> objects.</param> /// <param name="ruleArgs">If needed - arguments for initializing a <see cref="IRule"/> object.</param> public CAEnvironment(Size size, bool endless, string ruleName, string neighbourhoodName, object[] ruleArgs) { Size = size; Endless = endless; _rule = RuleFactory.Create(ruleName, ruleArgs); _neighbourhood = NeighbourhoodFactory.Create(neighbourhoodName); States = new CellState(); StatesNew = new CellState(); }
public static Brush GetStoneImageBrush(CellState stoneColor) { if (stoneColor == CellState.Black) { return GetBlackStoneImageBrush(); } else { return GetWhiteStoneImageBrush(); } }
public Tile(Sprite2D sprite, int i, int j) { State = CellState.None; sprite.OnMouseUp += OnMouseUp; this.AddChild(sprite); this.i = i; this.j = j; this.sprite = sprite; Global.gMouseHelper.Register(sprite); }
public void Empty() { state = CellState.EMPTY; }
public void Fill() { state = CellState.FILLED; }
public static bool HasFlag(this CellState cs, CellState flag) { return(((int)cs & (int)flag) != 0); }
public static CellState OppositeWall(this CellState orig) { return((CellState)(((int)orig >> 2) | ((int)orig << 2)) & CellState.Initial); }
public void Harvest() { state = CellState.Empty; progress = 0; }
public void Plant() { state = CellState.Planted; progress = 1; }
public void Harvest() { state = CellState.Empty; currentTime = 0; }
/// <summary> /// Constructor. /// Creates a cell with the provided state. /// </summary> public Cell(CellState cellState) { _cellState = cellState; }
public void NotifyFireResult(CellState state) { _output.WriteLine(state == CellState.Hit ? "Hit!" : "Miss!"); }
public void SwitchState() { state = (state == CellState.EMPTY) ? CellState.FILLED : CellState.EMPTY; }
public CellMovement(CellState state) { CurrentState = state; }
private void Visit(CellState startCellState) { startCellState.Visited = true; count++; startCellState.DfsDepth = count; startCellState.DfsLow = count; foreach (CellState adjacentCellState in startCellState.GetAdjacentCellStates()) { if (adjacentCellState.ClosestPlayer == player && (adjacentCellState.OccupationStatus == OccupationStatus.Clear || adjacentCellState.OccupationStatus == playerOccupationStatus)) { if (!adjacentCellState.Visited) { Edge newEdge = new Edge { StartVertex = startCellState, EndVertex = adjacentCellState }; edgeStack.Push(newEdge); adjacentCellState.ParentCellState = startCellState; Visit(adjacentCellState); if (adjacentCellState.DfsLow >= startCellState.DfsDepth) { // Create a chamber Chamber chamber = new Chamber(nextChamberNumber); nextChamberNumber++; startCellState.GameState.AddChamber(chamber, player); Edge poppedEdge = null; do { poppedEdge = edgeStack.Pop(); chamber.AddCell(poppedEdge.StartVertex); chamber.AddCell(poppedEdge.EndVertex); poppedEdge.StartVertex.AddChamber(chamber, player); poppedEdge.EndVertex.AddChamber(chamber, player); }while (poppedEdge != newEdge); } if (adjacentCellState.DfsLow < startCellState.DfsLow) { startCellState.DfsLow = adjacentCellState.DfsLow; } } else if (!(adjacentCellState.ParentCellState == startCellState) && (adjacentCellState.DfsDepth < startCellState.DfsDepth)) { // The link from startCellState to adjacentCellState is a back edge to an ancestor of startCellState: Edge backEdge = new Edge { StartVertex = startCellState, EndVertex = adjacentCellState }; edgeStack.Push(backEdge); if (adjacentCellState.DfsDepth < startCellState.DfsLow) { startCellState.DfsLow = adjacentCellState.DfsDepth; } } } } }
public void SetCell(CellState value, CubeKey dims) { Cells[dims.ToString()] = value; UpdateRanges(dims); }
public void MakeTurn(Player.PlayerColor color, CellState state) { if (CellAlive(state)) { if (!game.sacrifice) { cellState = CellState.DEAD; game.finishedMove = true; } else if (Game.TurnMatchesColor(color, state)) { cellState = CellState.DEAD; if (!game.newCell.halfEmpty) { game.newCell.halfEmpty = true; } else { game.newCell.cellState = state; game.newCell.halfEmpty = false; game.sacrifice = false; game.finishedMove = true; } } } else { if (!game.sacrifice) { if (game.currentPlayer.playerColor == Player.PlayerColor.BLUE) { cellState = CellState.BORN_BLUE; } else { cellState = CellState.BORN_READ; } game.newCell = this; game.sacrifice = true; } else { if ((cellState == CellState.BORN_READ || cellState == CellState.BORN_BLUE) && !halfEmpty) { cellState = CellState.DEAD; game.sacrifice = false; } else if (cellState == CellState.DEAD && !game.newCell.halfEmpty) { game.newCell.cellState = CellState.DEAD; game.newCell = this; if (game.currentPlayer.playerColor == Player.PlayerColor.BLUE) { cellState = CellState.BORN_BLUE; } else { cellState = CellState.BORN_READ; } } } } }
/// <summary> /// Default constructor. /// </summary> public Cell() { _cellState = CellState.Dead; }
public Cell() { state = CellState.BLOCKED; }
public void Plant() { state = CellState.Planted; }
public int SumOfAliveCells() { int total = 0; CellState cell = CellState.Alive; for (int i = 0; i < gridWidth; i++) { for (int j = 0; j < gridHeight; j++) { if (cell.Equals('1')) { total += 1; } } } return(total); //grH = gridHeight; //grW = gridWidth; ////List<int>[] lst = new List<int>[CellState.Dead]; //int activeCells = (int)CellState.Alive; //int total = grH + grW; //List[] lst = new List[gridWidth, gridHeight]; //foreach (var item in LifeGrid) //{ //} //Console.WriteLine($"total : {total}"); //Dictionary<int, LifeGrid> customers = new Dictionary<int, LifeGrid>(); //foreach (var item in gridWidth) //{ // Console.WriteLine("active cellss:"); //} //int total = 0; //for (int i = 0; i < gridWidth; i++) //{ // if (i == customers.ce) // total += activeCells; //} //return total; //return activeCells; //foreach (var item in LifeGrid) //{ //} //foreach (CellState cells in CellState.GetValues(CellState.Dead)) //{ // if // total += (int)cells; //} // for (int i = 0; i < gridHeight; i++) // for (int j = 0; j < gridWidth; j++) // { // CurrentState[i, j] = CellState.Dead; // total += activeCells; // } // return total; //} //foreach (var state in currentState) //{ // output.Append(state == CellState.Alive ? "1" : "."); // x++; // if (x >= rowLength) // { // x = 0; // output.AppendLine(); // } }
public void SetShowPersonOnBar(Texture2D faceTex, CellState role) { this.showPersonFace = (faceTex == null ? false : true); this.role = role; this.personMenuCallerBtn.BtnTexture = faceTex; }
public void UpdateTilesStateWithOffset(Deployable deployableObject, IntVector2 cellIndex, CellState newState) { for (int i = 0; i < deployableObject.TileMap.TileSize.X; i++) { for (int j = 0; j < deployableObject.TileMap.TileSize.Y; j++) { int posX = i + cellIndex.X - deployableObject.TileMap.TileOffset.X; int posY = -j + cellIndex.Y + deployableObject.TileMap.TileOffset.Y; if (posX < Rows && 0 <= posX && posY < Columns && 0 <= posY) { int index = CalculateIndex(posX, posY); Cells[index].IsEmpty = newState.ToBool(); if (newState == CellState.Empty) { Cells[index].InCellObject = null; } else if (newState == CellState.Full) { Cells[index].InCellObject = deployableObject; } } } } }
/// <summary> /// Constructor /// </summary> /// <param name="position">Position on a grid where the step is being made</param> /// <param name="previouState">State of the cell before the step is made</param> /// <param name="newState">State of the cell after the step is made</param> public Step(Point position, CellState previouState, CellState newState) { Position = position; FromState = previouState; ToState = newState; }
public HumanPlayer(Field field, CellState playerState) { PlayerCellState = playerState; Field = field; }
public Cell(int x, int y, int z, CellState state = CellState.Inactive, int w = 0) : this(x, y, z, w, state) { }
public Cell(int matchId) { MatchId = matchId; state = CellState.HIDDEN; }
void SetCellState(int x, int y, CellState state) { cellState[x - MIN_X, y - MIN_Y] = state; }
public static Bitmap Image(CellState state) => table[state];
public Organic(CellState state) => State = state;
public Cell(int xAxis, int yAxis, CellState cellState = CellState.Dead) { _cellState = cellState; XAxis = xAxis; YAxis = yAxis; }
public Cell(bool isMine) { this.isMine = isMine; this.state = CellState.Hidden; this.adjacentMines = 0; }
public void NextState() { cellState = nextCellState; }