//this method determines the sub matrix corresponding to a given element private Symbol[,] CreateSmallerMatrix(Symbol[,] input, int i, int j) { int order = int.Parse(System.Math.Sqrt(input.Length).ToString()); Symbol[,] output = new Symbol[order - 1, order - 1]; int x = 0, y = 0; for (int m = 0; m < order; m++, x++) { if (m != i) { y = 0; for (int n = 0; n < order; n++) { if (n != j) { output[x, y] = input[m, n]; y++; } } } else { x--; } } return(output); }
public Matrix(int height, int width, int size) { Width = width; Height = height; Size = size; X = 0; Y = 0; Field = ""; string l = ""; for (int i = 0; i < Width; i++) { l += '█'; } for (int i = 1; i < Height; i++) { Field += '\n' + l; } matrix = new Symbol[Height, Width]; for (int i = 0; i < Height; i++) { for (int j = 0; j < Width; j++) { matrix[i, j] = new Symbol(); } } }
//Normal symbols and Free Spins are checked separately due to the fact, that while playing on Free Spin - additional Free Spins cannot be awarded. //Checking all lines. When symbols match - the player is awarded. public void CheckLinesIgnoringFreeSpins(Symbol[,] board) { decimal prizes = 0; //first line prizes += CheckLine(board, "first line", new int[] { 0, 0, 0, 0, 0, }); //second line prizes += CheckLine(board, "second line", new int[] { 1, 1, 1, 1, 1, }); //third line prizes += CheckLine(board, "third line", new int[] { 2, 2, 2, 2, 2 }); //pyramidal line prizes += CheckLine(board, "pyramidal line", new int[] { 2, 1, 0, 1, 2 }); //reversed pyramidal line prizes += CheckLine(board, "reversed pyramidal line", new int[] { 0, 1, 2, 1, 0 }); //downstairs line prizes += CheckLine(board, "downstairs line", new int[] { 0, 0, 1, 2, 2 }); //upstairs line prizes += CheckLine(board, "upstairs line", new int[] { 2, 2, 1, 0, 0 }); player.Credit += prizes; }
/* конструктор */ public Board(int h, int w) { Height = h; Width = w; ChrArray = new Symbol[h, w]; FillBoard(); }
//The method checks column after column with given vertical coordinates and looks for matching symbols. Checking excludes Free Spins. private decimal CheckLine(Symbol[,] board, string nameOfLine, int[] verticalCoordinates) { //the prize of eventual win decimal prize = 0; //Checking if 1st, 2nd and 3rd symbol in line are the same, but different than 4th. if (board[0, verticalCoordinates[0]].Name == board[1, verticalCoordinates[1]].Name && board[0, verticalCoordinates[0]].Name == board[2, verticalCoordinates[2]].Name && board[0, verticalCoordinates[0]].Name != board[3, verticalCoordinates[3]].Name && board[0, verticalCoordinates[0]].Name != Figures.FreeSpin) { prize = prize + (board[0, verticalCoordinates[0]].PrizesForWinning[0]) * betValue; victoriesNotifications.Add("Victory at " + nameOfLine + ". Hitting 3 elements. Prize: " + prize); } //Checking if 1st, 2nd, 3rd and 4th symbol in line are the same, but different than 5th. if (board[0, verticalCoordinates[0]].Name == board[1, verticalCoordinates[1]].Name && board[0, verticalCoordinates[0]].Name == board[2, verticalCoordinates[2]].Name && board[0, verticalCoordinates[0]].Name == board[3, verticalCoordinates[3]].Name && board[0, verticalCoordinates[0]].Name != board[4, verticalCoordinates[4]].Name && board[0, verticalCoordinates[0]].Name != Figures.FreeSpin) { prize = prize + (board[0, verticalCoordinates[0]].PrizesForWinning[1]) * betValue; victoriesNotifications.Add("Victory at " + nameOfLine + ". Hitting 4 elements. Prize: " + prize); } //Checking if 1st, 2nd, 3rd, 4th and 5th symbol in line are the same. if (board[0, verticalCoordinates[0]].Name == board[1, verticalCoordinates[1]].Name && board[0, verticalCoordinates[0]].Name == board[2, verticalCoordinates[2]].Name && board[0, verticalCoordinates[0]].Name == board[3, verticalCoordinates[3]].Name && board[0, verticalCoordinates[0]].Name == board[4, verticalCoordinates[4]].Name && board[0, verticalCoordinates[0]].Name != Figures.FreeSpin) { prize = prize + (board[0, verticalCoordinates[0]].PrizesForWinning[2]) * betValue; victoriesNotifications.Add("Victory at " + nameOfLine + ". Hitting 5 elements. Prize: " + prize); } return(prize); }
static void ChoosingStake(Player player, Symbol[,] actualBoard) { decimal newStake; decimal one = 1; decimal ten = 10; bool conditionsMatched = false; Console.Clear(); Console.WriteLine("Type the number from 1 to 10 and play the next game with the new stake."); while (conditionsMatched == false) { string input = Console.ReadLine(); bool correctFormat = decimal.TryParse(input, out newStake); if (correctFormat == true && newStake >= one && newStake <= ten) { player.Stake = newStake; conditionsMatched = true; } else { Console.WriteLine("Invalid format. Try again."); } } }
/// <summary> /// Set the current state of the memento object. /// </summary> /// <param name="temp"></param> /// <param name="m"></param> public void setMemento(Object m) { Memento mem = (Memento)m; Symbol[,] state = mem.GetState(); SymbolLocation = state; }
private Pattern(int width, int height) { Width = width; Height = height; _symbols = new Symbol[Width, Height]; }
private Symbol Determinant(Symbol[,] input) { int order = int.Parse(System.Math.Sqrt(input.Length).ToString()); if (order > 2) { Symbol value = new Symbol("0"); for (int j = 0; j < order; j++) { Symbol[,] Temp = CreateSmallerMatrix(input, 0, j); string strPlusMunus = (SignOfElement(0, j).Tokens[0].Value == "1") ? "" : "-"; Console.WriteLine(strPlusMunus + input[0, j].NakedTokenString + "(" + Determinant(Temp).NakedTokenString + ")" + " " + order.ToString()); value = value + input[0, j] * (SignOfElement(0, j) * Determinant(Temp)); } return(value); } else if (order == 2) { return((input[0, 0] * input[1, 1]) - (input[1, 0] * input[0, 1])); } else { return(input[0, 0]); } }
public Matrix(Symbol theta_i, Symbol alpha_i_minus_1, Symbol a_i_minus_1, Symbol d_i) { data = new Symbol[4, 4]; //wiersz pierwszy data[0, 0] = Symbol.Cos(theta_i); data[0, 1] = -Symbol.Sin(theta_i); data[0, 2] = new Symbol(0); data[0, 3] = a_i_minus_1; //drugi wiersz data[1, 0] = Symbol.Sin(theta_i) * Symbol.Cos(alpha_i_minus_1); data[1, 1] = Symbol.Cos(theta_i) * Symbol.Cos(alpha_i_minus_1); data[1, 2] = Symbol.Sin(alpha_i_minus_1); data[1, 3] = d_i * Symbol.Sin(alpha_i_minus_1); //trzeci wiersz data[2, 0] = Symbol.Sin(theta_i) * Symbol.Sin(alpha_i_minus_1); data[2, 1] = Symbol.Cos(theta_i) * Symbol.Sin(alpha_i_minus_1); data[2, 2] = Symbol.Cos(alpha_i_minus_1); data[2, 3] = d_i * Symbol.Cos(alpha_i_minus_1); //czwarty wiersz data[3, 0] = new Symbol(0); data[3, 1] = new Symbol(0); data[3, 2] = new Symbol(0); data[3, 3] = new Symbol(1); }
internal Buffer(int top, int width, int height) { if (top < 0) { throw new ArgumentOutOfRangeException(nameof(top)); } if (width < 0) { throw new ArgumentOutOfRangeException(nameof(width)); } if (height < 0) { throw new ArgumentOutOfRangeException(nameof(height)); } _width = width; _height = height; _left = 0; _top = top; _screenCurrent = new Symbol[width, height]; _screenLastDrawn = new Symbol[width, height]; _lock = new object(); }
private Pattern(Pattern source) { Width = source.Width; Height = source.Height; _symbols = new Symbol[Width, Height]; Array.Copy(source._symbols, _symbols, _symbols.Length); }
static LeviCivita() { Symbol[,] array2 = ArrayUtilities.Initialize(2, 2, (i, j) => Symbol.Zero); LeviCivita.Permute(2, (indices, symbol) => array2[indices[0], indices[1]] = symbol); LeviCivita.Two = new EuclideanMatrix2((i, j) => array2[i, j]); Symbol[, , ,] array4 = ArrayUtilities.Initialize(4, 4, 4, 4, (i, j, k, l) => Symbol.Zero); LeviCivita.Permute(4, (indices, symbol) => array4[indices[0], indices[1], indices[2], indices[3]] = symbol); LeviCivita.Four = new Tensor4D4((i, j, k, l) => array4[i, j, k, l]); }
Symbol[,] data; // pierwszy indeks jest wierszem public Matrix() { data = new Symbol[4, 4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { data[i, j] = new Symbol(0); } } }
public Board(int rows, int columns) { if (rows != columns) { throw new ArgumentException("Rows should be equal to columns"); } Rows = rows; Columns = columns; board = new Symbol[rows, columns]; }
public Board(Symbol initSymbol) { symbols = new Symbol[3, 3]; for (int row = 0; row < 3; ++row) { for (int col = 0; col < 3; ++col) { symbols[row, col] = initSymbol; } } }
static void DisplayBoardOnScreen(Symbol[,] board) { Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(board[0, 0].NameToDisplayOnBoard + "|" + board[1, 0].NameToDisplayOnBoard + "|" + board[2, 0].NameToDisplayOnBoard + "|" + board[3, 0].NameToDisplayOnBoard + "|" + board[4, 0].NameToDisplayOnBoard); Console.WriteLine(board[0, 1].NameToDisplayOnBoard + "|" + board[1, 1].NameToDisplayOnBoard + "|" + board[2, 1].NameToDisplayOnBoard + "|" + board[3, 1].NameToDisplayOnBoard + "|" + board[4, 1].NameToDisplayOnBoard); Console.WriteLine(board[0, 2].NameToDisplayOnBoard + "|" + board[1, 2].NameToDisplayOnBoard + "|" + board[2, 2].NameToDisplayOnBoard + "|" + board[3, 2].NameToDisplayOnBoard + "|" + board[4, 2].NameToDisplayOnBoard); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(""); }
private void initializeBoard() { symbols = new Symbol[numRows, numColumns]; for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumns; j++) { symbols [i, j] = new Symbol(); } } }
public GameObject(int PosY, int PosX, Symbol[,] Content) { this.PosY = PosY; this.PosX = PosX; this.Content = Content; if (core != null) { core.Objects.Add(this); } }
public GameObject(int PosY, int PosX, string path) { try { this.PosX = PosX; this.PosY = PosY; string[] line = File.ReadAllLines(path); // If file empty create invisible pixel (more safe than empty array) if (line.Length < 1) { Content = new Symbol[, ] { { new Symbol(' ', 0x52) } }; return; } Content = new Symbol[line.Length, line[0].Replace(" ", "").Length / 2]; int i = 0; foreach (string str in line) { byte[] Result = str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(i => byte.Parse(i, System.Globalization.NumberStyles.HexNumber)).ToArray(); for (int j = 0; j < line[0].Replace(" ", "").Length / 2; j++) { try { Content[i, j] = new Symbol(' ', Result[j]); } catch (Exception e) { Content[i, j] = new Symbol(' ', 0x52); continue; } } i++; } if (core != null) { core.Objects.Add(this); } } catch (Exception e) { Console.WriteLine(e); } }
public BoardLogic() { state = new Symbol[3, 3]; currentTurn = Symbol.X; for (int row = 0; row < state.GetLength(0); row++) { for (int column = 0; column < state.GetLength(1); column++) { state[row, column] = Symbol.U; } } }
///Tested and passed public void setMementoTest() { int size = 25; Board target = Board.createInstance(size); Symbol[,] expected = target.SymbolStore; object m = target.CreateMemento();; // TODO: Initialize to an appropriate value Symbol[,] actual = target.SymbolStore; target.setMemento(m); Assert.AreEqual(expected, actual); //Assert.Inconclusive("A method that does not return a value cannot be verified."); }
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; }
public SymbolMatrix(int rows, int columns) { if (rows != columns) { throw new Exception("rows and columns must be equal for square matrix"); } this.Rows = rows; this.Columns = columns; InternalRep = new Symbol[this.Rows, this.Columns]; SymbolMatrixSymbolType = SymbolType.Expression; Zero(); }
public Window(int sizeY, int sizeX) { SizeY = sizeY; SizeX = sizeX; Content = new Symbol[sizeY, sizeX]; for (int i = 0; i < SizeY; i++) { for (int j = 0; j < SizeX; j++) { Content[i, j] = new Symbol(' ', 0x00); } } }
///Tested and passed public void PutSymbolTest() { //PrivateObject param0 = null; // TODO: Initialize to an appropriate value //Board_Accessor target = new Board_Accessor(param0); // TODO: Initialize to an appropriate value int size = 25; Board target = Board.createInstance(size); Symbol Coin = Symbol.Cross; // TODO: Initialize to an appropriate value Symbol expected = Coin; Point position = new Point(10, 10); // TODO: Initialize to an appropriate value target.PutSymbol(Coin, position); Symbol[,] actual = target.SymbolStore; Assert.AreEqual(expected, actual[position.X, position.Y]); //Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public static int contarProfundidade(Symbol[,] boardAtual) { int prof = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (boardAtual[i, j].GetOppositeSymbol() == Symbol.N) { prof += 1; } } } return(prof); }
public void NewGame() { Initialize(); Symbol[,] field = model.Field; view.ShowField(field); Symbol winner; while (!model.CheckWinner(out winner)) { Coordinate playerCoordinate = model.Players.CurrentNode.Data.RequestCoordinateFromPlayer(); model.ChangeField(playerCoordinate, model.Players.CurrentNode.Data.Symbol); view.ShowField(field); model.Players.NextNode(); } view.ShowWinner(winner); }
///Tested and passed public void ClearTest() { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // Board_Accessor target = new Board_Accessor(param0); // TODO: Initialize to an appropriate value int size = 2; Board target = Board.createInstance(size); Symbol[,] expected = new Symbol[size, size]; Point position = new Point(0, 0); target.PutSymbol(Symbol.Oval, position); target.Clear(); Symbol[,] actual = target.SymbolStore; Assert.AreEqual(expected.ToString(), actual.ToString()); // Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public Matrix(Symbol theta_i, Symbol alpha_i_minus_1) //na przysz�o�� �eby mo�na by�o te� tworzy� macierz rotacji { data = new Symbol[3, 3]; data[0, 0] = Symbol.Cos(theta_i); data[0, 1] = -Symbol.Sin(theta_i); data[0, 2] = new Symbol(0); data[1, 0] = Symbol.Sin(theta_i) * Symbol.Cos(alpha_i_minus_1); data[1, 1] = Symbol.Cos(theta_i) * Symbol.Cos(alpha_i_minus_1); data[1, 2] = Symbol.Sin(alpha_i_minus_1); data[2, 0] = Symbol.Sin(theta_i) * Symbol.Sin(alpha_i_minus_1); data[2, 1] = Symbol.Cos(theta_i) * Symbol.Sin(alpha_i_minus_1); data[2, 2] = Symbol.Cos(alpha_i_minus_1); }
/// Tested and passed public void CreateMementoTest() { //PrivateObject param0 = null; // TODO: Initialize to an appropriate value //Board_Accessor target = new Board_Accessor(param0); // TODO: Initialize to an appropriate value int size = 25; Board target = Board.createInstance(size); Symbol[,] expected = target.SymbolStore; // TODO: Initialize to an appropriate value object test; test = target.CreateMemento(); target.setMemento(test); Symbol[,] actual = target.SymbolStore; Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
/// <summary> /// Stores the state of symbols in memento object. /// </summary> /// <param name="state"></param> public Memento(Symbol[,] state) { csMemento = state; }
/// <summary> /// Set the current state of the memento object. /// </summary> /// <param name="temp"></param> /// <param name="m"></param> public void setMemento(Object m) { Memento mem = (Memento)m; Symbol[,] state = mem.GetState(); SymbolLocation = state; }
/// <summary> /// This method Resizes the playing board by a size of 10 when clicked /// at cornors of the board /// </summary> public void ResizeBoard() { int ExtensionSize = 10; BoardSize = BoardSize + ExtensionSize; this.AutoScrollMinSize = new System.Drawing.Size(CellSize * BoardSize, CellSize * BoardSize); Object objMemento = GmBoard.CreateMemento(); GmBoard.SymbolStore = null; GmBoard.SymbolStore = new Symbol[BoardSize, BoardSize]; GmBoard.BoardSize = BoardSize; SymbolTemp = new Symbol[BoardSize, BoardSize]; GmBoard.setMemento(objMemento); for (int i = 0; i < (BoardSize - ExtensionSize); i++) for (int j = 0; j < (BoardSize - ExtensionSize); j++) SymbolTemp[i, j] = GmBoard.SymbolStore[i, j]; GmBoard.SymbolStore = SymbolTemp; if (IsTopLeft == true) { SymbolTemp = null; SymbolTemp = new Symbol[BoardSize, BoardSize]; for (int i = 0; i < (BoardSize - ExtensionSize); i++) { for (int j = 0; j < (BoardSize - ExtensionSize); j++) { SymbolTemp[i + ExtensionSize, j + ExtensionSize] = GmBoard.SymbolStore[i, j]; } } GmBoard.SymbolStore = SymbolTemp; } }
/// <summary> /// This method creates a new instance of the Symbol SymbolLocation to store the symbols. /// </summary> public void Clear() { this.SymbolLocation = new Symbol[Size, Size]; }