예제 #1
0
        /// <summary>
        ///     Compare the position to another position.
        /// </summary>
        /// <param name="other">
        ///     The other position.
        /// </param>
        /// <returns>
        ///     0 if the positions are equal, greater than 0 if the other position is less than the current position, less than 0 if the other position is greater than the current position.
        /// </returns>
        public int CompareTo(Position other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            if (IsOneBased)
            {
                other = other.ToOneBased();
            }
            else if (IsZeroBased)
            {
                other = other.ToZeroBased();
            }

            int lineComparison = LineNumber.CompareTo(other.LineNumber);

            if (lineComparison != 0)
            {
                return(lineComparison);
            }

            return(ColumnNumber.CompareTo(other.ColumnNumber));
        }
예제 #2
0
        public string ToString(XLReferenceStyle referenceStyle, bool includeSheet)
        {
            string address;

            if (!IsValid)
            {
                address = "#REF!";
            }
            else if (referenceStyle == XLReferenceStyle.A1)
            {
                address = GetTrimmedAddress();
            }
            else if (referenceStyle == XLReferenceStyle.R1C1 ||
                     HasWorksheet && Worksheet.Workbook.ReferenceStyle == XLReferenceStyle.R1C1)
            {
                address = "R" + _rowNumber.ToInvariantString() + "C" + ColumnNumber.ToInvariantString();
            }
            else
            {
                address = GetTrimmedAddress();
            }

            if (includeSheet)
            {
                return(String.Concat(
                           WorksheetIsDeleted ? "#REF" : Worksheet.Name.EscapeSheetName(),
                           '!',
                           address));
            }

            return(address);
        }
예제 #3
0
        private ColumnNumber ChooseRandomMove(GameState gameState)
        {
            int          index        = UnityEngine.Random.Range(0, gameState.AvailableMoves.Count);
            ColumnNumber randomColumn = gameState.AvailableMoves[index].XIndex;


            return(randomColumn);
        }
예제 #4
0
        /// <summary>
        /// Implemented CompareTo method
        /// </summary>
        /// <param name="other">Object to compare</param>
        /// <returns>0 if values are the same, -1 if this object is smaller, 1 if it is bigger</returns>
        public int CompareTo(Cell other)
        {
            if (RowNumber == other.RowNumber)
            {
                return(ColumnNumber.CompareTo(other.ColumnNumber));
            }

            return(RowNumber.CompareTo(other.RowNumber));
        }
예제 #5
0
        public ColumnNumber ChooseColumnIndex(GameState gameState)
        {
            InitGameState(gameState);
            UpdateEnemyMoves();
            PickMyBestTarget();
            PickEnemyBestTarget();
            ColumnNumber index = PickRandomMoveBaseOnBestTarget(gameState);

            UpdateMovesList(index);
            return(index);
        }
예제 #6
0
 private void UpdateMovesList(ColumnNumber chosenColumn)
 {
     for (int i = 0; i < 6; i++)
     {
         if (!_currentBoard[(int)chosenColumn, i].IsOccupied)
         {
             _moves.Add(_currentBoard[(int)chosenColumn, i]);
             break;
         }
     }
 }
예제 #7
0
 public static BoardPosition GetBoardPositionByColumn(this ColumnNumber columnNumber, BoardPosition[,] currentBoard)
 {
     for (int i = 0; i < 6; i++)
     {
         if (!currentBoard[columnNumber, i].IsOccupied)
         {
             return(currentBoard[columnNumber, i]);
         }
     }
     return(null);
 }
        /// <summary> Serves as the default hash function. </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            unchecked
            {
                var hash = 101;

                hash = hash * 103 + ColumnNumber.GetHashCode();
                hash = hash * 107 + RowNumber.GetHashCode();
                hash = hash * 109 + (FolderIndex.HasValue ? FolderIndex.Value.GetHashCode() : -1.GetHashCode());

                return(hash);
            }
        }
