Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TA2_SWT
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Nick-Luis Achtmann
TA2_SWT
Commits
2a366dfe
Commit
2a366dfe
authored
1 month ago
by
Nick
Browse files
Options
Downloads
Patches
Plain Diff
winning bool geändert
parent
28c2e692
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Fehler fix
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/SceneController.java
+4
-2
4 additions, 2 deletions
src/SceneController.java
src/logic/Actor.java
+2
-2
2 additions, 2 deletions
src/logic/Actor.java
src/logic/Board.java
+3
-3
3 additions, 3 deletions
src/logic/Board.java
with
9 additions
and
7 deletions
src/SceneController.java
+
4
−
2
View file @
2a366dfe
...
...
@@ -93,16 +93,18 @@ public class SceneController {
int
row
=
GridPane
.
getRowIndex
(
pressedButton
);
// Zeilen-Koordinate
int
col
=
GridPane
.
getColumnIndex
(
pressedButton
);
// Spalten-Koordinate
//over();
if
(
buttonText
.
equals
(
" "
)
&&
playerTurn
==
1
)
{
// Setze X
pressedButton
.
setText
(
"X"
);
player
.
makeMove
(
board
,
col
,
row
);
//
over();
over
();
aiTurn
();
over
();
board
.
printBoard
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/logic/Actor.java
+
2
−
2
View file @
2a366dfe
...
...
@@ -10,7 +10,7 @@ public interface Actor {
// Methode für Spieler mit Koordinaten
default
boolean
makeMove
(
Board
board
,
int
x
,
int
y
)
{
return
board
.
placeToken
(
x
,
y
,
symbol
);
return
board
.
placeToken
(
x
,
y
,
'X'
);
}
// Methode für Gegner (Zufallsgenerator)
...
...
@@ -20,7 +20,7 @@ public interface Actor {
do
{
x
=
random
.
nextInt
(
3
);
y
=
random
.
nextInt
(
3
);
}
while
(!
board
.
placeToken
(
x
,
y
,
symbol
));
}
while
(!
board
.
placeToken
(
x
,
y
,
'O'
));
int
[]
coordinates
=
{
x
,
y
};
return
coordinates
;
}
...
...
This diff is collapsed.
Click to expand it.
src/logic/Board.java
+
3
−
3
View file @
2a366dfe
...
...
@@ -8,7 +8,7 @@ public class Board{
char
[][]
board
=
new
char
[
3
][
3
];
for
(
int
i
=
0
;
i
<
3
;
i
++){
for
(
int
j
=
0
;
j
<
3
;
j
++){
board
[
i
][
j
]
=
'#'
;
board
[
j
][
i
]
=
'#'
;
}
}
gameboard
=
board
;
...
...
@@ -31,7 +31,7 @@ public class Board{
String
output
=
""
;
for
(
int
i
=
0
;
i
<
3
;
i
++){
for
(
int
j
=
0
;
j
<
3
;
j
++){
output
=
output
+
gameboard
[
i
][
j
];
output
=
output
+
gameboard
[
j
][
i
];
}
output
=
output
+
"\n"
;
}
...
...
@@ -53,7 +53,7 @@ public class Board{
this
.
setWinner
(
gameboard
[
i
][
0
]);
return
true
;
}
if
((
gameboard
[
0
][
i
]
==
gameboard
[
1
][
i
])
&&
(
gameboard
[
i
][
0
]
!=
'#'
)
&&
(
gameboard
[
0
][
i
]
==
gameboard
[
2
][
i
])
)
{
if
((
gameboard
[
0
][
i
]
==
gameboard
[
1
][
i
])
&&
(
gameboard
[
0
][
i
]
!=
'#'
)
&&
(
gameboard
[
0
][
i
]
==
gameboard
[
2
][
i
])
)
{
this
.
setWinner
(
gameboard
[
i
][
0
]);
return
true
;
}
...
...
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