Example #1
0
        public bool VerificaParede(IElement[,] terreno, Veiculo motinha, int[,] sentido)

        {
            bool teste = true;;

            if (sentido[0, 1] > 0) // E
            {
                if (motinha.XPos + sentido[0, 1] * QuantidadeMov >= terreno.GetLength(1) - 1)
                {
                    if (motinha is Escavadora)
                    {
                        terreno[YPos, XPos] = null;
                        XPos = 1;
                        terreno[YPos, XPos] = motinha;
                    }
                    teste = false;
                }
            }
            else if (sentido[0, 1] < 0) //W
            {
                if (motinha.XPos + sentido[0, 1] * QuantidadeMov <= 0)
                {
                    if (motinha is Escavadora)
                    {
                        terreno[YPos, XPos] = null;
                        XPos = terreno.GetLength(1) - 2;
                        terreno[YPos, XPos] = motinha;
                    }
                    teste = false;
                }
            }
            if (sentido[1, 0] > 0) // S
            {
                if (motinha.YPos + sentido[1, 0] * QuantidadeMov >= terreno.GetLength(0) - 1)
                {
                    if (motinha is Escavadora)
                    {
                        terreno[YPos, XPos] = null;
                        YPos = 1;
                        terreno[YPos, XPos] = motinha;
                    }
                    teste = false;
                }
            }
            else if (sentido[1, 0] < 0) // N
            {
                if (motinha.YPos + sentido[1, 0] * QuantidadeMov <= 0)
                {
                    if (motinha is Escavadora)
                    {
                        terreno[YPos, XPos] = null;
                        YPos = terreno.GetLength(0) - 2;
                        terreno[YPos, XPos] = motinha;
                    }
                    teste = false;
                }
            }

            return(teste);
        }
Example #2
0
 public TableElement(int rows, int cols)
     : base("table")
 {
     this.rows = rows;
     this.cols = cols;
     this.childElements = new IElement[rows, cols];
 }
Example #3
0
 public HTMLTable(int rows, int cols)
     : base(TableName)
 {
     this.Rows = rows;
     this.Cols = cols;
     this.cells = new IElement[this.Rows, this.Cols];
 }
Example #4
0
 public Table(int rows, int cols)
     : base(Table.TableName)
 {
     this.Rows  = rows;
     this.Cols  = cols;
     this.table = new IElement[Rows, Cols];
 }
Example #5
0
 public HtmlTable(int rows, int cols)
     : base(tableName, tableContent)
 {
     this.Rows     = rows;
     this.Cols     = cols;
     tableElements = new HtmlElement[Rows, Cols];
 }
