Exemplo n.º 1
0
 public void ChooseTopic(int n)
 {
     cr.IndexTopic = n;
     crDAL.ChangePart(n);
     tpm = crDAL.GetRDLine();
     cr  = new Crossword(Gdatacoding(tpm[0]), tpm[1], Gdatacoding(tpm[0]).Length);
 }
Exemplo n.º 2
0
        public void InitialiseCrossword()
        {
            _dataGenerator = new GridDataGenerator();
            var gridSize = ParseGridSize();
            int cols     = gridSize[0];
            int rows     = gridSize[1];
            var cells    = _dataGenerator.Generate(cols, rows);

            var hintsBuilders = new List <IHintsGridBuider>
            {
                _hintsBuilderTop,
                _hintsBuidlerLeft
            };

            var pivots = _mainGridBuilder.CreatePivotPoints(new Vector2(cols, rows));

            _hintsBuidlerLeft.SetPivot(pivots.Left);
            _hintsBuilderTop.SetPivot(pivots.Top);

            _hintsBuidlerLeft.Height = _mainGridBuilder.Height;
            _hintsBuilderTop.Width   = _mainGridBuilder.Width;

            _game = new Crossword(cells, new StrictRules(), new LocalStateLoader(),
                                  _mainGridBuilder, hintsBuilders, new UnityAnnnouncer());

            _mainGridBuilder.BindToLogicalTiles(_game.Current);
        }
 public CSudocuControl()
 {
     InitializeComponent();
     _UpdateSudocuEvent = new UpdateSudocuEvent(_UpdateSudocu);
     _Sudocu            = new Crossword();
     _Sudocu.SetSize(10, 20);
 }
Exemplo n.º 4
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            // Сохраняем
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter           = "(*.xml)|*.xml";
            if (DialogResult.OK == openFileDialog.ShowDialog(this))
            {
                Crossword newSudocu = Crossword.Load(openFileDialog.FileName);

                numHeigth.Value     = newSudocu.Size.Height;
                numWidth.Value      = newSudocu.Size.Width;
                numVertical.Value   = newSudocu.Vertical.GetMaxCount();
                numHorizontal.Value = newSudocu.Horizontal.GetMaxCount();

                FormGrid();

                for (byte i = 0; i < newSudocu.Horizontal.Count; i++)
                {
                    byte[] bytelst = newSudocu.Horizontal[i].list;
                    for (byte j = 0; j < bytelst.Length; i++)
                    {
                        dataHorizontal.Rows[i].Cells[j + 1].Value =
                            bytelst[j].ToString();
                    }
                }


                _isForm = true;
            }
        }
 private void abrirCrucigrama()
 {
     using (var crossword = new Crossword(diff))
     {
         crossword.ShowDialog();
     }
 }
