static int Ft_getDimesions(Spot[,] grid) { int glength = grid.Length; int dimensions = Convert.ToInt32(Math.Sqrt(glength)); return(dimensions); }
public GoBoard(int nSize) { InitializeComponent(); this.nSize = nSize; //当前棋盘大小 m_colorToPlay = StoneColor.black; Grid = new Spot[nSize,nSize]; for (int i=0; i<nSize; i++) for (int j=0; j<nSize; j++) Grid[i,j] = new Spot(); penGrid = new Pen(Color.Brown, (float)0.5); penStoneW = new Pen(Color.WhiteSmoke, (float)1); penStoneB = new Pen(Color.Black,(float)1); penMarkW = new Pen(Color.Blue, (float) 1); penMarkB = new Pen(Color.Beige, (float) 1); brStar = new SolidBrush(Color.Black); brBoard = new SolidBrush(Color.Orange); brBlack = new SolidBrush(Color.Black); brWhite = new SolidBrush(Color.White); m_brMark = new SolidBrush(Color.Red); rGrid = new Rectangle(nEdgeLen, nEdgeLen,nTotalGridWidth, nTotalGridWidth); strLabels = new string [] {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t"}; gameTree = new GoTree(); }
public void AddNeighboors(Spot[,] grid, int x, int y) { if (x < grid.GetUpperBound(0)) { neighboors.Add(grid[x + 1, y]); } if (x > 0) { neighboors.Add(grid[x - 1, y]); } if (y < grid.GetUpperBound(1)) { neighboors.Add(grid[x, y + 1]); } if (y > 0) { neighboors.Add(grid[x, y - 1]); } #region diagonal //if (X > 0 && Y > 0) // Neighboors.Add(grid[X - 1, Y - 1]); //if (X < Utils.Columns - 1 && Y > 0) // Neighboors.Add(grid[X + 1, Y - 1]); //if (X > 0 && Y < Utils.Rows - 1) // Neighboors.Add(grid[X - 1, Y + 1]); //if (X < Utils.Columns - 1 && Y < Utils.Rows - 1) // Neighboors.Add(grid[X + 1, Y + 1]); #endregion }
private void CreateBoard() { logicalBoard = new Spot[boardSize, boardSize]; spotsRevealed = 0; //create buttons for (int i = 0; i < boardSize * boardSize; ++i) { Button button = new Button() { Tag = i //i/boardsize is line, i%boardsize is column }; //set button's background BitmapImage bitimg = new BitmapImage(); bitimg.BeginInit(); bitimg.UriSource = new Uri(@"Images/square.png", UriKind.RelativeOrAbsolute); bitimg.EndInit(); Image img = new Image(); img.Stretch = Stretch.Fill; img.Source = bitimg; button.Background = new ImageBrush(bitimg); //function to handle button click event button.Click += new RoutedEventHandler(button_clicked); //add button to board board.Children.Add(button); //init spot in logicalboard logicalBoard[i / boardSize, i % boardSize] = new Spot(); } AddMines(); }
public static void PoliceAction(this Spot[,] spots, SpotTypes type) { Collection <Spot> spotsoftype = new Collection <Spot>(); foreach (var spot in spots) { if (spot.SpotTypes == type) { spotsoftype.Add(spot); } } var OnAction = spotsoftype.OrderBy(x => Guid.NewGuid()).First(); if (type == SpotTypes.Factory) //factory { var factory = OnAction.Cast <Factory>(); if (factory.IsItem) { factory.Item = default; } } else // storage { var storage = OnAction.Cast <Storage>(); if (storage.IsItem) { storage.Items.Dequeue(); } } }
//private List<Field> flds; public Field(int nr, Text myText) { rows = 4; columns = 4; fieldText = myText; Fieldnr = nr; //Debug.Log("Field>" + nr); spots = new Spot[rows, columns]; //et 'Field' er på rows x columns punkter (egentlig ca 20x200) for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { spots[i, j] = new Spot(nr, i, j, myText); if ((i == 0) && (j == 0)) { spots[i, j].Marked = true; } } } //default valgt verdi som kan oppdateres til wievet Graf.ChosenSpot = spots[0, 0]; }
public Soldier(Role role, bool white, Spot currentSpot, Spot[,] map) { this.role = role; this.currentSpot = currentSpot; this.white = white; this.map = map; }
public Chess() { teams = new Team[2]; map = new Spot[8, 8]; for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { ConsoleColor color; if ((i + j) % 2 == 0) { color = ConsoleColor.Gray; } else { color = ConsoleColor.DarkYellow; } Vector2 offset = new Vector2(30, 1); map[i, j] = new Spot(new Vector2(4 * i, 2 * j) + offset, 2, new Vector2(i, j), color); } } teams[0] = new Team(true, map); teams[1] = new Team(false, map); for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { map[i, j].PrintRole(); } } }
public Board(int row, int col) { Spots = new Spot[row, col]; RowCount = row; ColCount = col; Reset(); }
public Mineral(int width, int height) { this.width = width; this.height = height; fullMineral = new Spot[width, height]; FillMineral(); }
static void Reader(StreamReader sr) { List <string> newlines = new List <string>(); string toAdd = null; string[] tmp = null; List <string> ntmp; int y = 2; do { toAdd = sr.ReadLine(); if (toAdd != null && toAdd != "") { newlines.Add(toAdd); } } while (toAdd != null); dimentions = Convert.ToInt32(newlines[1]); inputGrid = InitializeGrid(dimentions); for (int i = 0; i < dimentions; i++) { tmp = newlines[y].Split(' '); ntmp = tmp.ToList <string>(); ntmp.RemoveAll(p => string.IsNullOrEmpty(p)); tmp = ntmp.ToArray(); for (int j = 0; j < dimentions; j++) { inputGrid[i, j].value = tmp[j]; } y++; } }
public Map(int h, int w) { height = h; width = w; coor = new Spot[height, width]; initializeMap(); }
Spot[,] Spots; //массив блоков public Field(float X, float Y, float Width, float Height, int n, Bitmap bitmap, int Mistery) : base(X, Y, Width, Height, bitmap) { Spots = new Spot[n, n]; int count = 1; //создаём пятнашки for (int i = 0; i < Spots.GetLength(0); i++) { for (int j = 0; j < Spots.GetLength(1); j++) { //счётчик if (count == n * n) { count = 0; //если дошли до конца, то обнуляем счётчик, чтобы создать нулевой (пустой) блок } //создаём новый блок Spots[i, j] = new Spot(i * (Width / n), j * (Height / n), Width / n, Height / n, count++, null); //создаём новую картинку для блока. метод Clone копирует картинку либо её часть. if (bitmap != null) { Spots[i, j].BITMAP = bitmap.Clone( new RectangleF( //размеры копируемой части j * bitmap.Width / n, //х i * bitmap.Height / n, //у bitmap.Width / n, //ширина bitmap.Height / n), //высота System.Drawing.Imaging.PixelFormat.DontCare //формат пикселей ); } } } //перемешиваем блоки Random R = new Random(); for (int c = 0; c < n * n; c++) { //случайные индексы блоков 1 и 2 int ri1 = R.Next(n); int rj1 = R.Next(n); int ri2 = R.Next(n); int rj2 = R.Next(n); //меняем местами блоки координаты блоков Spots[ri1, rj1].Rearrange(Spots[ri2, rj2]); if (Mistery > 0 && Spots[ri1, rj1].Index > 0) { Spots[ri1, rj1].ShowIndex = false; Mistery--; } //меняем местами расположение блоков в массиве SwapSpots(ri1, rj1, ri2, rj2); } }
public Board(Difficulty difficulty) { this.difficulty = difficulty; int spots = difficulty.GetSpots(); this.spotlist = new Spot[spots, spots]; }
public void Clear() { foreach (Spot s in spots) if (s != null) s.traceBack = null; spots = null; }
public Spot CheckNeighbors(Spot[,] grid) { int i = this.i; int j = this.j; neighbors = new List <Spot>(); Spot right, up, down, left; if (i < cols - 1) { //right adjacent spot right = grid[i + 1, j]; if (right != null && !right.visited) { neighbors.Add(right); } } if (i > 0) { left = grid[i - 1, j]; //left adjacent spot if (left != null && !left.visited) { neighbors.Add(left); } } if (j < rows - 1) { down = grid[i, j + 1]; //down adjacent spot if (down != null && !down.visited) { neighbors.Add(down); } } if (j > 0) { up = grid[i, j - 1]; //up adjacent spot if (up != null && !up.visited) { neighbors.Add(up); } } if (neighbors.Count > 0) { RNGCryptoServiceProvider Rand = new RNGCryptoServiceProvider(); var r = RandomInteger(Rand, 0, neighbors.Count); return(neighbors[r]); } else { return(null); } }
public LocalGame(Spot[,] spots, bool enabled, Location loc) : base(enabled) { this.loc = loc; this.spots = spots; Outline = Color.clear; PopulateOwnerArray(spots); CheckWinner(); }
public GraphChunk(float base_x, float base_y, int ix, int iy) { this.base_x = base_x; this.base_y = base_y; this.ix = ix; this.iy = iy; spots = new Spot[CHUNK_SIZE, CHUNK_SIZE]; modified = false; }
// Use this for initialization void Start() { //her kommer tillegg zpots = Field.Spots; //waterMM = zpots[0, 0].WaterMM; //air = zpots[0, 0].Air; GameObject graphGO = GameObject.Instantiate(emptyGraphPrefab); graphGO.transform.SetParent(this.transform, false); graph = graphGO.GetComponent <WMG_Axis_Graph>(); graph.Init(); series1 = graph.addSeries(); graph.xAxis.AxisMaxValue = 28; if (useData2) { List <string> groups = new List <string>(); List <Vector2> data = new List <Vector2>(); for (int i = 0; i < series1Data2.Count; i++) { string[] row = series1Data2[i].Split(','); groups.Add(row[0]); if (!string.IsNullOrEmpty(row[1])) { float y = float.Parse(row[1]); data.Add(new Vector2(i + 1, y)); } } graph.groups.SetList(groups); graph.useGroups = true; graph.xAxis.LabelType = WMG_Axis.labelTypes.groups; graph.xAxis.AxisNumTicks = groups.Count; series1.seriesName = "Fruit Data"; series1.UseXDistBetweenToSpace = true; series1.pointValues.SetList(data); graph.Refresh(); } else { series1.pointValues.SetList(series1Data); } } //Start()
public Board() { spot = new Spot[8, 8]; player = new Player(); this.ResetBoard(); pieceAlreadySelected = false; mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>(); blackSideCamera = GameObject.Find("BlackSideCamera").GetComponent <Camera>(); }
void PopulateOwnerArray(Spot[,] spots) { ownerArray = new Player[spots.GetLength(0), spots.GetLength(1)]; foreach (Spot spot in spots) { spot.OwnerChanged += HandleSpotOwnerChanged; HandleSpotOwnerChanged(spot, null); // populate array spot.LocalGame = this; } }
public void Clear() { foreach (Spot s in spots) { if (s != null) { s.traceBack = null; } } spots = null; }
public Grid(int size) { _sideLength = size; _grid = new Spot[size, size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { _grid[i, j] = new Spot(); } } }
private Spot getSpot(Spot[,] spots, int x, int y) { Spot spot; if (x >= spots.GetLength(0) || x < 0 || y >= spots.GetLength(1) || y < 0) { return(null); } spot = spots[x, y]; return(spot); }
static void Main(string[] args) { StreamReader sr = new StreamReader(@"text.txt"); Reader(sr); endGrid = Ft_expectedOutcome(dimentions); Draw(inputGrid); Solve(); //OverrollPath.RemoveAll(p => string.IsNumber(0)); Console.WriteLine("Moves made : {0}", OverrollPath.Count); Console.ReadLine(); }
private void Awake() { _boardData = new Symbol[BoardSize, BoardSize]; _spots = new Spot[BoardSize, BoardSize]; var allSpots = GetComponentsInChildren <Spot>(); foreach (var spot in allSpots) { _spots[spot.Line, spot.Column] = spot; } _currentPlayer = StartingSymbol; }
static void Draw(Spot[,] grid) { int dimensions = Ft_getDimesions(grid); //Console.Clear(); for (int row = 0; row < dimensions; row++) { for (int col = 0; col < dimensions; col++) { Console.Write("{0,2} ", grid[row, col].value); } Console.Write("\n"); } Console.WriteLine(""); }
public Warehouse(Controller controller) { this._controller = controller; A.Name = "A"; B.Name = "B"; C.Name = "C"; _field = new Spot[_x, _y]; spots = new List <Spot>(); selectedSwitch = new Dictionary <char, SwitchRail>(); selectedSwitch.Add('q', s1); selectedSwitch.Add('w', s2); selectedSwitch.Add('e', s5); selectedSwitch.Add('a', s3); selectedSwitch.Add('s', s4); createWarehouse(); }
public SocialSpace(int size) { Size = Rows = Cols = size; _space = new Spot[Rows, Cols]; for (int r = 0; r < size; r++) { for (int c = 0; c < size; c++) { _space[r, c] = new Spot() { Row = r, Col = c } } } ; }
/// <inheritdoc /> public void Initialize() { this.Board.Player1OffBoardStones = 8; this.Board.Player2OffBoardStones = 8; int dimension = this.Board.DimensionCount; for (int levelIndex = 0; levelIndex < this.Board.LevelCount; levelIndex++) { Spot[,] level = this.Board.Spots[levelIndex] = new Spot[dimension, dimension]; for (int xIndex = 0; xIndex < dimension; xIndex++) { for (int yIndex = 0; yIndex < dimension; yIndex++) { level[xIndex, yIndex] = new Spot(null); } } } }
public Grid(int[,] array) { gridCountX = array.GetLength(0); gridCountY = array.GetLength(1); grid = new Spot[gridCountX, gridCountY]; for (int x = 0; x < gridCountX; x++) { for (int y = 0; y < gridCountY; y++) { bool walkable = array[x, y] == 0; grid[x, y] = new Spot(x, y, walkable); } } m_count = gridCountX * gridCountY; }
public SocialSpace(int rows, int cols) { Rows = rows; Cols = cols; _space = new Spot[Rows, Cols]; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { _space[r, c] = new Spot() { Row = r, Col = c } } } ; }
public GuiMatrix(CoreMatrix coreMatrix) { oldFocused = new Point(int.MaxValue, int.MaxValue); oldSelected = new Point(int.MaxValue, int.MaxValue); sMatrix = new Spot[8, 8]; Position pos = new Position(); for (pos.X = 0; !pos.errorFlag; pos.X++) { for (pos.Y = 0; !pos.errorFlag; pos.Y++) { if ((pos.X + pos.Y) % 2 != 0) { try { sMatrix[pos.X, pos.Y] = new Spot(pos.X, pos.Y, Color.CadetBlue, coreMatrix.FigureAt(pos).image); } catch (System.NullReferenceException) { sMatrix[pos.X, pos.Y] = new Spot(pos.X, pos.Y, Color.CadetBlue, null); } } else { try { sMatrix[pos.X, pos.Y] = new Spot(pos.X, pos.Y, Color.White, coreMatrix.FigureAt(pos).image); } catch (System.NullReferenceException) { sMatrix[pos.X, pos.Y] = new Spot(pos.X, pos.Y, Color.White, null); } } } } }