Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
puzzleplayer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Floris
puzzleplayer
Commits
1d51cff3
Commit
1d51cff3
authored
4 months ago
by
Floris
Browse files
Options
Downloads
Patches
Plain Diff
fixes
parent
17ab22c1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
PuzzlePlayer/Binary.cs
+9
-4
9 additions, 4 deletions
PuzzlePlayer/Binary.cs
PuzzlePlayer/PuzzleForm.cs
+5
-3
5 additions, 3 deletions
PuzzlePlayer/PuzzleForm.cs
with
14 additions
and
7 deletions
PuzzlePlayer/Binary.cs
+
9
−
4
View file @
1d51cff3
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Runtime.CompilerServices
;
...
...
@@ -173,12 +174,12 @@ namespace PuzzlePlayer_Namespace
{
// first check if x-1 and x+1 aren't out of bounds
// after that do the check if the move is valid
if
(!(
x
-
1
<
0
||
x
+
1
>
b
.
GetLength
(
0
)))
if
(!(
x
-
1
<
0
||
x
+
1
>
b
.
GetLength
(
0
)
-
1
))
if
(
b
[
x
-
1
,
y
]
==
checkFor
&&
b
[
x
+
1
,
y
]
==
checkFor
)
return
true
;
// same for y
if
(!(
y
-
1
<
0
||
y
+
1
>
b
.
GetLength
(
1
)))
if
(!(
y
-
1
<
0
||
y
+
1
>
b
.
GetLength
(
1
)
-
1
))
if
(
b
[
x
,
y
-
1
]
==
checkFor
&&
b
[
x
,
y
+
1
]
==
checkFor
)
return
true
;
...
...
@@ -189,13 +190,17 @@ namespace PuzzlePlayer_Namespace
// check if the two spaces left, right, up or down of the space are the opposite number. if so return true
private
bool
SideCheck
(
int
x
,
int
y
,
int
[,]
b
,
int
checkFor
)
{
if
(!(
x
-
2
<
0
||
x
+
2
>
b
.
GetLength
(
0
)))
if
(!(
x
-
2
<
0
||
x
+
2
>
b
.
GetLength
(
0
)
-
1
))
if
((
b
[
x
-
2
,
y
]
==
checkFor
&&
b
[
x
-
1
,
y
]
==
checkFor
)
||
(
b
[
x
+
2
,
y
]
==
checkFor
&&
b
[
x
+
1
,
y
]
==
checkFor
))
return
true
;
if
(!(
y
-
2
<
0
||
y
+
2
>
b
.
GetLength
(
1
)))
if
(!(
y
-
2
<
0
||
y
+
2
>
b
.
GetLength
(
1
)-
1
))
{
Debug
.
WriteLine
(
$"
{
x
}
,
{
y
}
"
);
if
((
b
[
x
,
y
-
2
]
==
checkFor
&&
b
[
x
,
y
-
1
]
==
checkFor
)
||
(
b
[
x
,
y
+
2
]
==
checkFor
&&
b
[
x
,
y
+
1
]
==
checkFor
))
return
true
;
}
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
PuzzlePlayer/PuzzleForm.cs
+
5
−
3
View file @
1d51cff3
...
...
@@ -45,8 +45,10 @@ namespace PuzzlePlayer_Namespace
{
UpdateUI
();
};
Board
.
boardState
[
1
,
1
]
=
1
;
Board
.
boardState
[
2
,
2
]
=
0
;
Board
.
boardState
[
4
,
4
]
=
1
;
Board
.
boardState
[
4
,
5
]
=
1
;
Board
.
boardState
[
5
,
4
]
=
1
;
Board
.
boardState
[
5
,
5
]
=
1
;
}
private
void
CreateUI
()
{
...
...
@@ -73,7 +75,7 @@ namespace PuzzlePlayer_Namespace
solvebutton
.
Text
=
"Solve"
;
solvebutton
.
MouseClick
+=
(
object
sender
,
MouseEventArgs
mea
)
=>
{
//board =
board.Solve();
board
.
Solve
();
board
.
Draw
(
graphics
,
new
Point
(
220
,
30
),
new
Size
(
400
,
400
));
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment