From f6870cf5596375bf07be2f611f538d92f7f3cae8 Mon Sep 17 00:00:00 2001
From: Hong-Phuc Bui <hong-phuc.bui@htwsaar.de>
Date: Tue, 13 May 2025 19:17:12 +0200
Subject: [PATCH] ue4, tictactoe

---
 ub-3/bsp-list-of-tupel.py |    5 +++++
 ub-3/tictactoe.test.py    |   17 ++++++++++++++++-
 ub-3/tictactoe.py         |   11 +++++++----
 ub-3/bsp-return.py        |    2 ++
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/ub-3/bsp-list-of-tupel.py b/ub-3/bsp-list-of-tupel.py
new file mode 100644
index 0000000..db2a52c
--- /dev/null
+++ b/ub-3/bsp-list-of-tupel.py
@@ -0,0 +1,5 @@
+position = [
+        (0,0), (0,1), (0,2), (1,0), (2,0)
+    ]
+p = position[5]
+print(p)
diff --git a/ub-3/bsp-return.py b/ub-3/bsp-return.py
new file mode 100644
index 0000000..29d98d9
--- /dev/null
+++ b/ub-3/bsp-return.py
@@ -0,0 +1,2 @@
+def is_in_Bereich(x, a, b):
+    return (x >= a and x <= b, a, b)
diff --git a/ub-3/tictaktoe.py b/ub-3/tictactoe.py
similarity index 95%
rename from ub-3/tictaktoe.py
rename to ub-3/tictactoe.py
index c809e3b..dc96c9b 100644
--- a/ub-3/tictaktoe.py
+++ b/ub-3/tictactoe.py
@@ -41,7 +41,7 @@
             print("Eingabe nicht in Ordnung")
 
 
-def pruefe_comination(p, board):
+def pruefe_combination(p, board):
     r = p[0]
     c = p[1]
     combination = p[2]
@@ -70,8 +70,9 @@
     for p in position:
         r = p[0]
         c = p[1]
+        print(p, player)
         if board[r][c] == player:
-            return pruefe_comination(p, board)
+            return pruefe_combination(p, board)
         else:
             return False
     
@@ -98,7 +99,9 @@
                 empty_cells = empty_cells - 1
     return (empty_cells == 0, 0)
                 
-                
+
+
+
 print_tafel(tafel)
 aktuelle_spieler = 1
 
@@ -111,7 +114,7 @@
     if aktuelle_spieler == 1:
         aktuelle_spieler = 2
     else:
-        aktuelle_spieler = 1
+        aktuelle_spieler = 1        
 
 print("Spiel beendet!")    
     
diff --git a/ub-3/tictactoe.test.py b/ub-3/tictactoe.test.py
index 9c37cf9..04a165d 100644
--- a/ub-3/tictactoe.test.py
+++ b/ub-3/tictactoe.test.py
@@ -1 +1,16 @@
-import 
+from tictactoe import pruefe_comination, has_spieler_gewonnen, PL1, PL2, EMPTY 
+
+
+test_board = [
+    [PL1,   PL1, PL1],
+    [EMPTY, PL2, EMPTY],
+    [EMPTY, PL2, EMPTY]
+]
+
+
+result = pruefe_comination( (0,0,"hvd"), test_board )
+
+print(result)
+
+result = has_spieler_gewonnen(PL1, test_board)
+print(result)

--
Gitblit v1.10.0-SNAPSHOT