예제 #9
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Date: ").AppendLine(this.DateTimeOccurred.ToString());
            if (TemplateFileName != null)
            {
                sb.Append("TemplateFileName: ").AppendLine(TemplateFileName);
            }
            if (TemplateIdentifier != null)
            {
                sb.Append("TemplateIdentifier: ").AppendLine(TemplateIdentifier);
            }
            sb.Append("Class: ").AppendLine(Class.ToString());
            sb.Append("IsWarning: ").AppendLine(IsWarning.ToString());
            sb.Append("IsRuntime: ").AppendLine(IsRuntime.ToString());
            sb.Append("IsTemplateCodeSegment: ").AppendLine(IsTemplateCodeSegment.ToString());
            if (ErrorNumber != null)
            {
                sb.Append("ErrorNumber: ").AppendLine(ErrorNumber);
            }
            if (ErrorType != null)
            {
                sb.Append("ErrorType: ").AppendLine(ErrorType);
            }
            if (SourceFile != null)
            {
                sb.Append("SourceFile: ").AppendLine(SourceFile);
            }
            if (SourceLine != null)
            {
                sb.Append("SourceLine: ").AppendLine(SourceLine);
            }
            sb.Append("LineNumber: ").AppendLine(LineNumber.ToString());
            sb.Append("ColumnNumber: ").AppendLine(ColumnNumber.ToString());
            if (Message != null)
            {
                sb.Append("Message: ").AppendLine(Message);
            }
            if (Detail != null)
            {
                sb.Append("Detail: ").AppendLine(Detail);
            }
            return(sb.ToString());
        }
예제 #10
0
        public override void MakeMove(ColumnNumber index)
        {
            Move move = new Move();

            move.Column = index;
            move.MyTeam = _myTeam;
            move.Player = this;
            MoveEvent thisMove = new MoveEvent()
            {
                MyMove           = move,
                MySecurityHandle = _mySecurityHandle
            };

            if (OnMoveComplete != null)
            {
                OnMoveComplete.Invoke(this, thisMove);
            }
        }
예제 #11
0
        //This needs to be public so the buttons can access this script
        public void SetCapturedMove(int columnIndex)
        {
            try
            {
                //A little silly but if the column is not available this will throw a null
                //which we handle to tell the player to pick a different column
                _gameState.AvailableMoves.First(x => x.XIndex == columnIndex);


                _choosenColumn = columnIndex;
                _timeToMove    = false;
                AvailableMoves.SetActive(false);
            }
            catch
            {
                Debug.Log("Column is full pick another one");
            }
        }
예제 #12
0
        /// <summary>
        ///     Compare the position to another position.
        /// </summary>
        /// <param name="other">
        ///     The other position.
        /// </param>
        /// <returns>
        ///     0 if the positions are equal, greater than 0 if the other position is less than the current position, less than 0 if the other position is greater than the current position.
        /// </returns>
        public int CompareTo(Position other)
        {
            if (IsOneBased)
            {
                other = other.ToOneBased();
            }
            else if (IsZeroBased)
            {
                other = other.ToZeroBased();
            }

            int lineComparison = LineNumber.CompareTo(other.LineNumber);

            if (lineComparison != 0)
            {
                return(lineComparison);
            }

            return(ColumnNumber.CompareTo(other.ColumnNumber));
        }
예제 #13
0
 protected override void Execute(NativeActivityContext context)
 {
     try
     {
         int colNumber = 0;
         if (ColumnNumber != null)
         {
             colNumber = ColumnNumber.Get(context);
         }
         DataRow dataRow      = CurrentDataRow.Get(context);
         dynamic currentValue = CurrentRowColumnValue.Get(context);
         dataRow[colNumber] = currentValue;
     }
     catch (Exception ex)
     {
         Logger.Log.Logger.LogData(ex.Message + " in activity DataTableSetCurrentRowCellValue", Logger.LogLevel.Error);
         if (!ContinueOnError)
         {
             context.Abort();
         }
     }
 }
        internal Dictionary <string, string> GetProperties()
        {
            var properties = new Dictionary <string, string>();

            if (!string.IsNullOrWhiteSpace(SourcePath))
            {
                properties.Add("sourcepath", SourcePath);
            }
            if (LineNumber.HasValue)
            {
                properties.Add("linenumber", LineNumber.ToString());
            }
            if (ColumnNumber.HasValue)
            {
                properties.Add("columnnumber", ColumnNumber.ToString());
            }
            if (ErrorCode.HasValue)
            {
                properties.Add("code", ErrorCode.ToString());
            }
            return(properties);
        }
예제 #15
0
 private ColumnNumber PickRandomMoveBaseOnBestTarget(GameState gameState)
 {
     if (_enemySelectedTarget != null)
     {
         if (_enemySelectedTarget.GetFourCost(_currentBoard, _enemyTeam) < 2)
         {
             if (_selectedTarget != null && _selectedTarget.GetFourCost(_currentBoard, _myTeam) > 1)
             {
                 return(_enemySelectedTarget.GetNextPosition(_currentBoard).XIndex);
             }
         }
     }
     if (_selectedTarget != null)
     {
         int requiredMovesCount = _selectedTarget.MovesRequiredToFillPath.Count;
         if (requiredMovesCount > 0)
         {
             BoardPosition pos = _selectedTarget.MovesRequiredToFillPath[0];
             return(pos.XIndex);
         }
         else
         {
             try
             {
                 ColumnNumber column = _selectedTarget.GetNextPosition(_currentBoard).XIndex;
                 if (column != null)
                 {
                     return(column);
                 }
             }
             catch
             {
                 //I am so good at coding
             }
         }
     }
     return(ChooseRandomMove(gameState));
 }
예제 #16
0
        protected override void Execute(CodeActivityContext context)
        {
            string    cn = ColumnName.Get(context);
            DataTable dt = DataTable.Get(context);
            int       ci;

            if (null == cn)
            {
                ci = ColumnNumber.Get(context);
            }
            else
            {
                if (!dt.Columns.Contains(cn))
                {
                    throw new ArgumentException("Column '" + cn + "' was not found");
                }

                //add 1 to the column index since we always start with column index 0
                ci = dt.Columns.IndexOf(cn) + 1;
            }

            ColumnLetter.Set(context, CalculateColumnLetter(ci));
        }
예제 #17
0
 /// <include file='doc\DataGridCell.uex' path='docs/doc[@for="DataGridCell.ToString"]/*' />
 /// <devdoc>
 ///    <para>
 ///       Gets the row number and column number of the cell.
 ///    </para>
 /// </devdoc>
 public override string ToString()
 {
     return("DataGridCell {RowNumber = " + RowNumber.ToString() +
            ", ColumnNumber = " + ColumnNumber.ToString() + "}");
 }
 public void OnTurnChosen(ColumnNumber index)
 {
     MakeMove(index);
 }
예제 #19
0
 private void AddQueen(RowNumber RowNumber, ColumnNumber ColumnNumber)
 {
     Space[(int)RowNumber, (int)ColumnNumber] = Piece.Queen;
 }
예제 #20
0
        private void GetListingValueFromEntity(object value)
        {
            if (value != null)
            {
                Type type = value.GetType();
                TypeCode typeCode = Type.GetTypeCode(type);
                switch (typeCode)
                {
                    case TypeCode.Int32:
                        this.NumberColumn = new ColumnNumber(value.ToString());
                        if (NumberColumn != null || NumberColumn.EntityValue != null)
                            this.ListingItems.Add(NumberColumn);
                        break;

                    case TypeCode.DateTime:
                        this.DateColumn = new ColumnDate(value.ToString());
                        if (DateColumn != null || DateColumn.EntityValue != null)
                            this.ListingItems.Add(DateColumn);

                        break;

                    case TypeCode.Boolean:
                        this.BoolCoumn = new ColumnBoolean(value.ToString());
                        if (BoolCoumn != null || BoolCoumn.EntityValue != null)
                            this.ListingItems.Add(BoolCoumn);
                        break;

                    case TypeCode.Double:
                        this.DoubleCoumn = new ColumnDouble(value.ToString());
                        if (DoubleCoumn != null || DoubleCoumn.EntityValue != null)
                            this.ListingItems.Add(DoubleCoumn);
                        break;
                }
            }
        }
예제 #21
0
        public void GetEntityValueFromListing(Listing listing)
        {
            if (listing != null)
            {
                switch (listing.Type)
                {
                    case "DateTime":
                        this.DateColumn = new ColumnDate(listing.Value);
                        if (DateColumn != null || DateColumn.EntityValue != null)
                            this.ListingItems.Add(DateColumn);
                        break;

                    case "Double":
                        this.DoubleCoumn = new ColumnDouble(listing);
                        if (DoubleCoumn != null || DoubleCoumn.EntityValue != null)
                            this.ListingItems.Add(DoubleCoumn);
                        break;

                    case "bool":
                        this.BoolCoumn = new ColumnBoolean(listing);
                        if (BoolCoumn != null || BoolCoumn.EntityValue != null)
                            this.ListingItems.Add(BoolCoumn);
                        break;

                    case "Int":
                        var numberValue = new ColumnNumber(listing);
                        if (numberValue != null || numberValue.EntityValue != null)
                            this.ListingItems.Add(numberValue);
                        break;

                    case "String":
                        var stringValue = new ColumnString(listing);
                        if (stringValue != null || stringValue.EntityValue != null)
                            this.ListingItems.Add(stringValue);
                        break;
                }
            }
            else
            {
                throw new Exception("Item Listing is Missing");
            }
        }
예제 #22
0
 /// <summary>
 ///    <para>
 ///       Gets the row number and column number of the cell.
 ///    </para>
 /// </summary>
 public override string ToString()
 {
     return("DataGridCell {RowNumber = " + RowNumber.ToString(CultureInfo.CurrentCulture) +
            ", ColumnNumber = " + ColumnNumber.ToString(CultureInfo.CurrentCulture) + "}");
 }
