Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CPTR142_AI_Game
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christian Rippe
CPTR142_AI_Game
Commits
ffc256ed
Commit
ffc256ed
authored
Mar 14, 2019
by
Jason Riggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change
parent
9702aeaa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
Board.cpp
Board.cpp
+21
-6
mainOthello.cpp
mainOthello.cpp
+2
-2
No files found.
Board.cpp
View file @
ffc256ed
...
...
@@ -62,7 +62,9 @@ void displayBoard::verticalCheck(int x, char chip) {
}
for
(
int
i
=
firstX
;
i
<=
secondX
;
i
++
)
{
board
[
x
][
i
]
=
{
chip
};
if
(
board
[
x
][
i
]
==
'X'
||
board
[
x
][
i
]
==
'O'
)
{
board
[
x
][
i
]
=
{
chip
};
}
}
}
...
...
@@ -86,7 +88,9 @@ void displayBoard::horizontalCheck(int y, char chip) {
}
for
(
int
i
=
firstY
;
i
<=
secondY
;
i
++
)
{
board
[
i
][
y
]
=
{
chip
};
if
(
board
[
i
][
y
]
==
'X'
||
board
[
i
][
y
]
==
'O'
)
{
board
[
i
][
y
]
=
{
chip
};
}
}
}
...
...
@@ -115,7 +119,9 @@ void displayBoard::downleftCheck(int x,int y,char chip) {
int
temp
=
firstX
-
secondX
;
int
i
=
1
;
while
(
temp
>
0
)
{
board
[
firstX
-
i
][
firstY
+
i
]
=
{
chip
};
if
(
board
[
firstX
-
i
][
firstY
+
i
]
==
'X'
||
board
[
firstX
-
i
][
firstY
+
i
]
==
'O'
)
{
board
[
firstX
-
i
][
firstY
+
i
]
=
{
chip
};
}
temp
--
;
i
++
;
}
...
...
@@ -147,7 +153,9 @@ void displayBoard::upleftCheck(int x, int y, char chip) {
int
temp
=
firstX
-
secondX
;
int
i
=
1
;
while
(
temp
>
0
)
{
board
[
firstX
-
i
][
firstY
-
i
]
=
{
chip
};
if
(
board
[
firstX
-
i
][
firstY
-
i
]
==
'X'
||
board
[
firstX
-
i
][
firstY
-
i
]
==
'O'
)
{
board
[
firstX
-
i
][
firstY
-
i
]
=
{
chip
};
}
temp
--
;
i
++
;
}
...
...
@@ -179,7 +187,9 @@ void displayBoard::downrightCheck(int x, int y, char chip) {
int
temp
=
secondX
-
firstX
;
int
i
=
1
;
while
(
temp
>
0
)
{
board
[
firstX
+
i
][
firstY
+
i
]
=
{
chip
};
if
(
board
[
firstX
+
i
][
firstY
+
i
]
==
'X'
||
board
[
firstX
+
i
][
firstY
+
i
]
==
'O'
)
{
board
[
firstX
+
i
][
firstY
+
i
]
=
{
chip
};
}
temp
--
;
i
++
;
}
...
...
@@ -211,13 +221,18 @@ void displayBoard::uprightCheck(int x,int y,char chip) {
int
temp
=
secondX
-
firstX
;
int
i
=
1
;
while
(
temp
>
0
)
{
board
[
firstX
+
i
][
firstY
-
i
]
=
{
chip
};
if
(
board
[
firstX
+
i
][
firstY
-
i
]
==
'X'
||
board
[
firstX
+
i
][
firstY
-
i
]
==
'O'
)
{
board
[
firstX
+
i
][
firstY
-
i
]
=
{
chip
};
}
temp
--
;
i
++
;
}
}
}
bool
displayBoard
::
isValidAdjacent
(
int
row
,
int
col
,
char
oppTurn
)
{
if
(
board
[
row
+
1
][
col
]
==
oppTurn
)
{
return
true
;
...
...
mainOthello.cpp
View file @
ffc256ed
...
...
@@ -43,7 +43,7 @@ int main() {
cin
>>
x
>>
y
;
if
(
turn
==
1
)
{
if
(
board
.
isValidAdjacent
(
x
-
1
,
y
-
1
,
'O'
)){
if
(
board
.
isValidAdjacent
(
x
-
1
,
y
-
1
,
'O'
)
&&
board
.
isValidFlip
(
x
-
1
,
y
-
1
,
'X'
)
){
board
.
playerMove1
(
x
,
y
);
board
.
verticalCheck
(
x
,
'X'
);
board
.
horizontalCheck
(
y
,
'X'
);
...
...
@@ -59,7 +59,7 @@ int main() {
}
}
else
if
(
turn
==
2
)
{
if
(
isValidAdjacent
(
x
-
1
,
y
-
1
,
'X
'
)){
if
(
board
.
isValidAdjacent
(
x
-
1
,
y
-
1
,
'X'
)
&&
board
.
isValidFlip
(
x
-
1
,
y
-
1
,
'O
'
)){
board
.
playerMove2
(
x
,
y
);
board
.
verticalCheck
(
x
,
'O'
);
board
.
horizontalCheck
(
y
,
'O'
);
...
...
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