Exemplo n.º 6
0
        public Crossword GetCrossword()
        {
            // create _board, verticalWords, horizontalWords
            GenCrossword();
            Crossword crossword = new Crossword(_board, verticalWords, horizontalWords);

            return(crossword);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Switches on the level indicated with <i>levelNumber</i> parameter.
 /// </summary>
 /// <param name="levelNumber">Number of a level to switch to</param>
 public void LoadLevel(int levelNumber)
 {
     _grid.ReturnCellsToPool();
     _wordsFound = 0;
     _curCrossword = _locationCrosswords[levelNumber];
     _grid.BuildCrossword(_curCrossword.GetCrosswordTable(), (char)0);
     _puzzle.InitiateBoardGame(_curCrossword);
     _puzzle.NextScroll();
 }
Exemplo n.º 8
0
        //private Crossword GenerateCrossword(int n, int m)
        //{
        //    if (n < 5 || m < 5)
        //        throw new ApplicationException("Field can't be less than 5*5");

        //    var board = new char[n, m];

        //    var horizontalWords = new Dictionary<Tuple<int, int>, Word>();
        //    var verticalWords = new Dictionary<Tuple<int, int>, Word>();


        //    horizontalWords.Add(new Tuple<int, int>(0, 0), new Word() { Id = 1, Value = "cat" });
        //    horizontalWords.Add(new Tuple<int, int>(0, 3), new Word() { Id = 2, Value = "small" });
        //    Crossword crossword = new Crossword(board, verticalWords, horizontalWords);
        //    return crossword;
        //}

        private Crossword GetDummyCrossword(int n, int m)
        {
            if (n < 5 || m < 5)
            {
                throw new ApplicationException("Field can't be less than 5*5");
            }


            var board = new char[n, m];

            var horizontalWords = new Dictionary <Tuple <int, int>, Word>();
            var verticalWords   = new Dictionary <Tuple <int, int>, Word>();

            horizontalWords.Add(new Tuple <int, int>(0, 0), new Word()
            {
                Id = 1, Value = "cat"
            });
            horizontalWords.Add(new Tuple <int, int>(0, 3), new Word()
            {
                Id = 2, Value = "small"
            });
            verticalWords.Add(new Tuple <int, int>(0, 0), new Word()
            {
                Id = 3, Value = "cross"
            });
            verticalWords.Add(new Tuple <int, int>(4, 1), new Word()
            {
                Id = 4, Value = "ball"
            });
            board[0, 0] = 'c';
            board[1, 0] = 'a';
            board[2, 0] = 't';

            board[0, 3] = 's';
            board[1, 3] = 'm';
            board[2, 3] = 'a';
            board[3, 3] = 'l';
            board[4, 3] = 'l';

            board[0, 0] = 'c';
            board[0, 1] = 'r';
            board[0, 2] = 'o';
            board[0, 3] = 's';
            board[0, 4] = 's';

            board[4, 1] = 'b';
            board[4, 2] = 'a';
            board[4, 3] = 'l';
            board[4, 4] = 'l';

            Crossword crossword = new Crossword(board, verticalWords, horizontalWords);

            return(crossword);
        }
Exemplo n.º 9
0
        public CrosswordVM()
        {
            crosswordService      = new CrosswordService();
            CluesAcross           = new List <string>();
            CluesDown             = new List <string>();
            CheckCrosswordCommand = new DelegateCommand(() => CheckCrossword());
            SolveCrosswordCommand = new DelegateCommand(() => SolveCrossword());

            crossword = crosswordService.ReadFromFile();
            InitializeGrid();
        }
Exemplo n.º 10
0
    public void Awake()
    {
        _crossword = new Crossword(_wordsFilePath);

        _crossword.GetCrosswordTable();

        //Dictionary<string, CWword>.Enumerator i = _crossword.CWdict.GetEnumerator();
        //CWword obj = null;
        //Debug.Log("SDFSDFDSFS" + (CWword)_crossword.CWdict.Values.word);
        //i.MoveNext();
        //Debug.Log(obj);
    }
        private void загрузитьСохраненныйToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string login = player.Login;
            string path  = @"..\..\Players\" + login;

            openFileDialog1.DefaultExt       = ".crs";
            openFileDialog1.InitialDirectory = path;
            openFileDialog1.AddExtension     = true;
            openFileDialog1.FileName         = "";
            openFileDialog1.Filter           = "Файл кроссворда (*.crs)|*.crs";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                clearDGV(dgvCrossword);

                BinaryFormatter formatter = new BinaryFormatter();

                using (FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate))
                {
                    _board = (Crossword)formatter.Deserialize(fs);
                }

                for (var i = 0; i < _board.N; i++)
                {
                    for (var j = 0; j < _board.M; j++)
                    {
                        dgvCrossword.Rows[i].Cells[j].Value           = " ";
                        dgvCrossword.Rows[i].Cells[j].ReadOnly        = true;
                        dgvCrossword.Rows[i].Cells[j].Style.BackColor = Color.Black;
                        dgvCrossword.Rows[i].Cells[j].Style.ForeColor = Color.Black;
                    }
                }
                dataGridView1.Rows.Clear();
                dataGridView2.Rows.Clear();

                foreach (var item in _board.defHorDict)
                {
                    dataGridView1.Rows.Add(item.Value.ToString());
                }

                foreach (var item in _board.defVerDict)
                {
                    dataGridView2.Rows.Add(item.Value.ToString());
                }

                ActualizeForProgCrs();

                lblCntHint.Text = _board.CntHint.ToString();
            }
        }
