added turn, do_move and check_move functions

This commit is contained in:
2025-09-22 19:43:52 +02:00
parent 699ee5be07
commit 4e960ab050
8 changed files with 93 additions and 8 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/prg-prl-ii-pk-kn.iml" filepath="$PROJECT_DIR$/.idea/prg-prl-ii-pk-kn.iml" />
</modules>
</component>
</project>

8
.idea/prg-prl-ii-pk-kn.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -9,6 +9,10 @@ field = [[" ", "|", " ", "|", " "],
["", "+", "", "+", ""],
[" ", "|", " ", "|", " "]]
player1 = True # bool that states which player is currently playing
player1_char = "X"
player2_char = "O"
def printer(): # function that prints the field
@@ -20,16 +24,50 @@ def printer(): # function that prints the field
print("\n", end="")
def turn(): # function that checks whoose turn it is and where they can place their symbol
print("penis")
def turn(): # function that checks whose turn it is and where they can place their symbol
while True:
next_move_x = int(input(
f"Player {1 if player1 else 2}, please choose the x (horizontal) coordinates of your next move: "))
if next_move_x in list(range(3)): # TODO Implement check to see if move is legal
break
else:
print("Please be sure to input a valid number (0-2). \nPlease try Again.")
while True:
next_move_y = int(input(
f"Player {1 if player1 else 2}, please choose the x (vertical) coordinates of your next move: "))
if next_move_y in list(range(3)): # TODO Implement check to see if move is legal
break
else:
print("Please be sure to input a valid number (0-2). \nPlease try Again.")
# it might be possible to compress the two above loops into one
return check_move(next_move_x, next_move_y)
player1_char = "X"
player2_char = "O"
def do_move(x, y):
global player1 # Tells do_move to look for the global var player1
field[x][y] = (player1_char if player1 else player2_char)
printer()
# TODO implement win checker here
player1 = not player1
turn()
def check_move(x, y):
# translate x and y coordinates to field coordinates
x = int(x * 2)
y = int(y * 2)
if not field[x][y] == " ":
print("Your given coordinates are already occupied. \nPlease Try again.\n")
turn()
else:
do_move(x, y)
print("Willkommen zu Kat&Paul's TicTacToe:")
printer()
# ssh push test
print("Player 1 (X) will start playing.")
turn()