public Attempt(bool hit, GridSize size, Point targetCell, Point pointer) { Hit = hit; Size = size; TargetCell = targetCell; Pointer = pointer; }
public static void DrawHeatMap(List<Attempt> attempts, GridSize size, out MemoryStream stream) { stream = new MemoryStream(); Bitmap heatMap = HeatMap(attempts, size); heatMap.Save(stream, ImageFormat.Png); heatMap.Dispose(); }
public static String ResolveSize(GridSize gridSize) { switch (gridSize) { case GridSize.span1: return "col-md-1"; case GridSize.span2: return "col-md-2"; case GridSize.span3: return "col-md-3"; case GridSize.span4: return "col-md-4"; case GridSize.span5: return "col-md-5"; case GridSize.span6: return "col-md-6"; case GridSize.span7: return "col-md-7"; case GridSize.span8: return "col-md-8"; case GridSize.span9: return "col-md-9"; case GridSize.span10: return "col-md-10"; case GridSize.span11: return "col-md-11"; case GridSize.span12: return "col-md-12"; } return "col-md-2"; }
public Layout(ViewContext view, GridSize layoutSize) { this.ViewContext = view; this.Component = new LayoutComponent(); this.Component.HtmlProperties = new HtmlProperties(view, this.Component.GetType()); this.Component.InnerHtml = String.Empty; this.ContainerElements = new Collection<ISushiComponentBuilder>(); this.Component.LayoutSize = layoutSize; }
public void GetChunk_DoesntExist() { var chunkSize = new GridSize(4); var world = new World(chunkSize); var chunkPosition = new ChunkPosition(15, 129, 63); var chunk = world.GetChunk(chunkPosition); Assert.IsNull(chunk); Assert.IsFalse(world.DoesChunkExist(chunkPosition)); }
public static IGraphMesh Construct(GraphMeshKind kind, GridSize size) { switch (kind) { case GraphMeshKind.Triangluar: return new TriangleGraphMesh(size); case GraphMeshKind.Histogram: return new HistogramGraphMesh(size); ; default: throw new ArgumentOutOfRangeException(nameof(kind), kind, "Unknown graph mesh kind provided"); } }
public void GetChunk_AlreadyExists() { var chunkSize = new GridSize(4); var world = new World(chunkSize); var chunkPosition = new ChunkPosition(17, -1000, 8); var chunk1 = world.CreateChunk(chunkPosition); var chunk2 = world.CreateChunk(chunkPosition); Assert.AreSame(chunk1, chunk2); Assert.IsTrue(world.DoesChunkExist(chunkPosition)); }
public GridController() { _gameManager = InjectBox.Get <GameManager>(); _levelData = InjectBox.Get <LevelData>(); _poolManager = InjectBox.Get <PoolManager>(); _cellPrefab = Resources.Load <GameObject>("Prefabs/Cell"); _gridParent = GameObject.Find("Grid").GetComponent <Transform>(); _cells = new List <Cell>(); _gridSize = _levelData.GetSize(_gameManager.CurrentLevel); }
public ConfigEntity SetMapSize(GridSize newValue) { if (hasMapSize) { throw new Entitas.EntitasException("Could not set MapSize!\n" + this + " already has an entity with MapSizeComponent!", "You should check if the context already has a mapSizeEntity before setting it or use context.ReplaceMapSize()."); } var entity = CreateEntity(); entity.AddMapSize(newValue); return(entity); }
// Use this for initialization void Start() { tuts.text = "Press A & D or LEFT ARROW && RIGHT ARROW \nto move"; gs = FindObjectOfType <GridSize>(); g = FindObjectOfType <GridScript>(); FindObjectOfType <T_PlayerMovement>().disableRespawn = true; player = GameObject.FindGameObjectWithTag("Player"); gotHit = false; freezeGame = true; timer = 0; dj = ADEvent = jumpEvent = doubleJumpEvent = rotateEvent = dropEvent = dodgeEvent = storeEvent = swapEvent = respawnEvent = makeLineEvent = false; }
public void CreateGrid(GridSize size) { if (size == GridSize.Large) { CreateGrid(lgWidth, lgHeight); } else { CreateGrid(sgWidth, sgHeight); } currentSize = size; }
public int SolvePart1(int squareNumber) { GridSize gridSize = CalculateGridSize(squareNumber); int largestSide = Math.Max(gridSize.X, gridSize.Y); int secondSide = Math.Min(gridSize.X, gridSize.Y); int positionOfMiddleOfSecondSide = secondSide / 2; int positionOfSquareOnNewRowColumn = secondSide - 1 - ((gridSize.X * gridSize.Y) - squareNumber); return((largestSide / 2) + Math.Abs(positionOfMiddleOfSecondSide - positionOfSquareOnNewRowColumn)); }
/// <summary> /// This gets the file from the user. /// </summary> /// <param name="pArgs">This is the command line arg passed to the program.</param> /// <param name="pWords">Allows the use of the Word struct.</param> /// <param name="pGrids">Allows the use of the GridSize.</param> static void GetAFile(string pArgs, out Word[] pWords, out GridSize pGrids) { //Aslong as the file isnt a text file the user will be asked to enter a text file. while (pArgs.EndsWith(".txt") == false) { Console.WriteLine("Please enter a txt file."); pArgs = Console.ReadLine(); Console.Clear(); } string[] boardChoice = File.ReadAllLines(pArgs); //Creating a new board of 1 less than boardChoice to cater for not having the grid size in the Word struct. pWords = new Word[boardChoice.Length - 1]; //GridSize will always only be 1 in length since the grid size is always only on 1 line. pGrids = new GridSize(); //Putting the information from the selected board into the structs. for (int i = 0; i < boardChoice.Length; i++) { string[] data = boardChoice[i].Split(','); //Loading the grid size and number of words. switch (i) { //This loads the grid. case 0: pGrids.columns = int.Parse(data[0]); pGrids.rows = int.Parse(data[1]); //Checks if the number of words is equal to the actual number of words. if (int.Parse(data[2]) != boardChoice.Length - 1) { throw new Exception("The number of words has to be the same as the ammount of words."); } pGrids.noWords = int.Parse(data[2]); break; //Loading the words etc. default: pWords[i - 1].word = data[0].ToLower(); pWords[i - 1].coOrdColumn = int.Parse(data[1]); pWords[i - 1].coOrdRow = int.Parse(data[2]); pWords[i - 1].direction = GetDirection(data[3].ToLower()); pWords[i - 1].wordFound = false; break; } } }
public void GetChunk_Create() { var chunkSize = new GridSize(4); var world = new World(chunkSize); var chunkPosition = new ChunkPosition(15, 129, 63); var chunk = world.CreateChunk(chunkPosition); Assert.IsNotNull(chunk); Assert.AreEqual(chunkPosition, chunk.Position); Assert.AreEqual(chunkSize, chunk.Size); Assert.IsTrue(world.DoesChunkExist(chunkPosition)); }
// Use this for initialization void Start() { highestpoint = -1; SnapMovement.gameOver = false; gs = FindObjectOfType <GridSize>(); for (int i = 0; i < gs.gridWidth; i++) { for (int j = 0; j < gs.gridHeight; j++) { grid[i, j] = null; } } }
/// <summary> /// Loads the world properties for this world using file version 1. /// </summary> /// <param name="reader">The reading to stream the data from.</param> private void LoadWorldPropertiesVersion1(BinaryReader reader) { var chunkSize = new GridSize(reader.ReadInt32()); var worldName = reader.ReadString(); var worldFileFormat = reader.ReadInt32(); m_WorldProperties = new WorldProperties { ChunkSize = chunkSize, WorldName = worldName, WorldFileFormat = worldFileFormat, }; }
public void DestroyChunk() { var chunkSize = new GridSize(4); var world = new World(chunkSize); var chunkPosition = new ChunkPosition(5, 19, -3); world.CreateChunk(chunkPosition); world.DestroyChunk(chunkPosition); Assert.IsNull(world.GetChunk(chunkPosition)); Assert.IsFalse(world.DoesChunkExist(chunkPosition)); }
public void ReplaceMapSize(GridSize newValue) { var entity = mapSizeEntity; if (entity == null) { entity = SetMapSize(newValue); } else { entity.ReplaceMapSize(newValue); } }
internal static string AsString(this GridSize size) { switch (size) { case GridSize.Auto: return(nameof(GridSize.Auto)); case GridSize.True: return(nameof(GridSize.True)); case GridSize.False: return(nameof(GridSize.False)); default: return($"{(int)size}"); } }
private int LoadPageStart(Holder holder, GridSize grid, int nbOfPartsLoadable) { CalculatePartSize(grid); if (pdfView.IsSwipeVertical) { var lastRow = holder.Row; return(LoadPage(holder.Page, 0, lastRow, 0, grid.Cols - 1, nbOfPartsLoadable)); } var lastCol = holder.Col; return(LoadPage(holder.Page, 0, grid.Rows - 1, 0, lastCol, nbOfPartsLoadable)); }
public void Init() { var size = new GridSize(4); ChunkData = new ChunkData(size); ChunkData.Blocks[1] = 1; ChunkData.Blocks[2] = 2; ChunkData.Blocks[3] = 3; TestFolder += "/ChunkDataTest"; System.IO.Directory.CreateDirectory(TestFolder); Handler = new ChunkDataHandler(); }
public bool Solve(int[,] pPuzzle, int pPuzzleSize, GridSize pSubGridSize) { m_PuzzleSize = pPuzzleSize; m_SubGridSize = pSubGridSize; SolvePuzzle(pPuzzle); if (m_NumberOfSolutions == m_MaxNoSolutions) { return(true); } return(false); }
public void Fill() { _grid.Fill('H'); GridSize size = _grid.GetSize(); for (var row = 0; row < size.rows; row++) { for (var column = 0; column < size.columns; column++) { Assert.AreEqual('H', _grid[row][column]); } } }
private static void CheckGridSize(GridSize gridSize) { if (gridSize.Columns < 1) { throw new ArgumentOutOfRangeException( nameof(gridSize), $"Argument {nameof(gridSize.Columns)} is {gridSize.Columns} but should be >= 1"); } if (gridSize.Rows < 1) { throw new ArgumentOutOfRangeException( nameof(gridSize), $"Argument {nameof(gridSize.Rows)} is {gridSize.Rows} but should be >= 1"); } }
public void TestGridSizeAssign() { GridSize grid = new GridSize(1, 1) { Rows = 2, Columns = 3 }; Assert.AreEqual(grid.Rows, 2); Assert.AreEqual(grid.Columns, 3); grid.Set(4, 5); Assert.AreEqual(grid.Rows, 4); Assert.AreEqual(grid.Columns, 5); }
public WorldGrid(int columns, int rows, float cellDimensions, float traversalVelocity, Vector3 offset) { var gridSize = new GridSize(columns, rows); this.CellSize = new Size(Distance.FromMeters(cellDimensions), Distance.FromMeters(cellDimensions)); this.MaximumVelocity = Velocity.FromMetersPerSecond(traversalVelocity); // TODO: if we create a grid with lateral and diagonal connections paths look a lot better // however we have to take into account 'crossing over' other cells when reserving. this.Grid = Grid.CreateGridWithLateralConnections(gridSize, this.CellSize, this.MaximumVelocity); this.PathFinder = new PathFinder(); this.Reservations = new Entity[columns, rows]; this.Offset = offset; this.CellOffset = new Vector3(this.CellSize.Width.Meters * 0.5f, 0, this.CellSize.Height.Meters * 0.5f); }
private void EnsureGridSizeFileExists() { IWebsiteState ws = Services.Get <IWebsiteState>(); if (File.Exists(ws.IconGridSizePath)) { string json = File.ReadAllText(ws.IconGridSizePath); ws.ActiveIconGridSize = JsonConvert.DeserializeObject <GridSize>(json); } else { // set automatically saves to file ws.ActiveIconGridSize = GridSize.BuildDefault(); } }
/// <summary> /// Erzeugt eine neue Instanz der Klasse. /// </summary> /// <param name="size">Die Maße des Gitters.</param> private Grid(GridSize size) { sideLength = size.SideLength; columns = size.Width / size.SideLength + 1; rows = size.Height / size.SideLength + 1; cells = new List <T> [columns, rows]; for (int c = 0; c < columns; c++) { for (int r = 0; r < rows; r++) { cells[c, r] = new List <T>(); } } }
private int DetermineTileSize(GridSize gridType) { switch (gridType) { case GridSize.SMALL: return(36); case GridSize.MEDIUM: return(24); case GridSize.LARGE: return(18); } return(-1); }
public void PaintNewGrid(GridSize gridSize) { _outputWriter.Clear(); _outputWriter.SetCursorPosition(0, 0); PaintColumnHeaders(gridSize.ColumnCount); PaintRowSeparator(gridSize.ColumnCount); for (var r = 0; r < gridSize.RowCount; r++) { PaintRowHeader(r + 1); PaintRowCells(gridSize.ColumnCount); PaintRowSeparator(gridSize.ColumnCount); } }
public void PaintNewGrid_RightSize_GridIsPainted(int columnCount, int rowCount) { _outputWriterMock.Setup(x => x.Clear()); _outputWriterMock.Setup(x => x.SetCursorPosition(0, 0)); _outputWriterMock.Setup(x => x.Write(It.IsAny <string>())); _outputWriterMock.Setup(x => x.WriteNewLine()); var gridSize = new GridSize(columnCount, rowCount); _sut.PaintNewGrid(gridSize); _outputWriterMock.Verify(x => x.SetCursorPosition(It.IsAny <int>(), It.IsAny <int>()), Times.Once); _outputWriterMock.Verify(x => x.SetCursorPosition(0, 0), Times.Once); _outputWriterMock.Verify(x => x.Write(It.IsAny <string>()), Times.Exactly(2 + 2 * columnCount + rowCount * (5 + columnCount * 2) - (rowCount >= 10 ? 1 : 0))); _outputWriterMock.Verify(x => x.WriteNewLine(), Times.Exactly(2 + rowCount * 2)); }
static void Main(string[] args) { IConfigProvider iConfigProvider = new AppConfigReader(); LoadConfigs(iConfigProvider); _gridSize = new GridSize(iConfigProvider); _turnCount = new TurnCount(iConfigProvider); Intro.Play(); // generate game id _gameId = RandomWrapper.RandomNumber(1, 10000).ToString(); // I will need this, but don't need it yet Console.CursorVisible = true; string userInput; do { userInput = DisplayMenu(); switch (userInput) { case "1": AddPlayer(); break; case "2": DisplayShips(); break; case "3": GridSize(); break; case "4": TurnCount(); break; case "5": //DeletePlayer(); break; case "6": RunGame(); break; } } while (userInput != "7"); }
private List <Row> GetRows(bool considerStarAsAuto) { if (RowDefinitions.InnerList.Count == 0) { var sizes = (VerticalAlignment == VerticalAlignment.Stretch || !double.IsNaN(Height)) ? __singleStarSize : __singleAutoSize; return(sizes.SelectToList(s => CreateInternalRow(considerStarAsAuto, s))); } else { return(RowDefinitions.InnerList .SelectToList(rd => CreateInternalRow(considerStarAsAuto, GridSize.FromGridLength(rd.Height)))); } }
private List <Column> GetColumns(bool considerStarAsAuto) { if (ColumnDefinitions.InnerList.Count == 0) { var sizes = (HorizontalAlignment == HorizontalAlignment.Stretch || !double.IsNaN(Width)) ? __singleStarSize : __singleAutoSize; return(sizes.SelectToList(size => CreateInternalColumn(considerStarAsAuto, size))); } else { return(ColumnDefinitions.InnerList .SelectToList(cd => CreateInternalColumn(considerStarAsAuto, GridSize.FromGridLength(cd.Width)))); } }
public static MvcHtmlString UxTextbox(this HtmlHelper helper, string text, string placeholder = null, bool multiLine = false, int? rows = null, TextboxSize size = null, GridSize gridSize = null, string width = null, string height = null, string helpText = null, string clientId = null) { var textbox = new Textbox(text, placeholder, multiLine, rows, size, gridSize, width, height, helpText, clientId); return helper.RenderUxControl(textbox); }
public Attempt(string id, int attemptNumber, string attemptLine, TimeSpan time, GridSize size, GestureDirection direction, GestureType type, DataSource source) { Valid = true; Size = size; Direction = direction; Source = source; AttemptNumber = attemptNumber; // 0 1 2 3 4 5 6 7 8 9 //[15:59:47]: Target: Hit Shape: Correct TC: (07,02) CC: (07, 02) JL: Short Pointer position: (1054,1,384,9). ID = id; string[] para = attemptLine.Trim().Split('[', ']')[1].Split(':'); Time = time; string[] info = attemptLine.Split(':'); Hit = info[4].Split(' ')[1] == "Hit"; Shape = info[5].Split(' ')[1] == "Correct"; TargetCell = GetPoint(info[6]); CurrentCell = GetPoint(info[7]); Pointer = GetPoint(info[9]); Type = type; }
public static double GetScale(GridSize size) { return size == GridSize.Large ? 122.0f : 61.0f; }
public static void DrawHeatMap(List<Attempt> attempts, GridSize size, string filename) { Bitmap heatMap = HeatMap(attempts, size); heatMap.Save(DataGenerator.DataDirectory + filename); heatMap.Dispose(); }
/// <summary> /// Sets the size in the grid that the element can fill /// </summary> /// <param name="size"></param> /// <returns></returns> public Field SetInputGridSize(GridSize size) { this.Component.Input.SetSize(size); return this; }
private static Bitmap HeatMap(List<Attempt> attempts, GridSize size) { // Color red to green -> http://stackoverflow.com/questions/6394304/algorithm-how-do-i-fade-from-red-to-green-via-yellow-using-rgb-values int width = size == GridSize.Large ? 10 : 20; int height = size == GridSize.Large ? 5 : 10; int sqSize = size == GridSize.Large ? 40 : 20; Bitmap heatMap = new Bitmap(400,200); Graphics map = Graphics.FromImage(heatMap); var list = new List<Tuple<float, int, int>>(); map.FillRectangle(Brushes.White, 0, 0, 400, 200); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { var cellAttempts = attempts.Where(x => x.TargetCell.X == j && x.TargetCell.Y == i).ToList(); float sum = cellAttempts.Sum(x => x.Hit ? 1 : 0); float count = cellAttempts.Count(); float percent = sum / count; if(count != 0) { list.Add(new Tuple<float, int, int>(percent, j, i)); } } } list.Sort((x, y) => x.Item1.CompareTo(y.Item1)); int colorDegree = (int)Math.Round(255f / (list.Count() * 0.5)) - 1; int half = (int)Math.Round((list.Count() * 0.5)); foreach(var cell in list) { var rectangle = new Rectangle(cell.Item2 * sqSize, cell.Item3 * sqSize, sqSize, sqSize); int value = (int)Math.Round(cell.Item1 * 255f); SolidBrush brush = new SolidBrush(Color.FromArgb(255, value, 0)); map.FillRectangle(brush, rectangle); } for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { var rectangle = new Rectangle(j * sqSize, i * sqSize, sqSize, sqSize); map.DrawRectangle(Pens.Black, rectangle); } } map.Save(); /* for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { var rectangle = new Rectangle(j * sqSize, i * sqSize, sqSize, sqSize); var cellAttempts = attempts.Where(x => x.TargetCell.X == j && x.TargetCell.Y == i); /* RGB values for the colors: •Red 255, 0, 0 •Yellow 255, 255, 0 •Green 0, 255, 0 Between Red and Yellow, equally space your additions to the green channel until it reaches 255. Between Yellow and Green, equally space your subtractions from the red channel. float sum = (float)cellAttempts.Sum(x => x.Hit ? 1 : 0); float count = (float)cellAttempts.Count(); float percentage = sum / count; Brush brush = Brushes.White; if(cellAttempts.Count() != 0) { float adjust = percentage < 0.75 ? 0.5f : 0.75f; int value = (int)Math.Round(255f / 0.25f * (percentage - adjust)); brush = percentage < 0.75f ? new SolidBrush(Color.FromArgb(255, value, 0)) : new SolidBrush(Color.FromArgb(255, 255, 255 - value)); } map.FillRectangle(brush, rectangle); map.DrawRectangle(Pens.Black, rectangle); } } */ return heatMap; }
public void SetSize(GridSize value) { SizeValue = value; }
public void ChangeSize(GridSize size) { if(size == GridSize.Large) { ChangeSize(lgHeight, lgWidth, canvasHeight / lgHeight, canvasWidth / lgWidth); } else { ChangeSize(sgHeight, sgWidth, canvasHeight / sgHeight, canvasWidth / sgWidth); } }
public SearchBox SetInputSize(GridSize size) { this.Component.Input.SetSize(size); return this; }
public Input SetSize(GridSize size) { this.Component.Size = size; return this; }
public Layout SetLayoutSize(GridSize size) { this.Component.LayoutSize = size; return this; }
private static string GetLine(string[] words, GridSize size) { //29:51 hit 2,4 //29:56 miss 9,0 8,0 string tc = $"({ words[2].Split(',')[0]},{ words[2].Split(',')[1]})"; string cc = "", pointer = ""; int cSize = size == GridSize.Large ? 121 : 61; int index = 2; if (words[1] == "Hit") { cc = tc; } else { cc = $"({words[3]})"; index = 3; } int x = Int32.Parse(words[index].Split(',')[0]); int y = Int32.Parse(words[index].Split(',')[1]); int px = x * cSize + (cSize / 2); int py = y * cSize + (cSize / 2); pointer = $"({px},{py})"; //Target: Hit Shape: Correct TC: (01,02) CC: (01, 02) JL: Long Pointer position: (136.0,310.5). return $"Target: {words[1]} Shape: Correct TC: {tc} CC: {cc} JL: Long Pointer position: {pointer}"; }
public AnyContent BeginCol(GridSize size) { return Col(size).BeginContent(); }
public IWriter2<GridCol, AnyContent> Col(GridSize size) { return Context.CreateWriter<GridCol, AnyContent>().Size(size); }