Exemplo n.º 12
0
        public double GetPrize(IEnumerable <char> givenCharacters)
        {
            uint numWordsRevealed = Crossword.CountRevealedWords(givenCharacters);

            foreach (uint rewardThreshold in PrizeTable.Keys.Reverse())
            {
                if (rewardThreshold <= numWordsRevealed)
                {
                    return(PrizeTable[rewardThreshold]);
                }
            }

            return(0);
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            string[] words = { "ушиб", "закрытый", "шина", "открытый", "перелом", "подвывих", "вывих" };

            Crossword crosswordClass = new Crossword(words);

            char[,] crossword = crosswordClass.GenerateCrossword();
            for (int i = 0; i < crosswordClass.crosswordSize; i++)
            {
                for (int j = 0; j < crosswordClass.crosswordSize; j++)
                {
                    Console.Write(crossword[i, j]);
                }
                Console.WriteLine();
            }
        }
Exemplo n.º 14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            // Сохраняем
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter           = "(*.xml)|*.xml";
            if (DialogResult.OK == saveFileDialog.ShowDialog(this))
            {
                // Формируем объект для сохранения
                Crossword newSudocu = new Crossword();
                newSudocu.SetSize((byte)numWidth.Value, (byte)numHeigth.Value);

                Byte RowIndex = 0;
                foreach (DataGridViewRow row in dataHorizontal.Rows)
                {
                    for (Byte i = 1; i < row.Cells.Count; i++)
                    {
                        try
                        {
                            byte value = (byte)(Int32)row.Cells[i].Value;
                            newSudocu.Horizontal[RowIndex].Add(value);
                        }
                        catch
                        { }
                    }
                    RowIndex++;
                }

                RowIndex = 0;
                foreach (DataGridViewRow row in dataVertical.Rows)
                {
                    for (Byte i = 1; i < row.Cells.Count; i++)
                    {
                        try
                        {
                            byte value = (byte)(Int32)row.Cells[i].Value;
                            newSudocu.Vertical[RowIndex].Add(value);
                        }
                        catch
                        { }
                    }
                    RowIndex++;
                }
                newSudocu.Save(saveFileDialog.FileName);
            }
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            string[]  words = { "перелом", "открытый", "подвывих", "закрытый" };
            Crossword cross = new Crossword(words);

            cross.FillCrossword();
            char[,] f = cross.GetField();

            for (int i = 0; i < f.GetLength(0); i++)
            {
                for (int j = 0; j < f.GetLength(1); j++)
                {
                    Console.Write(f[i, j]);
                }
                Console.Write("\n");
            }
        }
Exemplo n.º 16
0
        private void CreateCrossword()
        {
            DeleteAllTiles();

            mCrossCreator = new CrosswordCreator();
            mCrossword    = mCrossCreator.CreateCrossword(sizeWidth, sizeHeight);

            for (int row = 0; row < mCrossword.tiles.GetLength(0); row++)
            {
                for (int column = 0; column < mCrossword.tiles.GetLength(1); column++)
                {
                    CrosswordTile tile = Instantiate(crosswordTilePrefab, crosswordTileParent).GetComponent <CrosswordTile>();
                    tile.SetupTile(mCrossword.GetTile(new CrosswordPosition(row, column)).element);
                    mTileList.Add(tile);
                }
            }
        }
Exemplo n.º 17
0
        public void TestCase6()
        {
            using (StreamReader sr = new StreamReader(@"HackerRank\Crossword_TestCase6.txt"))
            {
                string[] crossword = new string[10];

                for (int i = 0; i < 10; i++)
                {
                    string crosswordItem = sr.ReadLine();
                    crossword[i] = crosswordItem;
                }

                string words = sr.ReadLine();

                string[] result = Crossword.crosswordPuzzle(crossword, words);

                Console.WriteLine(string.Join("\n", result));
            }
        }
