Esempio n. 1
0
 private void Empty_OnChangeSky_Im_Srv(
     object obj_shogiGui,
     StartposImporter startposImporter,
     KifuParserA_Genjo genjo
     )
 {
 }
Esempio n. 2
0
        public string Execute(
            ref KifuParserA_Result result,
            IRoomViewModel roomViewModel,
            out KifuParserA_State nextState,
            KifuParserA owner,
            KifuParserA_Genjo genjo
            )
        {
            nextState = this;

            StartposImporter startposImporter;
            string           restText;

            bool successful = StartposImporter.TryParse(
                genjo.InputLine,
                out startposImporter,
                out restText
                );

            if (successful)
            {
                genjo.InputLine = restText;

                // SFENの解析結果を渡すので、
                // その解析結果をどう使うかは、委譲します。
                owner.Delegate_OnChangeSky_Im_Srv(
                    roomViewModel,
                    startposImporter,
                    genjo
                    );

                nextState = KifuParserA_StateA2_SfenMoves.GetInstance();
            }
            else
            {
                // 解析に失敗しました。
                //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                genjo.ToBreak = true;
            }

            return(genjo.InputLine);
        }
Esempio n. 3
0
        public static bool TryParse(
            string inputLine,
            out StartposImporter instance,
            out string rest
            )
        {
            bool successful = true;

            ISfenPosition2 ro_SfenStartpos;

            if (!SfenStringReader.ReadString(inputLine, out rest, out ro_SfenStartpos))
            {
                successful = false;
                instance   = null;
                goto gt_EndMethod;
            }

            instance = new StartposImporter(inputLine, ro_SfenStartpos);

gt_EndMethod:
            return(successful);
        }
Esempio n. 4
0
        public SkyConst ToSky()
        {
            // 駒40個に、Finger番号を割り当てておきます。
            SkyBuffer dst_Sky = new SkyBuffer();// 駒数0。
            //SkyBuffer dst_Sky = new SkyBuffer(Util_Sky.New_Komabukuro());// SFENインポート時


            Dictionary <Finger, RO_Star_Koma> komaDic = new Dictionary <Finger, RO_Star_Koma>();


            // ・インクリメントするので、Finger型ではなく int型で。
            // ・駒を取ったときに、先手後手は浮動するので区別できない。
            // 王 0~1
            int int_fingerK1 = 0;
            int int_fingerK2 = 1;
            // 飛車 2~3
            int int_fingerR1 = 2;
            int int_fingerR2 = 3;
            // 角 4~5
            int int_fingerB1 = 4;
            int int_fingerB2 = 5;
            // 金 6~9
            int int_fingerG1 = 6;
            int int_fingerG2 = 8;
            // 銀 10~13
            int int_fingerS1 = 10;
            int int_fingerS2 = 12;
            // 桂 14~17
            int int_fingerN1 = 14;
            int int_fingerN2 = 16;
            // 香 18~21
            int int_fingerL1 = 18;
            int int_fingerL2 = 20;
            // 歩 22~30,31~39
            int int_fingerP1 = 22;
            int int_fingerP2 = 31;

            //
            // どの升に、どの駒がいるか
            //
            foreach (KeyValuePair <Basho, RO_Star_Koma> entry in this.banAndKoma)
            {
                int int_finger;

                // 今回のカウント
                switch (entry.Value.Syurui)
                {
                case PieceType.P:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerP1; break;

                    case Playerside.P2: int_finger = int_fingerP2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.L:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerL1; break;

                    case Playerside.P2: int_finger = int_fingerL2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.N:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerN1; break;

                    case Playerside.P2: int_finger = int_fingerN2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.S:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerS1; break;

                    case Playerside.P2: int_finger = int_fingerS2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.G:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerG1; break;

                    case Playerside.P2: int_finger = int_fingerG2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.K:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerK1; break;

                    case Playerside.P2: int_finger = int_fingerK2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.R:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerR1; break;

                    case Playerside.P2: int_finger = int_fingerR2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.B:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerB1; break;

                    case Playerside.P2: int_finger = int_fingerB2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PR:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerR1; break;

                    case Playerside.P2: int_finger = int_fingerR2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PB:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerB1; break;

                    case Playerside.P2: int_finger = int_fingerB2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PP:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerP1; break;

                    case Playerside.P2: int_finger = int_fingerP2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PL:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerL1; break;

                    case Playerside.P2: int_finger = int_fingerL2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PN:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerN1; break;

                    case Playerside.P2: int_finger = int_fingerN2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PS:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_finger = int_fingerS1; break;

                    case Playerside.P2: int_finger = int_fingerS2; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                default: throw new Exception($"未対応の駒種類=[{entry.Value.Syurui}]");
                }

                Debug.Assert(0 <= int_finger && int_finger <= 39, "finger=[" + int_finger + "]");

                Debug.Assert(!komaDic.ContainsKey(int_finger), "finger=[" + int_finger + "]");

                komaDic.Add(int_finger, entry.Value);


                // カウントアップ
                switch (entry.Value.Syurui)
                {
                case PieceType.P:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerP1++; break;

                    case Playerside.P2: int_fingerP2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.L:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerL1++; break;

                    case Playerside.P2: int_fingerL2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.N:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerN1++; break;

                    case Playerside.P2: int_fingerN2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.S:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerS1++; break;

                    case Playerside.P2: int_fingerS2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.G:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerG1++; break;

                    case Playerside.P2: int_fingerG2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.K:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerK1++; break;

                    case Playerside.P2: int_fingerK2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.R:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerR1++; break;

                    case Playerside.P2: int_fingerR2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.B:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerB1++; break;

                    case Playerside.P2: int_fingerB2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PR:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerR1++; break;

                    case Playerside.P2: int_fingerR2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PB:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerB1++; break;

                    case Playerside.P2: int_fingerB2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PP:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerP1++; break;

                    case Playerside.P2: int_fingerP2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PL:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerL1++; break;

                    case Playerside.P2: int_fingerL2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PN:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerN1++; break;

                    case Playerside.P2: int_fingerN2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                case PieceType.PS:
                    switch (entry.Value.Pside)
                    {
                    case Playerside.P1: int_fingerS1++; break;

                    case Playerside.P2: int_fingerS2++; break;

                    default: throw new Exception("未対応のプレイヤー番号");
                    }
                    break;

                default:
                    throw new Exception($"未対応の駒種類=[{entry.Value.Syurui}]");
                }
            }

            //
            // 40個の駒が、どの升に居るか
            //
            {
                // finger の順に並べる。
                RO_Star_Koma[] komas = new RO_Star_Koma[40];

                foreach (KeyValuePair <Finger, RO_Star_Koma> entry in komaDic)
                {
                    Debug.Assert(0 <= (int)entry.Key && (int)entry.Key <= 39, "entry.Key=[" + (int)entry.Key + "]");

                    komas[(int)entry.Key] = entry.Value;
                }

                // finger の順に追加。
                int komaHandle = 0;
                foreach (RO_Star_Koma koma in komas)
                {
                    dst_Sky.AddOverwriteStarlight(
                        komaHandle,
                        new RO_MotionlessStarlight(
                            //komaHandle,
                            koma
                            )
                        );
                    komaHandle++;
                }
            }

            StartposImporter.Assert_HirateHonsyogi(dst_Sky, "ToSkyの終了直前 this.InputLine=[" + this.InputLine + "]");

            return(new SkyConst(dst_Sky));
        }