Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
project2pentago
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9831113
project2pentago
Commits
505f5e40
Commit
505f5e40
authored
Apr 03, 2020
by
amir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completing some methods
parent
e25994ec
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
22 deletions
+43
-22
Main.java
Main.java
+5
-0
Player.java
Player.java
+32
-16
smallBoards.java
smallBoards.java
+6
-6
No files found.
Main.java
View file @
505f5e40
...
@@ -4,6 +4,9 @@ public class Main {
...
@@ -4,6 +4,9 @@ public class Main {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// write your code here
// write your code here
Player1
player1
=
new
Player1
();
Player2
player2
=
new
Player2
();
System
.
out
.
println
(
" 0 1 2 3 4 5"
);
System
.
out
.
println
(
" 0 1 2 3 4 5"
);
for
(
int
i
=
0
;
i
<
3
;
i
++){
for
(
int
i
=
0
;
i
<
3
;
i
++){
System
.
out
.
print
(
i
+
"|"
);
System
.
out
.
print
(
i
+
"|"
);
...
@@ -32,5 +35,7 @@ public class Main {
...
@@ -32,5 +35,7 @@ public class Main {
if
(
i
<
5
)
if
(
i
<
5
)
System
.
out
.
println
();
System
.
out
.
println
();
}
}
int
turns
=
1
;
}
}
}
}
Player.java
View file @
505f5e40
...
@@ -27,58 +27,74 @@ public class Player {
...
@@ -27,58 +27,74 @@ public class Player {
for
(
int
i
=
0
;
i
<
6
;
i
++){
for
(
int
i
=
0
;
i
<
6
;
i
++){
for
(
int
j
=
0
;
j
<
6
;
j
++){
for
(
int
j
=
0
;
j
<
6
;
j
++){
if
(
containsInArray
(
arr
,
j
,
i
)){
if
(
containsInArray
(
arr
,
j
,
i
)){
if
(
checkSides
(
arr
,
j
,
i
))
return
true
;
}
}
}
}
}
}
return
false
;
}
}
public
void
checkSides
(
int
[][]
arr
,
int
x
,
int
y
){
public
boolean
checkSides
(
int
[][]
arr
,
int
x
,
int
y
){
if
(
x
!=
0
){
if
(
x
!=
0
){
if
(
containsInArray
(
arr
,
x
-
1
,
y
)){
if
(
containsInArray
(
arr
,
x
-
1
,
y
)){
if
(
c
heckTheMoveIfPossible
(
arrOpponent
,
arr
,
x
,
y
,
-
1
,
0
)
)
if
(
c
ountTheMoves
(
arr
,
x
,
y
,
-
1
,
0
)
==
5
)
return
true
;
}
}
if
(
y
!=
0
){
if
(
y
!=
0
){
if
(
containsInArray
(
arr
,
x
-
1
,
y
-
1
))
if
(
containsInArray
(
arr
,
x
-
1
,
y
-
1
))
if
(
c
heckTheMoveIfPossible
(
arrOpponent
,
arr
,
x
,
y
,
-
1
,
-
1
)
)
if
(
c
ountTheMoves
(
arr
,
x
,
y
,
-
1
,
-
1
)
==
5
)
return
true
;
return
true
;
}
}
if
(
y
!=
5
){
if
(
y
!=
5
){
if
(
containsInArray
(
arr
,
x
-
1
,
y
+
1
))
if
(
containsInArray
(
arr
,
x
-
1
,
y
+
1
))
if
(
c
heckTheMoveIfPossible
(
arrOpponent
,
arr
,
x
,
y
,
-
1
,
+
1
)
)
if
(
c
ountTheMoves
(
arr
,
x
,
y
,
-
1
,
1
)
==
5
)
return
true
;
return
true
;
}
}
}
}
if
(
x
!=
5
){
if
(
x
!=
5
){
if
(
containsInArray
(
arr
Opponent
,
x
+
1
,
y
)){
if
(
containsInArray
(
arr
,
x
+
1
,
y
)){
if
(
c
heckTheMoveIfPossible
(
arrOpponent
,
arr
,
x
,
y
,
+
1
,
0
)
)
if
(
c
ountTheMoves
(
arr
,
x
,
y
,
1
,
0
)
==
5
)
return
true
;
return
true
;
}
}
if
(
y
!=
0
){
if
(
y
!=
0
){
if
(
containsInArray
(
arr
Opponent
,
x
+
1
,
y
-
1
))
if
(
containsInArray
(
arr
,
x
+
1
,
y
-
1
))
if
(
c
heckTheMoveIfPossible
(
arrOpponent
,
arr
,
x
,
y
,
+
1
,
-
1
)
)
if
(
c
ountTheMoves
(
arr
,
x
,
y
,
1
,
-
1
)
==
5
)
return
true
;
return
true
;
}
}
if
(
y
!=
5
){
if
(
y
!=
5
){
if
(
containsInArray
(
arr
Opponent
,
x
+
1
,
y
+
1
))
{
if
(
containsInArray
(
arr
,
x
+
1
,
y
+
1
))
{
if
(
c
heckTheMoveIfPossible
(
arrOpponent
,
arr
,
x
,
y
,
+
1
,
+
1
)
)
if
(
c
ountTheMoves
(
arr
,
x
,
y
,
1
,
-
1
)
==
5
)
return
true
;
return
true
;
}
}
}
}
}
}
if
(
y
!=
0
){
if
(
y
!=
0
){
if
(
containsInArray
(
arr
Opponent
,
x
,
y
-
1
))
if
(
containsInArray
(
arr
,
x
,
y
-
1
))
if
(
c
heckTheMoveIfPossible
(
arrOpponent
,
arr
,
x
,
y
,
0
,
-
1
)
)
if
(
c
ountTheMoves
(
arr
,
x
,
y
,
0
,
-
1
)
==
5
)
return
true
;
return
true
;
}
}
if
(
y
!=
5
){
if
(
y
!=
5
){
if
(
containsInArray
(
arr
Opponent
,
x
,
y
+
1
))
{
if
(
containsInArray
(
arr
,
x
,
y
+
1
))
{
if
(
c
heckTheMoveIfPossible
(
arrOpponent
,
arr
,
x
,
y
,
0
,
+
1
)
)
if
(
c
ountTheMoves
(
arr
,
x
,
y
,
0
,
1
)
==
5
)
return
true
;
return
true
;
}
}
}
}
return
false
;
return
false
;
}
}
public
int
countTheMoves
(
int
[][]
arr
,
int
x
,
int
y
,
int
moveX
,
int
moveY
){
int
x1
=
x
+
moveX
;
int
y1
=
y
+
moveY
;
int
counter
=
1
;
while
((
counter
<
5
)
&&
(
x1
>
-
1
)
&&
(
x1
<
6
)
&&
(
y1
>
-
1
)
&&
(
y1
<
6
)
&&
(
containsInArray
(
arr
,
x1
,
y1
))){
counter
++;
x1
+=
moveX
;
y1
+=
moveY
;
}
return
counter
;
}
}
}
smallBoards.java
View file @
505f5e40
...
@@ -28,13 +28,13 @@ public class smallBoards {
...
@@ -28,13 +28,13 @@ public class smallBoards {
boardsCoordinate
[
0
][
2
]
=
tmp1
;
boardsCoordinate
[
0
][
2
]
=
tmp1
;
boardsCoordinate
[
0
][
0
]
=
tmp2
;
boardsCoordinate
[
0
][
0
]
=
tmp2
;
int
tmp3
=
boardsCoordinate
[
1
][
0
];
tmp
=
boardsCoordinate
[
1
][
0
];
boardsCoordinate
[
1
][
0
]
=
boardsCoordinate
[
0
][
1
];
boardsCoordinate
[
1
][
0
]
=
boardsCoordinate
[
0
][
1
];
int
tmp4
=
boardsCoordinate
[
2
][
1
];
tmp1
=
boardsCoordinate
[
2
][
1
];
boardsCoordinate
[
2
][
1
]
=
tmp
3
;
boardsCoordinate
[
2
][
1
]
=
tmp
;
int
tmp5
=
boardsCoordinate
[
1
][
2
];
tmp2
=
boardsCoordinate
[
1
][
2
];
boardsCoordinate
[
1
][
2
]
=
tmp
4
;
boardsCoordinate
[
1
][
2
]
=
tmp
1
;
boardsCoordinate
[
0
][
1
]
=
tmp
5
;
boardsCoordinate
[
0
][
1
]
=
tmp
2
;
return
boardNumber
;
return
boardNumber
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment