Example #1
0
        //Protected Methods
        protected bool MarkEyeWhites(DataCell cell)
        {
            Random rand = new Random(DateTime.Now.Millisecond);

            if (cell.IsEye() && cell.Color == CellColor.WHITE)
            {
                cell.Marks.Add(Keys.Role, Values.YellowCircle);

                if (cell.UpCell().Color != cell.DownCell().Color)
                {
                    double rand_value = rand.NextDouble();
                    if (rand_value > 0.5)
                    {
                        cell.Marks[Keys.Role] += Values.RedDashedCircle;
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        //protected
        /// <summary>
        /// Mark All BLACK Cells,
        /// Left is the bar left head,
        /// Up is the bar up head,
        /// Marked is the bar's body,
        /// Single is the not in bar.
        /// Unmarked cells is the WHITE cell.
        /// </summary>
        protected void updateCellMarks()
        {
            Random rand_length = new Random();
            bool   markable    = true;

            foreach (DataCell cell in Matrix.CellMatrix)
            {
                //reset markable
                markable = true;

                if (!cell.IsEye() &&
                    !cell.Marks.ContainsKey(Keys.Role) &&
                    cell.Color == CellColor.BLACK)
                {
                    //Random Bar Length
                    int bar_length_index = rand_length.Next(2);
                    int bar_length       = barLengths[bar_length_index];

                    DataCell currCell = cell;
                    //Judge if could horizontal draw bar
                    for (int i = 0; i < bar_length; i++)
                    {
                        if (currCell == null || currCell.IsEye() || currCell.Color != cell.Color || currCell.Marks.ContainsKey(Keys.Role))
                        {
                            markable = false;
                            break;
                        }
                        currCell = currCell.RightCell();
                    }
                    if (markable)
                    {
                        //mark horizontal bar
                        cell.Marks.Add(Keys.Role, Values.Left);
                        cell.Marks.Add(Keys.Count, bar_length.ToString());
                        currCell = cell.RightCell();
                        for (int i = 0; i < bar_length - 1; i++)
                        {
                            currCell.Marks.Add(Keys.Role, Values.Marked);
                            currCell = currCell.RightCell();
                        }
                    }
                    else
                    {
                        markable = true;
                        currCell = cell;
                        for (int i = 0; i < bar_length; i++)
                        {
                            if (currCell == null || currCell.IsEye() || currCell.Color != cell.Color || currCell.Marks.ContainsKey(Keys.Role))
                            {
                                markable = false;
                                break;
                            }
                            currCell = currCell.DownCell();
                        }
                        if (markable)
                        {
                            cell.Marks.Add(Keys.Role, Values.Up);
                            cell.Marks.Add(Keys.Count, bar_length.ToString());
                            currCell = cell.DownCell();
                            for (int i = 0; i < bar_length - 1; i++)
                            {
                                currCell.Marks.Add(Keys.Role, Values.Marked);
                                currCell = currCell.DownCell();
                            }
                        }
                        else
                        {
                            cell.Marks.Add(Keys.Role, Values.Single);
                        }
                    }
                }
            }
        }