public void MatchPuzzleFailTest() { string[] _sudoku = { "9 5 8 3 6 7 1 2 4", "2 3 7 4 5 1 9 6 8", "1 4 6 2 5 7 3 5 7", "6 1 2 8 7 4 5 9 3", "5 7 3 6 1 9 4 8 2", "4 8 9 2 3 5 6 7 1", "7 2 4 5 9 3 8 1 6", "8 9 1 7 4 6 2 3 5", "3 6 5 1 8 2 7 4 9" }; string[] _puzzle = { "9 0 8 0 6 0 1 2 4", "2 3 7 4 5 1 9 6 8", "1 4 6 0 2 0 3 5 7", "0 1 2 0 7 0 5 9 3", "0 7 3 0 1 0 4 8 2", "4 8 0 0 0 5 6 0 1", "7 0 4 5 9 0 8 1 6", "8 9 0 7 4 6 2 0 0", "3 0 5 0 8 0 7 0 9" }; var sudoku = new SudokuPanel(_sudoku, "14061195"); var puzzle = new SudokuPanel(_puzzle, "14061195"); bool result = sudoku.MatchPuzzle(puzzle); Assert.False(result); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); _DoPanel = new SudokuPanel(new Size(this._SplitContainer.Panel1.Width, this._SplitContainer.Panel1.Height)); _DoPanel.Dock = DockStyle.Fill; this._SplitContainer.Panel1.Controls.Add(_DoPanel); }
/// <summary> /// Fills the sudoku with the computed values. /// </summary> /// <param name="solved">The calculated values.</param> /// <param name="unsolved">The scanned values.</param> public void FillSudoku(int[,] solved, int[,] unsolved) { SudokuPanel.transform.parent.gameObject.SetActive(true); SudokuTile[] sudokuTiles = SudokuPanel.GetComponentsInChildren <SudokuTile>(); int x, y; for (int i = 0; i < 81; i++) { //converts the child index to a (x, y) sudoku coordinate //this is a mess due to the initialization in SudokuCreator.Init() x = (i / 3) % 3 + (i / 27) * 3; y = 8 - (i % 3 + ((i / 9) % 3) * 3); sudokuTiles[i].Value = solved[x, y]; sudokuTiles[i].Bitmap = OCR.identifiedBitmaps[x + y * 9]; if (unsolved[x, y] > 0) { sudokuTiles[i].Display(); sudokuTiles[i].Defined = true; if (KnownDigitsBold) { sudokuTiles[i].GetComponent <Text>().fontStyle = FontStyle.Bold; } } else { sudokuTiles[i].Hide(); sudokuTiles[i].Defined = false; } } }
/// <summary> /// Initialization code for the major parts of the application. /// </summary> void Start() { Screen.fullScreen = false; //set up references debugText = DebugTextInstance.GetComponent <Text>(); debugText.enabled = true; Instance = this; Popup.Instance = infoPopup; QuestionPopup.Instance = questionPopup; BitmapEncoding.PersistentPath = Application.persistentDataPath; foreach (var v in WebCamTexture.devices) { print("\"" + v.name + "\"" + (v.isFrontFacing ? " (Front facing)" : "")); } print("Persistent: " + BitmapEncoding.PersistentPath); //load persistent data Status = "Loading Digit Bitmaps"; storedBitmaps = BitmapEncoding.LoadBitmaps(); Status = "Loading Settings"; SettingManager.LoadSettings(); //start camera Status = "Looking for cameras"; try { texture = new WebCamTexture(CameraName); texture.Play(); if (WebCamTexture.devices.Length == 0) { throw new System.Exception(NoCamerasMessage); } } catch (System.Exception e) { Popup.ActivatePopup("Could not start the camera:" + System.Environment.NewLine + e.Message); CameraUI.enabled = OverlayUI.enabled = false; } textureWidth = texture.width; textureHeight = texture.height; side = Mathf.Min(textureWidth, textureHeight) - 10; //create overlay, rotate and stretch images correctly Status = "Assigning images"; Texture2D overlay = CreateOverlay(textureWidth, textureHeight, side); OverlayUI.texture = overlay; CameraUI.texture = texture; CameraUI.GetComponent <AspectRatioFitter>().aspectRatio = textureWidth / (float)textureHeight; if ((texture.videoRotationAngle + 360) % 180 == 90) { int i = textureWidth; textureWidth = textureHeight; textureHeight = i; } CameraUI.transform.parent.localEulerAngles = new Vector3(0, 0, -texture.videoRotationAngle); SudokuPanel.GetComponent <SudokuCreator>().Init(); Status = "Ready to take picture"; debugText.enabled = false; }