예제 #23
0
 public string ToShortString()
 {
     return($"{ZoomLevel.ToString(CultureInfo.InvariantCulture)}, {RowNumber.ToString(CultureInfo.InvariantCulture)}, {ColumnNumber.ToString(CultureInfo.InvariantCulture)}");
 }
예제 #24
0
        public async void OnTurnRequested(GameState gameState)
        {
            ColumnNumber index = await brain.GetDesiredMoveAsync(gameState);

            MakeMove(index);
        }
예제 #25
0
        /// <summary>
        /// This procedure uses the calculation columns,
        /// and splits them each up into 12 columns, for each period
        ///
        /// </summary>
        /// <returns>void</returns>
        protected void InitMultiPeriodColumns()
        {
            System.Int32   MaxDisplayColumns;
            System.Int32   NumberColumns;
            System.Int32   Counter;
            System.Int32   Month;
            System.Int32   NewColumn;
            TParameterList TempParameters;
            String         Formula;

            System.Int32 CurrentPos;
            System.Int32 NumberPos;
            System.Int32 ColumnNumber;
            String       Numberstring;

            // then each column must be written back, 12 times
            // the references must be changed to other columns
            // what about ledger sums, etc?
            MaxDisplayColumns = Parameters.Get("MaxDisplayColumns").ToInt();
            NumberColumns     = MaxDisplayColumns;

            while (Parameters.Exists("param_calculation", NumberColumns))
            {
                NumberColumns = NumberColumns + 1;
            }

            // the current column calculation settings must be saved somewhere
            TempParameters = new TParameterList();

            for (Counter = 0; Counter <= NumberColumns - 1; Counter++)
            {
                TempParameters.Copy(Parameters, Counter, -1, eParameterFit.eBestFit, -1);
            }

            // clear the current column settings
            for (Counter = 0; Counter <= NumberColumns - 1; Counter++)
            {
                Parameters.RemoveColumn(Counter);
            }

            for (Counter = 0; Counter <= NumberColumns - 1; Counter++)
            {
                for (Month = 1; Month <= 12; Month++)
                {
                    NewColumn = Counter * 13 + Month - 1;
                    Parameters.Copy(TempParameters, Counter, -1, eParameterFit.eExact, NewColumn);
                    Parameters.Add("param_column_period_i", new TVariant(Month), NewColumn);
                    Parameters.Add("param_start_period_i", new TVariant(Month), NewColumn);
                    Parameters.Add("param_end_period_i", new TVariant(Month), NewColumn);
                    Parameters.Add("param_ytd", new TVariant(false), NewColumn);

                    if (Parameters.Exists("FirstColumn", NewColumn))
                    {
                        Parameters.Add("FirstColumn", new TVariant(Parameters.Get("FirstColumn", NewColumn).ToInt() * 13 + Month - 1), NewColumn);
                    }

                    if (Parameters.Exists("SecondColumn", NewColumn))
                    {
                        Parameters.Add("SecondColumn", new TVariant(Parameters.Get("SecondColumn", NewColumn).ToInt() * 13 + Month - 1), NewColumn);
                    }

                    if (Parameters.Exists("param_formula", NewColumn))
                    {
                        Formula = Parameters.Get("param_formula", NewColumn).ToString();

                        // replace column(x) with column(mul(13,x))
                        CurrentPos = 0;
                        CurrentPos = Formula.ToLower().IndexOf("column(", CurrentPos);

                        while (CurrentPos != -1)
                        {
                            NumberPos    = CurrentPos + ("column(").Length;
                            Numberstring = Formula.Substring(NumberPos, Formula.IndexOf(')', NumberPos) - NumberPos);
                            ColumnNumber = Convert.ToInt32(Numberstring);
                            Formula      =
                                Formula.Substring(0,
                                                  NumberPos) + "mul(13," + ColumnNumber.ToString() + ')' + Formula.Substring(Formula.IndexOf(')', NumberPos));
                            CurrentPos = Formula.ToLower().IndexOf("column(", CurrentPos + 1);
                        }

                        Parameters.Add("param_formula", new TVariant(Formula), NewColumn);
                    }
                }

                // the ytd column
                NewColumn = Counter * 13 + 12;
                Parameters.Copy(TempParameters, Counter, -1, eParameterFit.eExact, NewColumn);
                Parameters.Add("param_column_period_i", new TVariant(12), NewColumn);
                Parameters.Add("param_ytd", new TVariant(true), NewColumn);

                // TODO: also apply the formula/ reference changes to columns!!!!
            }

            Parameters.Add("MaxDisplayColumns", NumberColumns * 13);
        }
예제 #26
0
 public abstract void MakeMove(ColumnNumber index);