Exemplo n.º 18
0
    public static Crossword[] LoadCrosswords(string filepath)
    {
        int n = 0; int x_size; int y_size;

        System.IO.StreamReader MyReader = new System.IO.StreamReader(filepath);
        n = MyReader.ReadLine()[0] - '0';
        Debug.Log("NNNNNNN" + n);

        Crossword[] a = new Crossword[n];
        for (int i = 0; i < n; i++)
        {
            string size = MyReader.ReadLine();
            x_size = size[0] - '0';
            y_size = size[2] - '0';

            a[i] = new Crossword(x_size, y_size);
            a[i].CWLoad1(MyReader);
        }

        return(a);
    }
Exemplo n.º 19
0
    // Start is called before the first frame update
    void Start()
    {
        string DatabaseName = "Cluedo_DB.s3db";
        string filepath     = Application.dataPath + "/Plugins/" + DatabaseName;

        conn = "URI=file:" + filepath;
        Debug.Log("Stablishing connection to: " + conn);
        dbconn = new SqliteConnection(conn);
        dbconn.Open();
        IDbCommand dbcmd = dbconn.CreateCommand();
        string     query = "SELECT * FROM Arguments WHERE challengId = " + challengeId;

        dbcmd.CommandText = query;
        IDataReader reader = dbcmd.ExecuteReader();

        while (reader.Read())
        {
            hintsAndWords.Add(reader.GetString(3));
        }

        for (int i = 0; i < hintsAndWords.Count; i++)
        {
            string[] parts = hintsAndWords[i].Split(':');
            wordHintMap.Add(parts[1].ToUpper(), parts[0]);
            words.Add(parts[1].ToUpper());
        }

        crossword = new Crossword(words);
        crossword.Init();
        crossword.DisplayWordGrid();

        GridLayoutGroup gridLayout = scrollListContent.GetComponent <GridLayoutGroup>();

        gridLayout.constraintCount = crossword.endingX - crossword.startingX + 1;

        gridCells = new GameObject[crossword.endingY - crossword.startingY + 1, crossword.endingX - crossword.startingX + 1];
        for (int y = 0; y < gridCells.GetLength(0); y++)
        {
            for (int x = 0; x < gridCells.GetLength(1); x++)
            {
                gridCells[y, x] = new GameObject();
            }
        }

        for (int i = crossword.startingX; i <= crossword.endingX; i++)
        {
            gridCells[0, i - crossword.startingX] = (GameObject)Instantiate(transparentButtonPrefab);
            gridCells[0, i - crossword.startingX].transform.SetParent(scrollListContentTransform, false);
            gridCells[0, i - crossword.startingX].transform.localScale = new Vector3(1, 1, 1);
        }

        for (int y = crossword.startingY; y < crossword.endingY; y++)
        {
            gridCells[y - crossword.startingY + 1, 0] = (GameObject)Instantiate(transparentButtonPrefab);
            gridCells[y - crossword.startingY + 1, 0].transform.SetParent(scrollListContentTransform, false);
            gridCells[y - crossword.startingY + 1, 0].transform.localScale = new Vector3(1, 1, 1);


            for (int x = crossword.startingX; x < crossword.endingX; x++)
            {
                if (crossword.wordGrid[y, x] != '\0' && crossword.wordGrid[y, x] != '-')
                {
                    GameObject inputObject = (GameObject)Instantiate(letterInputPrefab);
                    inputObject.transform.SetParent(scrollListContentTransform, false);
                    inputObject.transform.localScale = new Vector3(1, 1, 1);
                }
                else
                {
                    gridCells[y - crossword.startingY + 1, x - crossword.startingX + 1] = (GameObject)Instantiate(transparentButtonPrefab);
                    gridCells[y - crossword.startingY + 1, x - crossword.startingX + 1].transform.SetParent(scrollListContentTransform, false);
                    gridCells[y - crossword.startingY + 1, x - crossword.startingX + 1].transform.localScale = new Vector3(1, 1, 1);
                }
            }
        }

        for (int i = 0; i < crossword.placedWords.Count; i++)
        {
            Debug.Log(crossword.placedWords.Count);

            if (crossword.placedWords[i].horientation == 'H')
            {
                gridCells[(int)(crossword.placedWords[i].startPosition.y - crossword.startingY) + 1, (int)crossword.placedWords[i].startPosition.x - crossword.startingX].GetComponentInChildren <TextMeshProUGUI>().text = (i + 1).ToString();
                int index = i;
                gridCells[(int)(crossword.placedWords[i].startPosition.y - crossword.startingY) + 1, (int)crossword.placedWords[i].startPosition.x - crossword.startingX].GetComponent <Button>().onClick.AddListener(() => IndexButtonClicked(index));
            }
            else
            {
                gridCells[(int)(crossword.placedWords[i].startPosition.y - crossword.startingY), (int)crossword.placedWords[i].startPosition.x - crossword.startingX + 1].GetComponentInChildren <TextMeshProUGUI>().text = (i + 1).ToString();
                int index = i;
                gridCells[(int)(crossword.placedWords[i].startPosition.y - crossword.startingY), (int)crossword.placedWords[i].startPosition.x - crossword.startingX + 1].GetComponent <Button>().onClick.AddListener(() => IndexButtonClicked(index));
            }
        }
    }
