Example #1
0
 public void Add(symbol s)
 {
     if (!SymSet.Contains(s))
     {
         SymSet.Add(s);
     }
 }
 protected void sq_Click(object sender, EventArgs e)
 {
     currentNumber = numb.NUMBER2;
     n1            = Math.Sqrt(n1);
     rez.Text      = n1.ToString();
     currentSymbol = symbol.SUM;
 }
Example #3
0
    public void PlayMove(Pile hand)
    {
        List <Card> cards = SelectedToCards();

        if (gameState == state.Draw || gameState == state.Burry)
        {
            revealed  = true;
            trumpSuit = cards[0].suit;
            foreach (Card card in cards)
            {
                GameObject newCard = SpawnCard(card);
                LaunchCard(newCard);
            }
        }
        else if (gameState == state.Play)
        {
            foreach (Card card in cards)
            {
                Debug.Log("Playing cards");
                hand.Remove(card);
                GameObject newCard = SpawnCard(card);
                LaunchCard(newCard);
            }
            ResetPlayerHand();
        }
    }
 /*-----------------------------------------------------------*/
 /*--- Constructor(s) ----------------------------------------*/
 /*-----------------------------------------------------------*/
 /** Full constructor.
  * @param sym the symbol that this part is made up of.
  * @param lab an optional label string for the part.
  */
 public symbol_part(symbol sym, string lab)
     : base(lab)
 {
     if (sym == null)
     throw new internal_error(
           "Attempt to construct a symbol_part with a null symbol");
     _the_symbol = sym;
 }
Example #5
0
 public int SuitToInt(symbol trump, int level)
 {
     if (isTrump)
     {
         return(3);
     }
     return(SuitToInt(trump));
 }
Example #6
0
 /// <summary>
 /// Constructur
 /// </summary>
 public TicTacToeGameplay()
 {
     Gamefield   = new symbol[3, 3];
     Playersicon = symbol.x;
     Player      = 1;
     Playerwon   = false;
     Fullfields  = 0;
 }
Example #7
0
        /*
         * When decoding, this routine is called to figure out which symbol
         * is presently waiting to be decoded.  This routine expects to get
         * the current model scale in the s.scale parameter, and it returns
         * a count that corresponds to the present floating point code:
         *
         * code = count / s.scale
         */
        private ushort get_current_count(symbol s)
        {
            long   range;
            ushort count;

            range = (long)(high - low) + 1;
            count = (ushort)((((long)(code - low) + 1) * s.scale - 1) / range);
            return(count);
        }
        /*-----------------------------------------------------------*/
        /*--- Constructor(s) ----------------------------------------*/
        /*-----------------------------------------------------------*/

        /** Full constructor.
         * @param sym the symbol that this part is made up of.
         * @param lab an optional label string for the part.
         */
        public symbol_part(symbol sym, string lab) : base(lab)
        {
            if (sym == null)
            {
                throw new internal_error(
                          "Attempt to construct a symbol_part with a null symbol");
            }
            _the_symbol = sym;
        }
 static void Main(string[] args)
 {
     symbol  s = new symbol();
     numeric n = new numeric();
     // ex e0 = s + n; //error!
     ex e1 = (ex)s + n;     //works
     ex e2 = s + (ex)n;     //works
     ex e3 = (ex)s + (ex)n; //works
 }
Example #10
0
 public void LoadType(string operation = "AdditionButton")
 {
     if (operation == "AdditionButton")
     {
         type = symbol.addition;
     }
     else if (operation == "MultiplicationButton")
     {
         type = symbol.multiplication;
     }
     PlayerPrefs.SetInt("operation", (int)type);
 }