Example #6
0
        /// <summary>
        /// Compares the element to another.
        /// </summary>
        /// <param name="obj">Other element to compare against.</param>
        /// <returns>If elements are equal.</returns>
        public override bool Equals(object obj)
        {
            ObjectMatrix Matrix = obj as ObjectMatrix;

            if (Matrix == null)
            {
                return(false);
            }

            if (this.columns != Matrix.columns || this.rows != Matrix.rows)
            {
                return(false);
            }

            IElement[,] V1 = this.Values;
            IElement[,] V2 = Matrix.Values;
            int x, y;

            for (y = 0; y < this.rows; y++)
            {
                for (x = 0; x < this.columns; x++)
                {
                    if (V1[y, x] != V2[y, x])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Example #7
0
 /// <summary>
 /// Object-valued matrix.
 /// </summary>
 /// <param name="Values">Object value.</param>
 public ObjectMatrix(IElement[,] Values)
 {
     this.values   = Values;
     this.elements = null;
     this.rows     = Values.GetLength(0);
     this.columns  = Values.GetLength(1);
 }
Example #8
0
 public HTMLTable(int rows, int cols)
     : base("table")
 {
     this.Rows = rows;
     this.Cols = cols;
     this.tableElements = new IElement[rows, cols];
 }
 public HTMLTable(int rows, int cols)
     : base("table", null)
 {
     this.Rows       = rows;
     this.Cols       = cols;
     this.innerTable = new IElement[Rows, Cols];
 }
Example #10
0
 /// <summary>
 /// Object-valued vector.
 /// </summary>
 /// <param name="Rows">Number of rows.</param>
 /// <param name="Columns">Number of columns.</param>
 /// <param name="Elements">Elements.</param>
 public ObjectMatrix(int Rows, int Columns, ICollection <IElement> Elements)
 {
     this.values   = null;
     this.elements = Elements;
     this.rows     = Rows;
     this.columns  = Columns;
 }
Example #11
0
 public TableElement(int rows, int cols)
 {
     this.Name = "table";
     this.Rows = rows;
     this.Cols = cols;
     this.elements = new IElement[rows, cols];
 }
Example #12
0
        /// <summary>
        /// Sets an element in the vector.
        /// </summary>
        /// <param name="Index">Index.</param>
        /// <param name="Value">Element to set.</param>
        public void SetElement(int Index, IElement Value)
        {
            if (Index < 0 || Index >= this.rows)
            {
                throw new ScriptException("Index out of bounds.");
            }

            IVector V = Value as IVector;

            if (V == null)
            {
                throw new ScriptException("Invalid row vector.");
            }

            if (V.Dimension != this.columns)
            {
                throw new ScriptException("Dimension mismatch.");
            }

            IElement[,] M = this.Values;
            this.elements = null;

            int i = 0;

            foreach (IElement E in V.ChildElements)
            {
                M[Index, i++] = E;
            }
        }
Example #13
0
 public HTMLTable(int rows, int cols)
     : base("table", null)
 {
     this.Rows = rows;
     this.Cols = cols;
     this.innerTable = new IElement[Rows, Cols];
 }
Example #14
0
 public Table(int rows, int cols)
     : base("table")
 {
     this.Rows     = rows;
     this.Cols     = cols;
     this.elements = new Element[this.Rows, this.Cols];
 }
Example #15
0
 // constructors
 public Table(int inputRows, int inputCols)
     : base("table")
 {
     this.Rows          = inputRows;
     this.Cols          = inputCols;
     this.tableElements = new IElement[this.Rows, this.Cols];
 }
Example #16
0
 public HTMLTable(int rows, int cols)
 {
     this.Rows  = rows;
     this.Cols  = cols;
     this.Name  = "table";
     this.cells = new IElement[rows, cols];
 }
Example #17
0
 // Constructors
 public HTMLTable(int rows, int cols)
     : base(TableName)
 {
     this.Rows  = rows;
     this.Cols  = cols;
     this.cells = new IElement[this.Rows, this.Cols];
 }
Example #18
0
 public HTMLTable(int rows, int cols)
     : base("table")
 {
     this.Rows     = rows;
     this.Cols     = cols;
     this.elements = new IElement[rows, cols];
 }
Example #19
0
 public Table(int rows, int cols)
 {
     this.rows  = rows;
     this.cols  = cols;
     this.table = new HTMLElement[rows, cols];
     this.name  = "table";
 }
Example #20
0
 public void Move(IElement[,] terreno, Veiculo motinha, int[,] sentido)
 {
     terreno[YPos, XPos] = null;
     XPos = XPos + sentido[0, 1] * QuantidadeMov;
     YPos = YPos + sentido[1, 0] * QuantidadeMov;
     terreno[YPos, XPos] = motinha;
 }
Example #21
0
 public Table(int rows, int cols)
     : base(TableName)
 {
     this.Rows = rows;
     this.Cols = cols;
     this.tableData = new IElement[this.Rows, this.Cols];
 }
Example #22
0
 public Table(int rows,int cols)
     : base("table",name)
 {
     this.rows = rows;
     this.cols = cols;
     this.cells = new IElement[this.Rows,this.Cols];
 }
Example #23
0
 public HtmlTable(int rows, int columns)
     : base(TableName, TableTextContent)
 {
     this.Rows = rows;
     this.Cols = columns;
     elements  = new IElement[Rows, Cols];
 }
Example #24
0
 public HTMLTable(int rows, int cols)
     : base(HTMLTable.TableName)
 {
     this.Rows = rows;
     this.Cols = cols;
     this.table = new IElement[rows, cols];
 }
Example #25
0
        /// <summary>
        /// Tries to multiply an element to the current element, from the left.
        /// </summary>
        /// <param name="Element">Element to multiply.</param>
        /// <returns>Result, if understood, null otherwise.</returns>
        public override IRingElement MultiplyLeft(IRingElement Element)
        {
            IElement[,] Values = this.Values;
            ObjectMatrix Matrix;

            IElement[,] v;
            IElement n;
            int      x, y, z;

            if (Element.IsScalar)
            {
                v = new IElement[this.rows, this.columns];

                for (y = 0; y < this.rows; y++)
                {
                    for (x = 0; x < this.columns; x++)
                    {
                        v[y, x] = Operators.Arithmetics.Multiply.EvaluateMultiplication(Element, Values[y, x], null);
                    }
                }

                return(new ObjectMatrix(v));
            }
            else if (!((Matrix = Element as ObjectMatrix) is null))
            {
                if (Matrix.columns != this.rows)
                {
                    return(null);
                }

                IElement[,] Values2 = Matrix.Values;

                v = new IElement[Matrix.rows, this.columns];

                for (y = 0; y < Matrix.rows; y++)
                {
                    for (x = 0; x < this.columns; x++)
                    {
                        n = null;

                        for (z = 0; z < this.rows; z++)
                        {
                            if (n is null)
                            {
                                n = Operators.Arithmetics.Multiply.EvaluateMultiplication(Values2[y, z], Values[z, x], null);
                            }
                            else
                            {
                                n = Operators.Arithmetics.Add.EvaluateAddition(n,
                                                                               Operators.Arithmetics.Multiply.EvaluateMultiplication(Values2[y, z], Values[z, x], null), null);
                            }
                        }

                        v[y, x] = n;
                    }
                }

                return(new ObjectMatrix(v));
            }
Example #26
0
        public HTMLTable(int rows, int cols)
            : base(InitialHTMLTableName)
        {
            this.Rows = rows;
            this.Cols = cols;

            this.tableElements = new IElement[rows, cols];
        }
Example #27
0
        public HTMLTable(int rows, int cols)
            : base(InitialHTMLTableName)
        {
            this.Rows = rows;
            this.Cols = cols;

            this.tableElements = new IElement[rows, cols];
        }
Example #28
0
    public HtmlTable(int rows, int cols)
        : base(TableName)
    {
        this.Rows = rows;
        this.Cols = cols;

        this.childElements = new IElement[this.Rows, this.Cols];
    }
Example #29
0
        public HtmlTable(int rows, int cols)
            : base(TableName)
        {
            this.Rows = rows;
            this.Cols = cols;

            this.childElements = new IElement[this.Rows, this.Cols];
        }
Example #30
0
        public Table(int rows, int cols, string name = null, string content = null)
            : base(name, content)
        {
            this.Rows = rows;
            this.Cols = cols;

            this.matrix = new IElement[rows, cols];
        }
Example #31
0
        public Terreno(int numLinhas, int numColunas)

        {
            _numLinhas  = numLinhas;
            _numColunas = numColunas;

            terreno = new IElement[_numLinhas, _numColunas];
        }
 public Table(int row, int col)
     : base()
 {
     this.Name = tableName;
     this.TextContent = null;
     this.ChildElements = null;
     this.Rows = row;
     this.Cols = col;
     this.table = new IElement[this.Rows, this.Cols];
 }
Example #33
0
        public void SetVeiculo(IElement[,] terreno, Veiculo motinha)
        {
            rnd = new Random();
            do
            {
                YPos = rnd.Next(1, terreno.GetLength(0) - 1);
                XPos = rnd.Next(1, terreno.GetLength(1) - 1);
            } while (terreno[YPos, XPos] != null);

            terreno[YPos, XPos] = motinha;
        }
Example #34
0
        /// <summary>
        /// Sets an element in the matrix.
        /// </summary>
        /// <param name="Column">Zero-based column index into the matrix.</param>
        /// <param name="Row">Zero-based row index into the matrix.</param>
        /// <param name="Value">Element value.</param>
        public void SetElement(int Column, int Row, IElement Value)
        {
            if (Column < 0 || Column >= this.columns || Row < 0 || Row >= this.rows)
            {
                throw new ScriptException("Index out of bounds.");
            }

            IElement[,] M = this.Values;
            this.elements = null;

            M[Row, Column] = Value;
        }
Example #35
0
        public OperationTable(ICollection<IElement> elements, bool firstElementIsIdentity)
        {
            this.elements = new List<IElement>(elements);
            this.cells = new IElement[elements.Count, elements.Count];

            if (firstElementIsIdentity)
                for (int k = 0; k < this.elements.Count; k++)
                {
                    this.cells[k, 0] = this.elements[k];
                    this.cells[0, k] = this.elements[k];
                }
        }
Example #36
0
        public IElement this[int row, int col]
        {
            get
            {
                return(matrix[row, col]);
            }

            set
            {
                this.matrix = value;
            }
        }
Example #37
0
 public HTMLTable(int rows, int cols) : base("table")
 {
     if (rows <= 0)
     {
         throw new ArgumentOutOfRangeException("rows", 0, "Positive number required.");
     }
     if (cols <= 0)
     {
         throw new ArgumentOutOfRangeException("cols", 0, "Positive number required.");
     }
     this.Rows          = rows;
     this.Cols          = cols;
     this.tableElements = new IElement[rows, cols];
 }
Example #38
0
        public OperationTable(ICollection <IElement> elements, bool firstElementIsIdentity)
        {
            this.elements = new List <IElement>(elements);
            this.cells    = new IElement[elements.Count, elements.Count];

            if (firstElementIsIdentity)
            {
                for (int k = 0; k < this.elements.Count; k++)
                {
                    this.cells[k, 0] = this.elements[k];
                    this.cells[0, k] = this.elements[k];
                }
            }
        }
Example #39
0
 public HTMLTable(int rows, int cols)
     : base("table")
 {
     if (rows <= 0)
     {
         throw new ArgumentOutOfRangeException("rows", 0, "Positive number required.");
     }
     if (cols <= 0)
     {
         throw new ArgumentOutOfRangeException("cols", 0, "Positive number required.");
     }
     this.Rows = rows;
     this.Cols = cols;
     this.tableElements = new IElement[rows, cols];
 }
Example #40
0
        /// <summary>
        /// Returns a transposed matrix.
        /// </summary>
        /// <returns>Transposed matrix.</returns>
        public IMatrix Transpose()
        {
            IElement[,] v      = new IElement[this.columns, this.rows];
            IElement[,] Values = this.Values;
            int x, y;

            for (y = 0; y < this.rows; y++)
            {
                for (x = 0; x < this.columns; x++)
                {
                    v[x, y] = Values[y, x];
                }
            }

            return(new ObjectMatrix(v));
        }
Example #41
0
        /// <summary>
        /// Negates the element.
        /// </summary>
        /// <returns>Negation of current element.</returns>
        public override IGroupElement Negate()
        {
            IElement[,] Values = this.Values;
            IElement[,] v      = new IElement[this.rows, this.columns];
            int x, y;

            for (y = 0; y < this.rows; y++)
            {
                for (x = 0; x < this.columns; x++)
                {
                    v[y, x] = Operators.Arithmetics.Negate.EvaluateNegation(Values[y, x]);
                }
            }

            return(new ObjectMatrix(v));
        }
Example #42
0
        /// <summary>
        /// Tries to add an element to the current element.
        /// </summary>
        /// <param name="Element">Element to add.</param>
        /// <returns>Result, if understood, null otherwise.</returns>
        public override IAbelianGroupElement Add(IAbelianGroupElement Element)
        {
            IElement[,] Values = this.Values;
            ObjectMatrix Matrix;

            IElement[,] v;
            int x, y;

            if (Element.IsScalar)
            {
                v = new IElement[this.rows, this.columns];

                for (y = 0; y < this.rows; y++)
                {
                    for (x = 0; x < this.columns; x++)
                    {
                        v[y, x] = Operators.Arithmetics.Add.EvaluateAddition(Element, this.values[y, x], null);
                    }
                }

                return(new ObjectMatrix(v));
            }
            else if ((Matrix = Element as ObjectMatrix) != null)
            {
                if (this.columns != Matrix.columns || this.rows != Matrix.rows)
                {
                    return(null);
                }

                IElement[,] Values2 = Matrix.Values;

                v = new IElement[this.rows, this.columns];
                for (y = 0; y < this.rows; y++)
                {
                    for (x = 0; x < this.columns; x++)
                    {
                        v[y, x] = Operators.Arithmetics.Add.EvaluateAddition(Values[y, x], Values2[y, x], null);
                    }
                }

                return(new ObjectMatrix(v));
            }
            else
            {
                return(null);
            }
        }
Example #43
0
        /// <summary>
        /// <see cref="Object.ToString()"/>
        /// </summary>
        public override string ToString()
        {
            IElement[,] v = this.Values;
            StringBuilder sb = null;
            bool          First;
            int           x, y;

            for (y = 0; y < this.rows; y++)
            {
                if (sb == null)
                {
                    sb = new StringBuilder("[[");
                }
                else
                {
                    sb.Append(",\r\n [");
                }

                First = true;
                for (x = 0; x < this.columns; x++)
                {
                    if (First)
                    {
                        First = false;
                    }
                    else
                    {
                        sb.Append(", ");
                    }

                    sb.Append(v[y, x].ToString());
                }

                sb.Append(']');
            }

            if (sb == null)
            {
                sb = new StringBuilder("[[]]");
            }
            else
            {
                sb.Append(']');
            }

            return(sb.ToString());
        }
Example #44
0
 public HTMLTable(int rows, int cols)
     : base(TableName)
 {
     this.tableContent = new IElement[rows, cols];
 }
Example #45
0
 public Table(int rows, int columns)
 {
     this.Rows = rows;
     this.Cols = columns;
     this.elements = new IElement[rows, columns];
 }
Example #46
0
 public OperationTable(OperationTable table)
 {
     this.elements = new List<IElement>(table.elements);
     this.cells = new IElement[this.elements.Count, this.elements.Count];
     Array.Copy(table.cells, this.cells, this.elements.Count * this.elements.Count);
 }
 public Table(int rows, int cols)
     : base(tableName, null)
 {
     this.Rows = rows;
     this.Cols = cols;
     this.cells = new IElement[rows, cols];
 }
Example #48
0
 public Table(int rows, int cols)
 {
     this.rows = rows;
     this.cols = cols;
     this.table = new HTMLElement[rows, cols];
     this.name = "table";
 }
 public HtmlTable(int rows, int cols)
     : base(TableName)
 {
     this.htmlElements = new HtmlElement[rows, cols];
 }
 public HTMLTable(int rows, int cols, string name = "table")
 {
     this.Rows = rows;
     this.Cols = cols;
     this.cellElements = new IElement[rows, cols];
 }
Example #51
0
 public Table(int rows, int cols)
     : base("table")
 {
     this.arr = new IElement[rows, cols];
 }
Example #52
0
 public Table(int rows, int cols)
 {
     this.matrix = new Element[rows, cols];
 }
Example #53
0
 public HTMLTable(int rows, int cols)
     : base(rows, cols)
 {
     this.Name = TableName;
     this.table = new IElement[rows, cols];
 }
Example #54
0
 public HTMLTable(int rows, int cols)
 {
     this.rows = rows;
     this.cols = cols;
     this.table = new IElement[this.Rows, this.Cols];
 }
 public Table(int rows, int cols)
     : base(tableName)
 {
     this.matrix = new IElement[rows, cols];
 }