Exemplo n.º 20
0
 public void ChangeQuestion()
 {
     tpm = crDAL.GetRDLine();
     cr  = new Crossword(Gdatacoding(tpm[0]), tpm[1], Gdatacoding(tpm[0]).Length);
 }
Exemplo n.º 21
0
 public void LoadPentagrams(Crossword crossword)
 {
     Crossword[] crosswordArray = new Crossword[1];
     crosswordArray[0] = crossword;
     LoadPentagrams(crosswordArray);
 }
Exemplo n.º 22
0
 protected EmptyElement(Crossword crossword, int column, int row) : base(crossword, column, row)
 {
 }
Exemplo n.º 23
0
 //-----------------------------------------------------------------
 public void LoadSudocu(String Path)
 {
     _Sudocu = Crossword.Load(Path);
     DoSolve();
 }
Exemplo n.º 24
0
 static BaseCrosswordElement createFunc(Crossword crossword, int column, int row)
 {
     return(new Definition(crossword, column, row));
 }
Exemplo n.º 25
0
 protected Definition(Crossword crossword, int column, int row)
     : base(crossword, column, row)
 {
     _def = BaseDefinition.CreateDefinition(Kierunek.Poziomo);
     crossword._defContainer.Add(_def);
 }
Exemplo n.º 26
0
 /// <summary>
 /// Reads the <i>file</i> to load all levels of related location.
 /// </summary>
 /// <param name="file"> Name of the resourse file </param>
 public int LoadLocation(string file)
 {
     _locationCrosswords = Crossword.LoadCrosswords(file);
     return _locationCrosswords.Length;
 }
Exemplo n.º 27
0
 //internal static new CheckFactory.ctor ctor
 //{
 //    get
 //    {
 //        return new CheckFactory.ctor(createFunc);
 //    }
 //}
 //static IChecker createFunc()
 //{
 //    return new <mycheckerName>();
 //}
 #endregion
 #endregion
 /// <summary>
 /// Protected constructor. Not accessible to public.
 /// </summary>
 /// <param name="crossword">Parent crossword.</param>
 /// <param name="column">Column location of the element within the crossword.</param>
 /// <param name="row">Row location of the element within the crossword.</param>
 protected BaseCrosswordElement(Crossword crossword, int column, int row)
 {
     _crossword = crossword;
     _column    = column;
     _row       = row;
 }
Exemplo n.º 28
0
 protected Letter(Crossword crossword, int column, int row)
     : base(crossword, column, row)
 {
     DefiniteChanged += new EventHandler(DefiniteChangedEH);
 }
Exemplo n.º 29
0
 static BaseCrosswordElement createFunc(Crossword crossword, int column, int row)
 {
     return(new Letter(crossword, column, row));
 }
Exemplo n.º 30
0
 public void InitiateBoardGame(Crossword crossword)
 {
     _pentaLoader.LoadPentagrams(crossword);
 }