Example #11
0
        /*
         * This routine is called to encode a symbol.  The symbol is passed
         * in the symbol structure as a low count, a high count, and a range,
         * instead of the more conventional probability ranges.  The encoding
         * process takes two steps.  First, the values of high and low are
         * updated to take into account the range restriction created by the
         * new symbol.  Then, as many bits as possible are shifted out to
         * the output stream.  Finally, high and low are stable again and
         * the routine returns.
         */
        private void encode_symbol(symbol s)
        {
            long range;

            /*
             * These three lines rescale high and low for the new symbol.
             */
            range = (long)(high - low) + 1;

            high = Convert.ToUInt16(low + ((range * s.high) / s.scale - 1));

            low = Convert.ToUInt16(low + ((range * s.low) / s.scale));

            /*
             * This loop turns out new bits until high and low are far enough
             * apart to have stabilized.
             */
            for ( ; ;)
            {
                /*
                 * If this test passes, it means that the MSDigits match, and can
                 * be sent to the output stream.
                 */
                if ((high & 0x8000) == (low & 0x8000))
                {
                    output_bit(high & 0x8000);
                    while (underflow_bits > 0)
                    {
                        output_bit(~high & 0x8000);
                        underflow_bits--;
                    }
                }

                /*
                 * If this test passes, the numbers are in danger of underflow, because
                 * the MSDigits don't match, and the 2nd digits are just one apart.
                 */
                else if (Convert.ToBoolean(low & 0x4000) && !Convert.ToBoolean(high & 0x4000))
                {
                    underflow_bits += 1;
                    low            &= 0x3fff;
                    high           |= 0x4000;
                }
                else
                {
                    return;
                }
                low  <<= 1;
                high <<= 1;
                high  |= 1;
            }
        }
        /*-----------------------------------------------------------*/
        /*--- Constructor(s) ----------------------------------------*/
        /*-----------------------------------------------------------*/
        /** Full constructor.
         * @param on_sym  symbol we are transitioning on.
         * @param to_st   state we transition to.
         * @param nxt     next transition in linked list.
         */
        public lalr_transition(symbol on_sym, lalr_state to_st, lalr_transition nxt)
        {
            /* sanity checks */
                if (on_sym == null)
            throw new internal_error("Attempt to create transition on null symbol");
            if (to_st == null)
            throw new internal_error("Attempt to create transition to null state");

            /* initialize */
            _on_symbol = on_sym;
            _to_state  = to_st;
            _next      = nxt;
        }
 protected void su_Click(object sender, EventArgs e)
 {
     currentNumber = numb.NUMBER2;
     if (n2 == 0)
     {
         rez.Text = "";
     }
     else
     {
         rez.Text = n2.ToString();
     }
     currentSymbol = symbol.SUM;
 }
Example #14
0
    public int PlayingValue(symbol trump, int level)
    {
        if (value == level)
        {
            if (suit == trump)
            {
                return(SuitToInt(trump, level) * 13 + 16);
            }
            else
            {
                return(SuitToInt(trump, level) * 13 + 15);
            }
        }

        return(SuitToInt(trump, level) * 13 + value);
    }
 public bool UpdateUserCounter([FromBody] symbol data)
 {
     try
     {
         using (APP_DBEntities db = new APP_DBEntities())
         {
             db.symbols.Add(data);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #16
0
        /*
         * Just figuring out what the present symbol is doesn't remove
         * it from the input bit stream.  After the character has been
         * decoded, this routine has to be called to remove it from the
         * input stream.
         */
        private void remove_symbol_from_stream(symbol s)
        {
            long range;

            /*
             * First, the range is expanded to account for the symbol removal.
             */
            range = (long)(high - low) + 1;
            high  = Convert.ToUInt16(low + (ushort)((range * s.high) / s.scale - 1));
            low   = Convert.ToUInt16(low + (ushort)((range * s.low) / s.scale));

            /*
             * Next, any possible bits are shipped out.
             */
            for (; ;)
            {
                /*
                 * If the MSDigits match, the bits will be shifted out.
                 */
                if ((high & 0x8000) == (low & 0x8000))
                {
                }

                /*
                 * Else, if underflow is threatining, shift out the 2nd MSDigit.
                 */
                else if ((low & 0x4000) == 0x4000 && (high & 0x4000) == 0)
                {
                    code ^= 0x4000;
                    low  &= 0x3fff;
                    high |= 0x4000;
                }

                /*
                 * Otherwise, nothing can be shifted out, so I return.
                 */
                else
                {
                    return;
                }
                low  <<= 1;
                high <<= 1;
                high  |= 1;
                code <<= 1;
                code  += input_bit();
            }
        }
Example #17
0
    void Start()
    {
        toggle = GetComponent <ToggleGroup>();
        int number = PlayerPrefs.GetInt("operation");

        type = (TypeToggle.symbol)number;

        if (type == (TypeToggle.symbol) 0)
        {
            additionButton.isOn = true;
        }
        else if (type == (TypeToggle.symbol) 1)
        {
            additionButton.isOn       = false;
            multiplicationButton.isOn = true;
        }
    }
        /*-----------------------------------------------------------*/
        /*--- Constructor(s) ----------------------------------------*/
        /*-----------------------------------------------------------*/

        /** Full constructor.
         * @param on_sym  symbol we are transitioning on.
         * @param to_st   state we transition to.
         * @param nxt     next transition in linked list.
         */
        public lalr_transition(symbol on_sym, lalr_state to_st, lalr_transition nxt)

        {
            /* sanity checks */
            if (on_sym == null)
            {
                throw new internal_error("Attempt to create transition on null symbol");
            }
            if (to_st == null)
            {
                throw new internal_error("Attempt to create transition to null state");
            }

            /* initialize */
            _on_symbol = on_sym;
            _to_state  = to_st;
            _next      = nxt;
        }
Example #19
0
        /*
         * This modeling function is called to convert a symbol value
         * consisting of a low, high, and range value into a text character
         * that can be sent to a file.  It does this by finding the symbol
         * in the probability table that straddles the current range.
         */
        private char convert_symbol_to_int(ushort count, ref symbol s)
        {
            int i;

            i = 0;
            for (; ;)
            {
                if (count >= codes[i].low && count < codes[i].high)
                {
                    s.low  = codes[i].low;
                    s.high = codes[i].high;
                    return(codes[i].c);
                }
                if (i == (codes.Count - 1))
                {
                    error_exit("Failure to decode character");
                }
                i++;
            }
        }
Example #20
0
        /*
         * This routine is called to convert a character read in from
         * the text input stream to a low, high, range SYMBOL.  This is
         * part of the modeling function.  In this case, all that needs
         * to be done is to find the character in the probabilities table
         * and then retrieve the low and high values for that symbol.
         */
        private void convert_int_to_symbol(char c, ref symbol s)
        {
            int i;

            i = 0;
            for ( ; ;)
            {
                if (c == codes[i].c)
                {
                    s.c    = c;
                    s.low  = codes[i].low;
                    s.high = codes[i].high;
                    return;
                }
                if (i == (codes.Count - 1))
                {
                    error_exit("Trying to encode a char not in the table");
                }
                i++;
            }
        }
Example #21
0
        /*
         * This is the compress routine.  It shows the basic algorithm for
         * the compression programs used in this article.  First, an input
         * characters is loaded.  The modeling routines are called to
         * convert the character to a symbol, which has a high, low and
         * range.  Finally, the arithmetic coder module is called to
         * output the symbols to the bit stream.
         */
        public System.IO.MemoryStream compress(string input)
        {
            int    i;
            char   c;
            symbol s = new symbol();

            initialize_output_bitstream();
            initialize_arithmetic_encoder();
            for (i = 0; i < input.ToCharArray().Length; i++)
            {
                c = input.ToCharArray()[i];
                convert_int_to_symbol(c, ref s);
                encode_symbol(s);
                if (c == '\0')
                {
                    break;
                }
            }
            flush_arithmetic_encoder();
            flush_output_bitstream();
            return(output_buffer);
        }
Example #22
0
        /*
         * This expansion routine demonstrates the basic algorithm used for
         * decompression in this article.  It first goes to the modeling
         * module and gets the scale for the current context.  (Note that
         * the scale is fixed here, since this is not an adaptive model).
         * It then asks the arithmetic decoder to give a high and low
         * value for the current input number scaled to match the current
         * range.  Finally, it asks the modeling unit to convert the
         * high and low values to a symbol.
         */
        public string expand(System.IO.MemoryStream compressed_data, int size)
        {
            char   c;
            ushort count;
            string retval = "";

            symbol s = new symbol();

            initialize_arithmetic_decoder(ref compressed_data);
            for (int i = 0; ;)
            {
                count   = get_current_count(s);
                c       = convert_symbol_to_int(count, ref s);
                retval += c.ToString();
                if (++i == size)
                {
                    break;
                }
                remove_symbol_from_stream(s);
            }
            return(retval);
        }
        public static void rez(symbol symb, ref double n1, ref double n2, TextBox text)
        {
            switch (symb)
            {
            case symbol.SUM:
                n1       += n2;
                n2        = 0;
                text.Text = n1.ToString();
                break;

            case symbol.DIF:
                n1       -= n2;
                n2        = 0;
                text.Text = n1.ToString();
                break;

            case symbol.IMP:
                n1       /= n2;
                n2        = 0;
                text.Text = n1.ToString();
                break;

            case symbol.PROD:
                n1       *= n2;
                n2        = 0;
                text.Text = n1.ToString();
                break;

            case symbol.PW:
                n1        = Math.Pow(n1, n2);
                n2        = 0;
                text.Text = n1.ToString();
                break;

            default:
                break;
            }
        }
Example #24
0
 !IsDataContractSerializable(symbol, dataContractAttribute, dataMemberAttribute);
 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
 /** Constructor with null next.
  * @param on_sym  symbol we are transitioning on.
  * @param to_st   state we transition to.
  */
 public lalr_transition(symbol on_sym, lalr_state to_st)
     : this(on_sym,to_st,null)
 {
     //	this(on_sym, to_st, null);
 }
 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
 /** Constructor with no label.
  * @param sym the symbol that this part is made up of.
  */
 public symbol_part(symbol sym)
     : this(sym,null)
 {
 }
Example #27
0
 SymbolKind.Property => BuildProperty(symbol as IPropertySymbol),
Example #28
0
 => Create(symbol, bid.Item1, bid.Item2, ask.Item1, ask.Item2);
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /** Constructor with no label.
         * @param sym the symbol that this part is made up of.
         */
        public symbol_part(symbol sym) : this(sym, null)
        {
        }
Example #30
0
 if (ShouldIncludeInTargetTypedCompletionList(symbol, inferredTypes, syntaxContext.SemanticModel, syntaxContext.Position))
        /*-----------------------------------------------------------*/
        /*--- Constructor(s) ----------------------------------------*/
        /*-----------------------------------------------------------*/
        /** Full constructor.
           * @param prod production this item uses.
           * @param pos  position of the "dot" within the item.
           */
        public lr_item_core(production prod, int pos)
        {
            production_part part;

              if (prod == null)
            throw new internal_error(
              "Attempt to create an lr_item_core with a null production");

              _the_production = prod;

              if (pos < 0 || pos > _the_production.rhs_length())
            throw new internal_error(
              "Attempt to create an lr_item_core with a bad dot position");

              _dot_pos = pos;

              /* compute and cache hash code now */
              _core_hash_cache = 13*_the_production.GetHashCode() + pos;

              /* cache the symbol after the dot */
              if (_dot_pos < _the_production.rhs_length())
            {
              part = _the_production.rhs(_dot_pos);
              if (!part.is_action())
            _symbol_after_dot = ((symbol_part)part).the_symbol();
            }
        }
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /** Constructor with null next.
         * @param on_sym  symbol we are transitioning on.
         * @param to_st   state we transition to.
         */
        public lalr_transition(symbol on_sym, lalr_state to_st) : this(on_sym, to_st, null)
        {
//	this(on_sym, to_st, null);
        }
Example #33
0
 /// <summary>
 /// 获取单词
 /// </summary>
 public void getsym()
 {
     sym = compiler.SA.getSymbol();
 }
Example #34
0
        /// <summary>
        /// 产生Cld_FCBlock的大小及引脚坐标
        /// </summary>
        /// <param name="block"></param>
        /// <param name="pos"></param>
        public void generate_Rec_symbol(Cld_FCBlock block, rela_pos pos)
        {
            Regex  regPointName = new Regex(@"^(\d+)((-(\d+)){3})$");
            symbol sym          = new symbol();
            float  width        = 60f;      // 初始宽度
            float  height       = 0f;       // 初始高度
            float  headHeight   = 15f;      // 上边距
            float  footHeight   = 15f;      // 下边距
            float  pinSpace     = 15f;      // 引脚间隔
            //List<string> edges = null;    // 各条边的信息

            List <Cld_FCInput>  VisibleInputs     = new List <Cld_FCInput>();
            List <Cld_FCOutput> VisibleOutputs    = new List <Cld_FCOutput>();
            List <string>       VisiblePointNames = new List <string>();

            foreach (Cld_FCInput input in block.Cld_FCInput_List)
            {
                // InputPin 的索引也从 0 开始  ___WangXiang
                input.PinIndex = get_pin_index(block.FunctionName, input.PinName) - block.Cld_FCOutput_List.Count;

                // input.PointName!=null的时候不管是否Visible也要占一个Pin位置  ___WangXiang
                bool display = input.Visible || (input.PointName != null && regPointName.IsMatch(input.PointName));
                if (display)
                {
                    VisibleInputs.Add(input);
                }
            }

            foreach (Cld_FCOutput output in block.Cld_FCOutput_List)
            {
                output.PinIndex = get_pin_index(block.FunctionName, output.PinName);

                // output的Visible只控制PointName的显示。 ___WangXiang
                // 当Visible==true或outputPin有连线时,始终占一个Pin的位置(未处理)
                if (output.Visible)
                {
                    VisibleOutputs.Add(output);
                }
                else
                {
                    foreach (Cld_FCBlock blockTemp in block.Prj_Sheet.Cld_FCBlock_List)
                    {
                        foreach (Cld_FCInput input in blockTemp.Cld_FCInput_List)
                        {
                            if (input.Visible && input.PointName == output.PointName)
                            {
                                VisibleOutputs.Add(output);
                                break;
                            }
                        }
                    }
                }
            }

            int max = (VisibleInputs.Count > VisibleOutputs.Count) ? VisibleInputs.Count : VisibleOutputs.Count;

            if (max == 0)
            {
                //当模块引脚的个数为0
                height = (float)(headHeight + footHeight);
            }
            else if (max > 0)
            {
                height = (float)(headHeight + footHeight + max * pinSpace);
            }
            else
            {
                throw new Exception("the pin number should not be negative");
            }
            //产生矩形的四条边
            //edges = generate_edge(width, height, Color.Black, pos);


            //根据Pin的Index对输入引脚和输出引脚进行排序
            VisibleInputs.Sort(new Cld_FCInput_Compare());
            VisibleOutputs.Sort(new Cld_FCOutput_Compare());

            switch (pos)
            {
            case rela_pos.UPLEFT:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = "0_" + (headHeight + i * pinSpace + pinSpace / 2);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = (width) + "_" + (headHeight + i * pinSpace + pinSpace / 2);
                }
                break;

            case rela_pos.UPRIGHT:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = (-width) + "_" + (headHeight + i * pinSpace);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = "0_" + (headHeight + i * pinSpace);
                }
                break;

            case rela_pos.DOWNLEFT:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = "0_" + (headHeight + i * pinSpace - height);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = (width) + "_" + (headHeight + i * pinSpace - height);
                }
                break;

            case rela_pos.DOWNRIGHT:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = (-width) + "_" + (headHeight + i * pinSpace - height);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = "0_" + (headHeight + i * pinSpace - height);
                }
                break;

            case rela_pos.CENTER:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = (-width) + "_" + (headHeight + i * pinSpace - height / 2);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = (width / 2) + "_" + (headHeight + i * pinSpace - height / 2);
                }
                break;

            default:
                break;
            }

            //填充symbol对象
            sym.kind = symbol_kinds.Rectangle;
            //sym.edges = edges;
            sym.height      = height;
            sym.symbol_name = block.FunctionName;
            sym.width       = width;
            block.Symbol    = sym;
            block.Size      = new SizeF(width, height);
        }
Example #35
0
 => new(CreateString(symbol, cancellationToken));