umutcaner commited on
Commit
f11ab78
·
verified ·
1 Parent(s): 696e0f5

Upload 29 files

Browse files

# Maze Data Structure in Java

This is a Java project that visualizes maze-solving algorithms using basic data structures like stacks, queues, and graphs.

## Features

- Visual simulation of maze traversal
- Demonstrates core data structures and recursion
- Useful for educational purposes

## How to Run

1. Clone or download the repository.
2. Compile the Java files:
javac MazeSolver.java
java MazeSolver
3. Alternatively, run the provided .jar file if available.

## License

This project is licensed under the MIT License.

Files changed (29) hide show
  1. mazeDataStructure/mazeDeneme/.gitignore +29 -0
  2. mazeDataStructure/mazeDeneme/.idea/.gitignore +8 -0
  3. mazeDataStructure/mazeDeneme/.idea/.name +1 -0
  4. mazeDataStructure/mazeDeneme/.idea/misc.xml +6 -0
  5. mazeDataStructure/mazeDeneme/.idea/modules.xml +8 -0
  6. mazeDataStructure/mazeDeneme/.idea/workspace.xml +97 -0
  7. mazeDataStructure/mazeDeneme/game_log.txt +400 -0
  8. mazeDataStructure/mazeDeneme/mazeDeneme.iml +11 -0
  9. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Agent$Node.class +0 -0
  10. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Agent.class +0 -0
  11. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/CircularLinkedList$Node.class +0 -0
  12. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/CircularLinkedList.class +0 -0
  13. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/InputScreen$1.class +0 -0
  14. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/InputScreen.class +0 -0
  15. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Main.class +0 -0
  16. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/MazeManager$1.class +0 -0
  17. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/MazeManager.class +0 -0
  18. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/MazeTile$EntityType.class +0 -0
  19. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/MazeTile.class +0 -0
  20. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Queue.class +0 -0
  21. mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Stack.class +0 -0
  22. mazeDataStructure/mazeDeneme/src/Agent.java +233 -0
  23. mazeDataStructure/mazeDeneme/src/CircularLinkedList.java +65 -0
  24. mazeDataStructure/mazeDeneme/src/InputScreen.java +70 -0
  25. mazeDataStructure/mazeDeneme/src/Main.java +7 -0
  26. mazeDataStructure/mazeDeneme/src/MazeManager.java +392 -0
  27. mazeDataStructure/mazeDeneme/src/MazeTile.java +41 -0
  28. mazeDataStructure/mazeDeneme/src/Queue.java +43 -0
  29. mazeDataStructure/mazeDeneme/src/Stack.java +55 -0
mazeDataStructure/mazeDeneme/.gitignore ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### IntelliJ IDEA ###
2
+ out/
3
+ !**/src/main/**/out/
4
+ !**/src/test/**/out/
5
+
6
+ ### Eclipse ###
7
+ .apt_generated
8
+ .classpath
9
+ .factorypath
10
+ .project
11
+ .settings
12
+ .springBeans
13
+ .sts4-cache
14
+ bin/
15
+ !**/src/main/**/bin/
16
+ !**/src/test/**/bin/
17
+
18
+ ### NetBeans ###
19
+ /nbproject/private/
20
+ /nbbuild/
21
+ /dist/
22
+ /nbdist/
23
+ /.nb-gradle/
24
+
25
+ ### VS Code ###
26
+ .vscode/
27
+
28
+ ### Mac OS ###
29
+ .DS_Store
mazeDataStructure/mazeDeneme/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
mazeDataStructure/mazeDeneme/.idea/.name ADDED
@@ -0,0 +1 @@
 
 
1
+ DataStructuresProject
mazeDataStructure/mazeDeneme/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_24" default="true" project-jdk-name="openjdk-24" project-jdk-type="JavaSDK">
4
+ <output url="file://$PROJECT_DIR$/out" />
5
+ </component>
6
+ </project>
mazeDataStructure/mazeDeneme/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/mazeDeneme.iml" filepath="$PROJECT_DIR$/mazeDeneme.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
mazeDataStructure/mazeDeneme/.idea/workspace.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="b5072dfa-d52e-49ae-8fc0-689c044ffaa8" name="Changes" comment="" />
8
+ <option name="SHOW_DIALOG" value="false" />
9
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
+ <option name="LAST_RESOLUTION" value="IGNORE" />
12
+ </component>
13
+ <component name="FileTemplateManagerImpl">
14
+ <option name="RECENT_TEMPLATES">
15
+ <list>
16
+ <option value="Class" />
17
+ </list>
18
+ </option>
19
+ </component>
20
+ <component name="ProjectColorInfo">{
21
+ &quot;associatedIndex&quot;: 8
22
+ }</component>
23
+ <component name="ProjectId" id="2wApFYymmxPaPZVZ6JOtcKgORsc" />
24
+ <component name="ProjectViewState">
25
+ <option name="foldersAlwaysOnTop" value="false" />
26
+ <option name="hideEmptyMiddlePackages" value="true" />
27
+ <option name="showLibraryContents" value="true" />
28
+ <option name="sortKey" value="BY_TIME_DESCENDING" />
29
+ </component>
30
+ <component name="PropertiesComponent">{
31
+ &quot;keyToString&quot;: {
32
+ &quot;Application.InputScreen.executor&quot;: &quot;Run&quot;,
33
+ &quot;Application.Main.executor&quot;: &quot;Run&quot;,
34
+ &quot;Application.Maze.executor&quot;: &quot;Run&quot;,
35
+ &quot;Application.MazeGame.executor&quot;: &quot;Run&quot;,
36
+ &quot;Application.MazeGenerator.executor&quot;: &quot;Run&quot;,
37
+ &quot;Application.MazeSwing.executor&quot;: &quot;Run&quot;,
38
+ &quot;JavaClassFindUsagesOptions.isSearchForTextOccurrences&quot;: &quot;false&quot;,
39
+ &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
40
+ &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
41
+ &quot;last_opened_file_path&quot;: &quot;C:/Users/anilu/Documents/denizProje&quot;,
42
+ &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
43
+ &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
44
+ &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
45
+ &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
46
+ &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
47
+ &quot;onboarding.tips.debug.path&quot;: &quot;C:/Users/anilu/IdeaProjects/mazeDeneme/src/Main.java&quot;,
48
+ &quot;project.structure.last.edited&quot;: &quot;Project&quot;,
49
+ &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
50
+ &quot;project.structure.side.proportion&quot;: &quot;0.0&quot;,
51
+ &quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;,
52
+ &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
53
+ }
54
+ }</component>
55
+ <component name="SharedIndexes">
56
+ <attachedChunks>
57
+ <set>
58
+ <option value="bundled-jdk-9823dce3aa75-a94e463ab2e7-intellij.indexing.shared.core-IU-243.26053.27" />
59
+ <option value="bundled-js-predefined-d6986cc7102b-1632447f56bf-JavaScript-IU-243.26053.27" />
60
+ </set>
61
+ </attachedChunks>
62
+ </component>
63
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
64
+ <component name="TaskManager">
65
+ <task active="true" id="Default" summary="Default task">
66
+ <changelist id="b5072dfa-d52e-49ae-8fc0-689c044ffaa8" name="Changes" comment="" />
67
+ <created>1745494132492</created>
68
+ <option name="number" value="Default" />
69
+ <option name="presentableId" value="Default" />
70
+ <updated>1745494132492</updated>
71
+ <workItem from="1745494133731" duration="749000" />
72
+ <workItem from="1745494899626" duration="3300000" />
73
+ <workItem from="1745573609389" duration="4342000" />
74
+ <workItem from="1745582449579" duration="1716000" />
75
+ <workItem from="1745684545735" duration="10368000" />
76
+ <workItem from="1745831618109" duration="12238000" />
77
+ <workItem from="1745873259840" duration="1359000" />
78
+ <workItem from="1745932611845" duration="12000" />
79
+ <workItem from="1745933062425" duration="33307000" />
80
+ <workItem from="1746098087868" duration="251000" />
81
+ <workItem from="1746104724431" duration="3438000" />
82
+ <workItem from="1746108904522" duration="7272000" />
83
+ <workItem from="1746182825310" duration="6584000" />
84
+ <workItem from="1746195297418" duration="1770000" />
85
+ <workItem from="1746204440746" duration="2850000" />
86
+ <workItem from="1746208079372" duration="5143000" />
87
+ <workItem from="1746267018747" duration="1521000" />
88
+ <workItem from="1746284021289" duration="10472000" />
89
+ <workItem from="1746299074166" duration="318000" />
90
+ <workItem from="1746362154867" duration="1013000" />
91
+ </task>
92
+ <servers />
93
+ </component>
94
+ <component name="TypeScriptGeneratedFilesManager">
95
+ <option name="version" value="3" />
96
+ </component>
97
+ </project>
mazeDataStructure/mazeDeneme/game_log.txt ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === OYUN BİTTİ ===
2
+ Kazanan Ajan: Mavi Agent (ID: 1)
3
+ Toplam Raunt Sayısı: 106
4
+
5
+ Mavi Agent (ID: 1)
6
+ - Adım Sayısı: 54
7
+ - Tuzak Sayısı: 1
8
+ - Power-Up Kullanımı: 4
9
+ - Hareketler: (0, 0)(0, 1)(0, 2)(0, 3)(0, 4)(1, 4)(1, 5)(1, 6)(1, 7)(2, 7)(2, 8)(1, 8)(0, 8)(0, 7)(0, 8)(0, 9)(1, 9)(1, 10)(1, 9)(1, 10)(2, 10)(2, 9)(2, 8)(1, 8)(0, 8)(0, 9)(1, 9)(1, 10)(2, 10)(2, 9)(3, 9)(3, 8)(4, 8)(5, 8)(5, 9)(5, 10)(4, 10)(4, 11)(4, 12)(4, 13)(4, 14)(5, 14)(5, 13)(5, 12)(6, 12)(7, 12)(7, 11)(6, 11)(6, 10)(6, 8)(7, 8)(7, 7)
10
+ --------------------------
11
+ Turuncu Agent (ID: 2)
12
+ - Adım Sayısı: 53
13
+ - Tuzak Sayısı: 2
14
+ - Power-Up Kullanımı: 7
15
+ - Hareketler: (14, 14)(14, 13)(13, 12)(13, 13)(13, 14)(12, 14)(11, 14)(10, 14)(10, 13)(10, 12)(11, 12)(11, 11)(10, 11)(9, 11)(9, 10)(9, 9)(9, 8)(9, 7)(9, 6)(9, 7)(9, 6)(10, 6)(11, 6)(11, 7)(10, 7)(10, 8)(11, 8)(12, 8)(13, 8)(13, 7)(12, 7)(12, 6)(13, 6)(13, 5)(13, 6)(13, 5)(14, 5)(14, 4)(14, 3)(14, 2)(14, 1)(14, 0)(14, 1)(14, 2)(14, 1)(14, 0)(13, 0)(13, 1)(13, 2)(13, 3)(13, 4)
16
+ --------------------------
17
+ === OYUN BİTTİ ===
18
+ Kazanan Ajan: Turuncu Agent (ID: 2)
19
+ Toplam Raunt Sayısı: 47
20
+
21
+ Turuncu Agent (ID: 2)
22
+ - Adım Sayısı: 24
23
+ - Tuzak Sayısı: 0
24
+ - Power-Up Kullanımı: 0
25
+ - Hareketler: (9, 9)(8, 9)(8, 8)(9, 8)(9, 7)(8, 7)(7, 7)(7, 8)(7, 9)(6, 9)(5, 9)(4, 9)(3, 9)(2, 9)(1, 9)(0, 9)(0, 8)(1, 8)(2, 8)(2, 7)(2, 6)(3, 6)(4, 6)(4, 5)(5, 5)
26
+ --------------------------
27
+ Mavi Agent (ID: 1)
28
+ - Adım Sayısı: 24
29
+ - Tuzak Sayısı: 0
30
+ - Power-Up Kullanımı: 0
31
+ - Hareketler: (0, 0)(1, 0)(2, 0)(2, 1)(2, 2)(3, 2)(3, 1)(4, 1)(5, 1)(6, 1)(6, 2)(5, 2)(4, 2)(4, 3)(4, 4)(5, 4)(6, 4)(6, 3)(7, 3)(7, 2)(7, 1)(8, 1)(8, 0)(9, 0)(9, 1)
32
+ --------------------------
33
+ === OYUN BİTTİ ===
34
+ Kazanan Ajan: Turuncu Agent (ID: 2)
35
+ Toplam Raunt Sayısı: 15
36
+
37
+ Turuncu Agent (ID: 2)
38
+ - Adım Sayısı: 8
39
+ - Tuzak Sayısı: 0
40
+ - Power-Up Kullanımı: 1
41
+ - Hareketler: (9, 9)(8, 9)(7, 9)(6, 9)(5, 9)(5, 8)(5, 7)(5, 6)(5, 5)
42
+ --------------------------
43
+ Mavi Agent (ID: 1)
44
+ - Adım Sayısı: 8
45
+ - Tuzak Sayısı: 0
46
+ - Power-Up Kullanımı: 0
47
+ - Hareketler: (0, 0)(0, 1)(1, 1)(1, 2)(0, 2)(0, 3)(1, 3)(2, 3)(2, 4)
48
+ --------------------------
49
+ === OYUN BİTTİ ===
50
+ Kazanan Ajan: Turuncu Agent (ID: 2)
51
+ Toplam Raunt Sayısı: 23
52
+
53
+ Turuncu Agent (ID: 2)
54
+ - Adım Sayısı: 12
55
+ - Tuzak Sayısı: 0
56
+ - Power-Up Kullanımı: 0
57
+ - Hareketler: (9, 9)(8, 9)(7, 9)(7, 8)(6, 8)(5, 8)(5, 7)(6, 7)(7, 7)(7, 6)(6, 6)(5, 6)(5, 5)
58
+ --------------------------
59
+ Mavi Agent (ID: 1)
60
+ - Adım Sayısı: 12
61
+ - Tuzak Sayısı: 1
62
+ - Power-Up Kullanımı: 0
63
+ - Hareketler: (0, 0)(0, 1)(1, 1)(1, 0)(2, 0)(2, 1)(3, 1)(3, 0)(4, 0)(4, 2)
64
+ --------------------------
65
+ === OYUN BİTTİ ===
66
+ Kazanan Ajan: Turuncu Agent (ID: 2)
67
+ Toplam Raunt Sayısı: 85
68
+
69
+ Turuncu Agent (ID: 2)
70
+ - Adım Sayısı: 43
71
+ - Tuzak Sayısı: 4
72
+ - Power-Up Kullanımı: 1
73
+ - Hareketler: (14, 9)(14, 8)(14, 6)(14, 5)(14, 4)(14, 3)(13, 3)(13, 2)(14, 2)(14, 1)(14, 0)(12, 0)(12, 1)(12, 3)(12, 4)(13, 4)(13, 5)(13, 6)(13, 7)(13, 8)(12, 8)(11, 8)(11, 9)(10, 9)(10, 8)(10, 7)(11, 6)(10, 6)(9, 6)(8, 6)(7, 6)(7, 5)
74
+ --------------------------
75
+ Mavi Agent (ID: 1)
76
+ - Adım Sayısı: 43
77
+ - Tuzak Sayısı: 4
78
+ - Power-Up Kullanımı: 0
79
+ - Hareketler: (0, 0)(0, 1)(1, 1)(1, 2)(1, 3)(2, 3)(2, 4)(2, 5)(3, 5)(3, 4)(3, 3)(3, 2)(2, 1)(3, 0)(3, 1)(4, 1)(4, 2)(5, 2)(5, 3)(5, 4)(6, 4)(6, 3)(7, 2)(8, 2)(8, 1)(8, 0)(9, 0)(9, 1)(10, 1)(10, 0)(11, 0)(11, 1)(11, 2)(10, 2)(10, 3)
80
+ --------------------------
81
+ === OYUN BİTTİ ===
82
+ Kazanan Ajan: Turuncu Agent (ID: 2)
83
+ Toplam Raunt Sayısı: 15
84
+
85
+ Turuncu Agent (ID: 2)
86
+ - Adım Sayısı: 8
87
+ - Tuzak Sayısı: 0
88
+ - Power-Up Kullanımı: 0
89
+ - Hareketler: (9, 9)(8, 9)(7, 9)(7, 8)(6, 8)(6, 7)(6, 6)(5, 6)(5, 5)
90
+ --------------------------
91
+ Mavi Agent (ID: 1)
92
+ - Adım Sayısı: 8
93
+ - Tuzak Sayısı: 0
94
+ - Power-Up Kullanımı: 0
95
+ - Hareketler: (0, 0)(1, 0)(1, 1)(1, 2)(0, 2)(0, 3)(0, 4)(0, 5)(0, 6)
96
+ --------------------------
97
+ === OYUN BİTTİ ===
98
+ Kazanan Ajan: Turuncu Agent (ID: 2)
99
+ Toplam Raunt Sayısı: 59
100
+
101
+ Turuncu Agent (ID: 2)
102
+ - Adım Sayısı: 30
103
+ - Tuzak Sayısı: 3
104
+ - Power-Up Kullanımı: 3
105
+ - Hareketler: (9, 9)(8, 9)(7, 9)(6, 9)(6, 8)(6, 7)(6, 6)(7, 6)(7, 6)(7, 7)(7, 6)(7, 7)(8, 7)(9, 7)(9, 6)(9, 5)(9, 4)(7, 4)(6, 3)(5, 3)(5, 4)(5, 5)
106
+ --------------------------
107
+ Mavi Agent (ID: 1)
108
+ - Adım Sayısı: 30
109
+ - Tuzak Sayısı: 0
110
+ - Power-Up Kullanımı: 0
111
+ - Hareketler: (0, 0)(0, 1)(0, 2)(0, 3)(0, 4)(1, 4)(1, 3)(1, 2)(2, 2)(2, 3)(3, 3)(4, 3)(4, 4)(3, 4)(2, 4)(2, 5)(1, 5)(1, 6)(0, 6)(0, 7)(0, 8)(1, 8)(1, 9)(2, 9)(3, 9)(3, 8)(4, 8)(4, 9)(5, 9)(5, 8)(5, 7)
112
+ --------------------------
113
+ === Game Over ===
114
+ Winner Agent: Blue Agent (ID: 1)
115
+ Number of rount played: 22
116
+
117
+ Blue Agent (ID: 1)
118
+ - Step number: 12
119
+ - Trap number: 0
120
+ - Power-Up usage: 0
121
+ - Moves: (0, 0)(1, 0)(2, 0)(3, 0)(3, 1)(3, 2)(4, 2)(4, 3)(5, 3)(5, 4)(4, 4)(4, 5)(5, 5)
122
+ --------------------------
123
+ Orange Agent (ID: 2)
124
+ - Step number: 11
125
+ - Trap number: 1
126
+ - Power-Up usage: 0
127
+ - Moves: (9, 9)(9, 8)(8, 8)(7, 8)(6, 8)(6, 7)(8, 7)(9, 7)(9, 6)
128
+ --------------------------
129
+ === Game Over ===
130
+ Winner Agent: Orange Agent (ID: 2)
131
+ Number of rount played: 59
132
+
133
+ Orange Agent (ID: 2)
134
+ - Step number: 30
135
+ - Trap number: 1
136
+ - Power-Up usage: 0
137
+ - Moves: (9, 9)(9, 8)(9, 7)(9, 6)(9, 5)(9, 4)(9, 3)(9, 2)(8, 2)(8, 1)(9, 1)(9, 0)(8, 0)(6, 0)(6, 1)(7, 1)(7, 2)(7, 3)(7, 4)(8, 4)(8, 5)(7, 5)(6, 5)(6, 4)(5, 4)(4, 4)(4, 5)(5, 5)
138
+ --------------------------
139
+ Blue Agent (ID: 1)
140
+ - Step number: 30
141
+ - Trap number: 1
142
+ - Power-Up usage: 1
143
+ - Moves: (0, 0)(1, 1)(0, 1)(0, 2)(0, 3)(0, 4)(0, 5)(0, 6)(1, 6)(1, 5)(1, 4)(1, 3)(1, 2)(2, 2)(2, 1)(3, 1)(4, 1)(5, 1)(5, 2)(4, 2)(4, 3)(3, 3)(3, 4)(3, 5)(2, 5)(2, 6)(2, 7)(2, 8)
144
+ --------------------------
145
+ === Game Over ===
146
+ Winner Agent: Orange Agent (ID: 2)
147
+ Number of rount played: 31
148
+
149
+ Orange Agent (ID: 2)
150
+ - Step number: 16
151
+ - Trap number: 0
152
+ - Power-Up usage: 0
153
+ - Moves: (9, 9)(8, 9)(7, 9)(7, 8)(8, 8)(8, 7)(8, 6)(8, 5)(9, 5)(9, 4)(8, 4)(7, 4)(7, 5)(6, 5)(6, 4)(5, 4)(5, 5)
154
+ --------------------------
155
+ Blue Agent (ID: 1)
156
+ - Step number: 16
157
+ - Trap number: 1
158
+ - Power-Up usage: 0
159
+ - Moves: (0, 0)(1, 0)(1, 1)(0, 1)(0, 2)(0, 3)(1, 3)(2, 3)(2, 2)(2, 1)(3, 1)(3, 0)(4, 0)(4, 1)
160
+ --------------------------
161
+ === Game Over ===
162
+ Winner Agent: Blue Agent (ID: 1)
163
+ Number of rount played: 22
164
+
165
+ Blue Agent (ID: 1)
166
+ - Step number: 12
167
+ - Trap number: 1
168
+ - Power-Up usage: 0
169
+ - Moves: (0, 0)(1, 0)(2, 0)(2, 1)(1, 1)(1, 2)(1, 3)(2, 3)(3, 3)(3, 4)(4, 4)(5, 4)(5, 5)
170
+ --------------------------
171
+ Orange Agent (ID: 2)
172
+ - Step number: 11
173
+ - Trap number: 0
174
+ - Power-Up usage: 0
175
+ - Moves: (9, 9)(9, 8)(8, 8)(7, 8)(6, 8)(6, 9)(5, 9)(5, 8)(5, 7)(6, 7)(7, 7)(7, 6)
176
+ --------------------------
177
+ === Game Over ===
178
+ Winner Agent: Orange Agent (ID: 2)
179
+ Number of rount played: 27
180
+
181
+ Orange Agent (ID: 2)
182
+ - Step number: 14
183
+ - Trap number: 0
184
+ - Power-Up usage: 0
185
+ - Moves: null(9, 9)(9, 8)(9, 7)(9, 6)(8, 6)(8, 7)(7, 7)(7, 6)(7, 5)(8, 5)(8, 4)(7, 4)(6, 4)(6, 5)
186
+ --------------------------
187
+ Blue Agent (ID: 1)
188
+ - Step number: 14
189
+ - Trap number: 0
190
+ - Power-Up usage: 1
191
+ - Moves: null(0, 0)(1, 0)(2, 0)(3, 0)(3, 1)(4, 1)(5, 1)(5, 2)(5, 3)(5, 4)(4, 4)(3, 4)(3, 5)(3, 6)
192
+ --------------------------
193
+ === Game Over ===
194
+ Winner Agent: Orange Agent (ID: 2)
195
+ Number of rount played: 23
196
+
197
+ Orange Agent (ID: 2)
198
+ - Step number: 12
199
+ - Trap number: 0
200
+ - Power-Up usage: 0
201
+ - Moves: null(9, 9)(8, 9)(8, 8)(8, 7)(9, 7)(9, 6)(8, 6)(7, 6)(7, 5)(6, 5)(6, 6)(5, 6)
202
+ --------------------------
203
+ Blue Agent (ID: 1)
204
+ - Step number: 12
205
+ - Trap number: 0
206
+ - Power-Up usage: 0
207
+ - Moves: null(0, 0)(0, 1)(0, 2)(0, 3)(1, 3)(1, 4)(1, 5)(0, 5)(0, 6)(0, 7)(0, 8)(1, 8)
208
+ --------------------------
209
+ === Game Over ===
210
+ Winner Agent: Blue Agent (ID: 1)
211
+ Number of rount played: 66
212
+
213
+ Blue Agent (ID: 1)
214
+ - Step number: 34
215
+ - Trap number: 2
216
+ - Power-Up usage: 1
217
+ - Moves: null(0, 0)(0, 1)(1, 1)(1, 2)(2, 2)(2, 3)(1, 3)(1, 4)(0, 4)(0, 5)(1, 5)(2, 5)(2, 6)(1, 6)(0, 6)(0, 7)(0, 8)(0, 9)(1, 9)(2, 9)(2, 8)(2, 7)(3, 7)(4, 7)(4, 6)(5, 6)(6, 6)(6, 5)
218
+ --------------------------
219
+ Orange Agent (ID: 2)
220
+ - Step number: 33
221
+ - Trap number: 1
222
+ - Power-Up usage: 2
223
+ - Moves: null(9, 9)(8, 9)(8, 8)(9, 8)(9, 7)(9, 6)(9, 5)(9, 4)(8, 4)(8, 5)(8, 6)(7, 6)(7, 5)(7, 4)(7, 3)(8, 3)(9, 3)(9, 2)(9, 3)(9, 2)(9, 1)(8, 1)(8, 2)(8, 3)(9, 3)(9, 2)(9, 1)(8, 1)(8, 0)(7, 0)
224
+ --------------------------
225
+ === Game Over ===
226
+ Winner Agent: Blue Agent (ID: 1)
227
+ Number of rount played: 70
228
+
229
+ Blue Agent (ID: 1)
230
+ - Step number: 36
231
+ - Trap number: 2
232
+ - Power-Up usage: 0
233
+ - Moves: null(0, 0)(1, 0)(2, 0)(3, 0)(4, 0)(5, 0)(5, 1)(6, 1)(6, 2)(5, 2)(5, 3)(6, 3)(7, 3)(8, 3)(8, 4)(9, 4)(9, 5)(9, 6)(9, 7)(8, 7)(7, 7)(7, 6)(8, 6)(8, 5)(7, 5)(7, 4)(6, 4)(6, 5)(6, 6)(5, 6)
234
+ --------------------------
235
+ Orange Agent (ID: 2)
236
+ - Step number: 35
237
+ - Trap number: 1
238
+ - Power-Up usage: 2
239
+ - Moves: null(9, 9)(8, 9)(8, 8)(7, 8)(6, 8)(6, 7)(5, 7)(5, 8)(5, 9)(4, 9)(3, 9)(2, 9)(1, 9)(0, 9)(0, 8)(1, 8)(1, 7)(0, 7)(0, 6)(1, 6)(2, 6)(2, 7)(3, 7)(4, 7)(4, 6)(3, 6)(3, 5)(2, 5)(3, 5)(2, 5)(1, 5)(2, 5)
240
+ --------------------------
241
+ === Game Over ===
242
+ Winner Agent: Orange Agent (ID: 2)
243
+ Number of rount played: 39
244
+
245
+ Orange Agent (ID: 2)
246
+ - Step number: 20
247
+ - Trap number: 0
248
+ - Power-Up usage: 4
249
+ - Moves: null(9, 9)(9, 8)(9, 7)(9, 6)(9, 5)(9, 4)(8, 4)(8, 5)(7, 5)(6, 5)(6, 4)(7, 4)(7, 3)(7, 2)(7, 3)(7, 2)(6, 2)(6, 3)(5, 3)(5, 4)
250
+ --------------------------
251
+ Blue Agent (ID: 1)
252
+ - Step number: 20
253
+ - Trap number: 1
254
+ - Power-Up usage: 0
255
+ - Moves: null(0, 0)(1, 0)(2, 0)(2, 1)(2, 2)(1, 2)(0, 2)(0, 3)(1, 3)(1, 4)(0, 4)(0, 5)(1, 5)(2, 5)(2, 6)(1, 6)(0, 6)
256
+ --------------------------
257
+ === Game Over ===
258
+ Winner Agent: Orange Agent (ID: 2)
259
+ Number of rount played: 25
260
+
261
+ Orange Agent (ID: 2)
262
+ - Step number: 13
263
+ - Trap number: 1
264
+ - Power-Up usage: 0
265
+ - Moves: null(9, 9)(9, 8)(9, 7)(8, 7)(8, 6)(8, 5)(7, 5)(7, 4)(6, 4)(5, 4)
266
+ --------------------------
267
+ Blue Agent (ID: 1)
268
+ - Step number: 13
269
+ - Trap number: 0
270
+ - Power-Up usage: 0
271
+ - Moves: null(0, 0)(1, 0)(1, 1)(1, 2)(1, 3)(0, 3)(0, 4)(0, 5)(0, 6)(1, 6)(2, 6)(2, 5)(1, 5)
272
+ --------------------------
273
+ === Game Over ===
274
+ Winner Agent: Orange Agent (ID: 2)
275
+ Number of rount played: 19
276
+
277
+ Orange Agent (ID: 2)
278
+ - Step number: 10
279
+ - Trap number: 0
280
+ - Power-Up usage: 0
281
+ - Moves: null(9, 9)(8, 9)(8, 8)(7, 8)(7, 7)(6, 7)(6, 6)(7, 6)(7, 5)(6, 5)
282
+ --------------------------
283
+ Blue Agent (ID: 1)
284
+ - Step number: 10
285
+ - Trap number: 0
286
+ - Power-Up usage: 0
287
+ - Moves: null(0, 0)(1, 0)(2, 0)(2, 1)(1, 1)(1, 2)(0, 2)(0, 3)(0, 4)(1, 4)
288
+ --------------------------
289
+ === Game Over ===
290
+ Winner Agent: Orange Agent (ID: 2)
291
+ Number of rount played: 63
292
+
293
+ Orange Agent (ID: 2)
294
+ - Step number: 32
295
+ - Trap number: 1
296
+ - Power-Up usage: 1
297
+ - Moves: (9, 9)(9, 8)(8, 8)(7, 8)(7, 7)(7, 6)(8, 6)(8, 7)(9, 7)(9, 6)(9, 5)(8, 5)(7, 5)(7, 4)(6, 4)(6, 3)(7, 3)(7, 2)(9, 2)(9, 1)(8, 1)(7, 1)(7, 0)(6, 0)(6, 1)(6, 2)(5, 2)(5, 3)(5, 4)(5, 5)
298
+ --------------------------
299
+ Blue Agent (ID: 1)
300
+ - Step number: 32
301
+ - Trap number: 1
302
+ - Power-Up usage: 2
303
+ - Moves: (0, 0)(0, 1)(0, 2)(0, 3)(0, 4)(0, 5)(0, 6)(0, 7)(0, 8)(0, 9)(1, 9)(2, 9)(3, 9)(3, 7)(4, 7)(5, 7)(5, 8)(6, 8)(6, 9)(7, 9)(8, 9)(9, 9)(9, 8)(9, 7)(9, 6)(9, 5)(8, 5)(8, 4)(8, 3)(9, 3)
304
+ --------------------------
305
+ === Game Over ===
306
+ Winner Agent: Orange Agent (ID: 2)
307
+ Number of rount played: 7
308
+
309
+ Orange Agent (ID: 2)
310
+ - Step number: 4
311
+ - Trap number: 0
312
+ - Power-Up usage: 0
313
+ - Moves: (4, 4)(4, 3)(4, 2)(3, 2)(2, 2)
314
+ --------------------------
315
+ Blue Agent (ID: 1)
316
+ - Step number: 4
317
+ - Trap number: 0
318
+ - Power-Up usage: 0
319
+ - Moves: (0, 0)(1, 0)(2, 0)(3, 0)(3, 1)
320
+ --------------------------
321
+ === Game Over ===
322
+ Winner Agent: Orange Agent (ID: 2)
323
+ Number of rount played: 27
324
+
325
+ Orange Agent (ID: 2)
326
+ - Step number: 14
327
+ - Trap number: 1
328
+ - Power-Up usage: 0
329
+ - Moves: (9, 9)(9, 8)(8, 8)(8, 7)(9, 7)(9, 5)(8, 5)(7, 5)(7, 6)(6, 6)(5, 6)(5, 5)
330
+ --------------------------
331
+ Blue Agent (ID: 1)
332
+ - Step number: 14
333
+ - Trap number: 0
334
+ - Power-Up usage: 1
335
+ - Moves: (0, 0)(1, 0)(2, 0)(3, 0)(4, 0)(4, 1)(5, 1)(6, 1)(6, 0)(7, 0)(8, 0)(9, 0)(9, 1)(9, 2)(9, 3)
336
+ --------------------------
337
+ === Game Over ===
338
+ Winner Agent: Blue Agent (ID: 1)
339
+ Number of rount played: 42
340
+
341
+ Blue Agent (ID: 1)
342
+ - Step number: 22
343
+ - Trap number: 2
344
+ - Power-Up usage: 1
345
+ - Moves: (0, 0)(1, 0)(1, 1)(0, 1)(0, 2)(1, 3)(2, 3)(2, 2)(3, 2)(4, 3)(5, 3)(6, 3)(6, 4)(7, 4)(7, 5)(6, 5)(5, 5)
346
+ --------------------------
347
+ Orange Agent (ID: 2)
348
+ - Step number: 21
349
+ - Trap number: 1
350
+ - Power-Up usage: 0
351
+ - Moves: (9, 9)(8, 9)(7, 9)(6, 9)(5, 9)(4, 9)(3, 9)(2, 9)(0, 9)(0, 8)(1, 8)(2, 8)(2, 7)(3, 7)(3, 8)(4, 8)(4, 7)(4, 6)(4, 5)
352
+ --------------------------
353
+ === Game Over ===
354
+ Winner Agent: Orange Agent (ID: 2)
355
+ Number of rount played: 27
356
+
357
+ Orange Agent (ID: 2)
358
+ - Step number: 14
359
+ - Trap number: 0
360
+ - Power-Up usage: 4
361
+ - Moves: (9, 9)(8, 9)(7, 9)(7, 8)(8, 8)(9, 8)(9, 7)(9, 6)(9, 5)(8, 5)(7, 5)(6, 5)(7, 5)(6, 5)(5, 5)
362
+ --------------------------
363
+ Blue Agent (ID: 1)
364
+ - Step number: 14
365
+ - Trap number: 1
366
+ - Power-Up usage: 0
367
+ - Moves: (0, 0)(0, 1)(0, 2)(0, 3)(1, 3)(2, 3)(3, 3)(3, 2)(5, 2)(6, 2)(7, 2)(7, 1)
368
+ --------------------------
369
+ === Game Over ===
370
+ Winner Agent: Orange Agent (ID: 2)
371
+ Number of rount played: 23
372
+
373
+ Orange Agent (ID: 2)
374
+ - Step number: 12
375
+ - Trap number: 0
376
+ - Power-Up usage: 0
377
+ - Moves: (9, 9)(8, 9)(8, 8)(9, 8)(9, 7)(8, 7)(8, 6)(8, 5)(7, 5)(7, 6)(6, 6)(6, 5)(5, 5)
378
+ --------------------------
379
+ Blue Agent (ID: 1)
380
+ - Step number: 12
381
+ - Trap number: 0
382
+ - Power-Up usage: 3
383
+ - Moves: (0, 0)(1, 0)(2, 0)(3, 0)(3, 1)(4, 1)(4, 0)(5, 0)(6, 0)(6, 1)(6, 2)(6, 3)(6, 4)
384
+ --------------------------
385
+ === Game Over ===
386
+ Winner Agent: Orange Agent (ID: 2)
387
+ Number of rount played: 215
388
+
389
+ Orange Agent (ID: 2)
390
+ - Step number: 108
391
+ - Trap number: 7
392
+ - Power-Up usage: 4
393
+ - Moves: (19, 19)(19, 18)(18, 18)(17, 19)(16, 19)(16, 18)(16, 17)(15, 17)(15, 16)(16, 16)(17, 16)(17, 15)(17, 14)(16, 14)(16, 13)(17, 13)(17, 12)(14, 12)(14, 13)(15, 14)(14, 14)(13, 14)(13, 13)(13, 12)(12, 12)(12, 11)(12, 10)(12, 9)(13, 9)(13, 8)(14, 8)(14, 7)(14, 6)(15, 6)(15, 5)(16, 5)(17, 6)(17, 7)(18, 7)(18, 8)(18, 9)(19, 9)(19, 8)(19, 7)(19, 6)(19, 7)(19, 6)(18, 6)(18, 5)(18, 6)(18, 5)(19, 5)(19, 4)(19, 3)(19, 2)(19, 1)(18, 0)(17, 0)(16, 0)(16, 1)(17, 1)(18, 1)(18, 2)(18, 3)(18, 4)(17, 4)(16, 4)(15, 4)(14, 4)(14, 3)(13, 3)(13, 4)(12, 4)(11, 4)(11, 5)(10, 6)(9, 6)(9, 5)(8, 5)(8, 6)(8, 7)(9, 7)(9, 8)(10, 8)(11, 8)(11, 9)(11, 10)(10, 10)
394
+ --------------------------
395
+ Blue Agent (ID: 1)
396
+ - Step number: 108
397
+ - Trap number: 3
398
+ - Power-Up usage: 6
399
+ - Moves: (0, 0)(1, 0)(1, 1)(2, 1)(3, 1)(4, 1)(5, 1)(5, 0)(6, 0)(7, 0)(8, 0)(9, 0)(10, 0)(10, 1)(9, 1)(8, 1)(8, 2)(7, 2)(6, 2)(6, 3)(5, 3)(5, 2)(4, 2)(4, 3)(3, 3)(3, 2)(2, 2)(1, 2)(2, 2)(1, 2)(0, 2)(1, 2)(0, 2)(1, 2)(0, 2)(0, 3)(1, 3)(1, 4)(2, 4)(2, 5)(3, 5)(3, 6)(2, 6)(3, 6)(2, 6)(2, 7)(1, 7)(1, 8)(2, 8)(2, 9)(3, 9)(4, 9)(5, 9)(5, 8)(5, 7)(6, 7)(6, 6)(5, 6)(5, 5)(5, 4)(6, 4)(7, 4)(8, 4)(8, 3)(9, 3)(10, 3)(11, 3)(11, 2)(12, 2)(13, 2)(14, 2)(15, 2)(15, 1)(14, 1)(14, 0)(16, 0)(16, 1)(17, 1)(18, 1)(18, 2)(18, 3)(18, 4)(17, 4)(16, 4)(15, 4)(14, 4)(14, 3)(13, 3)(13, 4)(12, 4)(11, 4)(11, 5)(10, 5)(10, 6)(9, 6)(9, 5)(8, 5)(8, 6)(8, 7)(9, 7)(10, 8)(11, 8)(11, 9)
400
+ --------------------------
mazeDataStructure/mazeDeneme/mazeDeneme.iml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7
+ </content>
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ </component>
11
+ </module>
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Agent$Node.class ADDED
Binary file (567 Bytes). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Agent.class ADDED
Binary file (5.93 kB). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/CircularLinkedList$Node.class ADDED
Binary file (689 Bytes). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/CircularLinkedList.class ADDED
Binary file (1.94 kB). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/InputScreen$1.class ADDED
Binary file (688 Bytes). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/InputScreen.class ADDED
Binary file (2.66 kB). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Main.class ADDED
Binary file (389 Bytes). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/MazeManager$1.class ADDED
Binary file (726 Bytes). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/MazeManager.class ADDED
Binary file (12.3 kB). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/MazeTile$EntityType.class ADDED
Binary file (1.2 kB). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/MazeTile.class ADDED
Binary file (1.26 kB). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Queue.class ADDED
Binary file (1.49 kB). View file
 
mazeDataStructure/mazeDeneme/out/production/mazeDeneme/Stack.class ADDED
Binary file (1.44 kB). View file
 
mazeDataStructure/mazeDeneme/src/Agent.java ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import java.awt.Color;
2
+ import java.util.Random;
3
+
4
+ public class Agent {
5
+ private int x, y;
6
+ private final int id;
7
+ private final MazeManager maze;
8
+ private final Color color;
9
+ private final String name;
10
+
11
+ private boolean phaseWallUsed = false;
12
+ private boolean passedWall = false;
13
+ private final Stack<String> moveHistory;
14
+ private final Random random = new Random();
15
+ private boolean gotPowerUp = false;
16
+
17
+ private int powerUpUses = 0;
18
+ private int stepCount = 0;
19
+ private int trapHits = 0;
20
+
21
+
22
+ public Agent(int startX, int startY, MazeManager maze, Color color, String name, int id) {
23
+ this.id=id;
24
+ this.x = startX;
25
+ this.y = startY;
26
+ this.maze = maze;
27
+ this.color = color;
28
+
29
+ this.name = name;
30
+ this.moveHistory = new Stack<>(maze.getCols() * maze.getRows());
31
+ moveHistory.push("(" + x + ", " + y + ")");
32
+ }
33
+
34
+ public int getId()
35
+ {
36
+ return id;
37
+ }
38
+
39
+ public int getX() {
40
+ return x;
41
+ }
42
+
43
+ public int getY() {
44
+ return y;
45
+ }
46
+
47
+ public Color getColor() {
48
+ return color;
49
+ }
50
+
51
+ public int getTrapHits() {
52
+ return trapHits;
53
+ }
54
+
55
+ public String getName() {
56
+ return name;
57
+ }
58
+
59
+ public Stack<String> getMoveHistory() {
60
+ return moveHistory;
61
+ }
62
+
63
+ public boolean passedWallThisTurn() {
64
+ return passedWall;
65
+ }
66
+
67
+ public void setPassedWall(boolean value) {
68
+ this.passedWall = value;
69
+ }
70
+
71
+ public int getStepCount() {
72
+ return stepCount;
73
+ }
74
+
75
+
76
+ public int getPowerUpUses() {
77
+ return powerUpUses;
78
+ }
79
+
80
+ public void moveTowardsGoal() {
81
+ boolean canPhaseWall = false;
82
+
83
+ if (gotPowerUp && !phaseWallUsed) {
84
+ if (random.nextInt(100) < 20) {
85
+ canPhaseWall = true;
86
+ passedWall = true;
87
+ powerUpUses++;
88
+ }
89
+ } else {
90
+ passedWall = false;
91
+ }
92
+
93
+ Node[] openSet = new Node[maze.getCols() * maze.getRows()];
94
+ boolean[][] closedSet = new boolean[maze.getCols()][maze.getRows()];
95
+ int openSetSize = 0;
96
+
97
+ int goalX = maze.getCols() / 2;
98
+ int goalY = maze.getRows() / 2;
99
+
100
+ Node start = new Node(x, y, null, 0, heuristic(x, y, goalX, goalY));
101
+ openSet[openSetSize++] = start;
102
+ Node goalNode = null;
103
+
104
+ while (openSetSize > 0) {
105
+ int bestIndex = 0;
106
+ for (int i = 1; i < openSetSize; i++) {
107
+ if (openSet[i].f < openSet[bestIndex].f) bestIndex = i;
108
+ }
109
+ Node current = openSet[bestIndex];
110
+ openSet[bestIndex] = openSet[--openSetSize];
111
+
112
+ if (current.x == goalX && current.y == goalY) {
113
+ goalNode = current;
114
+ break;
115
+ }
116
+
117
+ closedSet[current.x][current.y] = true;
118
+
119
+ for (int dir = 0; dir < 4; dir++) {
120
+ int nx = current.x;
121
+ int ny = current.y;
122
+ switch (dir) {
123
+ case 0:
124
+ ny--;
125
+ break;
126
+ case 1:
127
+ nx++;
128
+ break;
129
+ case 2:
130
+ ny++;
131
+ break;
132
+ case 3:
133
+ nx--;
134
+ break;
135
+ }
136
+ if (!maze.isInMaze(nx, ny)) {
137
+ continue;
138
+ }
139
+ boolean isWall = maze.hasWall(current.x, current.y, dir);
140
+ if (isWall && !canPhaseWall) {
141
+ continue;
142
+ }
143
+ if (closedSet[nx][ny]) {
144
+ continue;
145
+ }
146
+
147
+ boolean alreadyInOpenSet = false;
148
+ for (int i = 0; i < openSetSize; i++) {
149
+ if (openSet[i].x == nx && openSet[i].y == ny) {
150
+ alreadyInOpenSet = true;
151
+ break;
152
+ }
153
+ }
154
+
155
+ if (!alreadyInOpenSet) {
156
+ openSet[openSetSize++] = new Node(nx, ny, current,
157
+ current.g + 1, heuristic(nx, ny, goalX, goalY));
158
+ }
159
+ }
160
+ }
161
+
162
+ if (goalNode != null && goalNode.parent != null) {
163
+ Node moveTo = goalNode;
164
+ while (moveTo.parent.parent != null) {
165
+ moveTo = moveTo.parent;
166
+ }
167
+
168
+ int oldX = x;
169
+ int oldY = y;
170
+
171
+ if (maze.hasWall(x, y, directionTo(moveTo.x, moveTo.y)) && canPhaseWall) {
172
+ phaseWallUsed = true;
173
+ }
174
+
175
+ this.x = moveTo.x;
176
+ this.y = moveTo.y;
177
+
178
+ if (x != oldX || y != oldY) {
179
+ moveHistory.push("(" + x + ", " + y + ")");
180
+ stepCount++;
181
+ }
182
+
183
+ MazeTile tile = maze.getTile(x, y);
184
+ if (tile.getEntity() == MazeTile.EntityType.TRAP && tile.isTrapActive()) {
185
+ tile.deactivateTrap();
186
+ trapHits++;
187
+ stepBackTwice();
188
+ }
189
+ if (tile.getEntity() == MazeTile.EntityType.POWER_UP && tile.isPowerUpActive()) {
190
+ tile.deactivatePowerUp();
191
+ gotPowerUp = true;
192
+ phaseWallUsed = false;
193
+ }
194
+ }
195
+ }
196
+
197
+ private int directionTo(int toX, int toY) {
198
+ if (toX == x + 1) return 1;
199
+ if (toX == x - 1) return 3;
200
+ if (toY == y + 1) return 2;
201
+ if (toY == y - 1) return 0;
202
+ return -1;
203
+ }
204
+
205
+ private void stepBackTwice() {
206
+ if (moveHistory.getSize() < 3) return;
207
+ moveHistory.pop();
208
+ moveHistory.pop();
209
+ String coord = (String) moveHistory.pop();
210
+ String[] parts = coord.replace("(", "").replace(")", "").split(", ");
211
+ this.x = Integer.parseInt(parts[0]);
212
+ this.y = Integer.parseInt(parts[1]);
213
+ }
214
+
215
+ private int heuristic(int x1, int y1, int x2, int y2) {
216
+ return Math.abs(x1 - x2) + Math.abs(y1 - y2);
217
+ }
218
+
219
+ private static class Node {
220
+ int x, y;
221
+ Node parent;
222
+ int g;
223
+ int f;
224
+
225
+ public Node(int x, int y, Node parent, int g, int h) {
226
+ this.x = x;
227
+ this.y = y;
228
+ this.parent = parent;
229
+ this.g = g;
230
+ this.f = g + h;
231
+ }
232
+ }
233
+ }
mazeDataStructure/mazeDeneme/src/CircularLinkedList.java ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ public class CircularLinkedList<T> {
2
+ private Node<T> head;
3
+ private int size = 0;
4
+
5
+ public void add(T data) {
6
+ Node<T> newNode = new Node<>(data);
7
+ if (head == null) {
8
+ head = newNode;
9
+ head.next = head;
10
+ head.prev = head;
11
+ } else {
12
+ Node<T> last = head.prev;
13
+
14
+ last.next = newNode;
15
+ newNode.prev = last;
16
+
17
+ newNode.next = head;
18
+ head.prev = newNode;
19
+ }
20
+ size++;
21
+ }
22
+
23
+ public void rotateOneStep(int steps) {
24
+ if (head == null || steps <= 0)
25
+ {
26
+ return;
27
+ }
28
+ for (int i = 0; i < steps; i++) {
29
+ head = head.prev;
30
+ }
31
+ }
32
+
33
+
34
+ public T get(int index) {
35
+ if (index < 0 || index >= size);
36
+ Node<T> current = head;
37
+ for (int i = 0; i < index; i++) {
38
+ current = current.next;
39
+ }
40
+ return current.data;
41
+ }
42
+
43
+ public void toArray(T[] array) {
44
+ if (array.length < size) ;
45
+ Node<T> curr = head;
46
+ for (int i = 0; i < size; i++) {
47
+ array[i] = curr.data;
48
+ curr = curr.next;
49
+ }
50
+ }
51
+
52
+ public int size() {
53
+ return size;
54
+ }
55
+
56
+ public static class Node<T> {
57
+ T data;
58
+ Node<T> next;
59
+ Node<T> prev; // ← burası eklendi
60
+
61
+ public Node(T data) {
62
+ this.data = data;
63
+ }
64
+ }
65
+ }
mazeDataStructure/mazeDeneme/src/InputScreen.java ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import javax.swing.*;
2
+ import java.awt.*;
3
+ import java.awt.event.ActionEvent;
4
+ import java.awt.event.ActionListener;
5
+
6
+ public class InputScreen extends JFrame {
7
+ private JTextField colsField, rowsField, trapChanceField, powerUpChanceField;
8
+ private JButton playButton;
9
+
10
+ public InputScreen() {
11
+ setTitle("Maze settings");
12
+ setSize(300, 250);
13
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
14
+ setLocationRelativeTo(null);
15
+ setLayout(new GridLayout(5, 2, 5, 5));
16
+
17
+ add(new JLabel("Col number:"));
18
+ colsField = new JTextField("10");
19
+ add(colsField);
20
+
21
+ add(new JLabel("Row number:"));
22
+ rowsField = new JTextField("10");
23
+ add(rowsField);
24
+
25
+ add(new JLabel("Trap Probality (%):"));
26
+ trapChanceField = new JTextField("5");
27
+ add(trapChanceField);
28
+
29
+ add(new JLabel("PowerUp Probality (%):"));
30
+ powerUpChanceField = new JTextField("3");
31
+ add(powerUpChanceField);
32
+
33
+ playButton = new JButton("Play");
34
+ add(new JLabel()); // boşluk için
35
+ add(playButton);
36
+
37
+ playButton.addActionListener(new ActionListener() {
38
+ @Override
39
+ public void actionPerformed(ActionEvent e) {
40
+ startGame();
41
+ }
42
+ });
43
+
44
+ setVisible(true);
45
+ }
46
+
47
+ private void startGame() {
48
+ try {
49
+ int cols = Integer.parseInt(colsField.getText());
50
+ int rows = Integer.parseInt(rowsField.getText());
51
+ int trapChance = Integer.parseInt(trapChanceField.getText());
52
+ int powerUpChance = Integer.parseInt(powerUpChanceField.getText());
53
+
54
+ JFrame frame = new JFrame("Maze Game");
55
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
56
+ frame.getContentPane().add(new MazeManager(cols, rows, trapChance, powerUpChance));
57
+ frame.pack();
58
+ frame.setLocationRelativeTo(null);
59
+ frame.setVisible(true);
60
+
61
+ this.dispose(); // input ekranını kapat
62
+ } catch (NumberFormatException ex) {
63
+ JOptionPane.showMessageDialog(this, "enter valid number.", "error", JOptionPane.ERROR_MESSAGE);
64
+ }
65
+ }
66
+
67
+ public static void main(String[] args) {
68
+ new InputScreen();
69
+ }
70
+ }
mazeDataStructure/mazeDeneme/src/Main.java ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ public class Main {
2
+ public static void main(String[] args) {
3
+
4
+ new InputScreen();
5
+
6
+ }
7
+ }
mazeDataStructure/mazeDeneme/src/MazeManager.java ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import java.awt.*;
2
+ import java.io.FileWriter;
3
+ import java.io.IOException;
4
+ import java.util.*;
5
+ import javax.swing.*;
6
+ import javax.swing.Timer;
7
+
8
+ public class MazeManager extends JPanel {
9
+
10
+
11
+ //Agens and queue
12
+ private Queue<Agent> agentQueue;
13
+ private Agent agent1;
14
+ private Agent agent2;
15
+
16
+
17
+ //variables
18
+ private final int cols, rows;
19
+ private final int cellSize = 20;
20
+ private final MazeTile[][] tiles;
21
+ private final boolean[][][] walls;
22
+ private final Random random = new Random();
23
+ private final int trapChance;
24
+ private final int powerUpChance;
25
+
26
+
27
+ //Game Mechanic
28
+ private boolean gameOver = false;
29
+ private int currRount = 0;
30
+ private Timer timer;
31
+
32
+ public MazeManager(int cols, int rows, int trapChance, int powerUpChance) {
33
+
34
+ //Create ways in maze
35
+ this.cols = cols;
36
+ this.rows = rows;
37
+ this.trapChance = trapChance;
38
+ this.powerUpChance = powerUpChance;
39
+ this.tiles = new MazeTile[cols][rows];
40
+ this.walls = new boolean[cols][rows][4];
41
+
42
+ for (int x = 0; x < cols; x++) {
43
+ for (int y = 0; y < rows; y++) {
44
+ tiles[x][y] = new MazeTile();
45
+ for (int d = 0; d < 4; d++) walls[x][y][d] = true;
46
+ }
47
+ }
48
+
49
+ boolean[][] visited = new boolean[cols][rows];
50
+ generateMaze(0, 0, visited);
51
+ placeEntities();
52
+ setPreferredSize(new Dimension(cols * cellSize, rows * cellSize));
53
+
54
+
55
+ agentQueue = new Queue(10);
56
+ agent1 = new Agent(0, 0, this, Color.BLUE, "Blue Agent",1);
57
+ agent2 = new Agent(cols - 1, rows - 1, this, Color.ORANGE, "Orange Agent",2);
58
+
59
+ agentQueue.enqueue(agent1);
60
+ agentQueue.enqueue(agent2);
61
+
62
+ timer = new Timer(300, e -> {
63
+ if (gameOver || agentQueue.isEmpty()) return;
64
+
65
+ if (currRount > 0 && currRount % 5 == 0) rotateCorridor();
66
+ repaint();
67
+
68
+ Agent currentAgent = agentQueue.dequeue();
69
+ currentAgent.moveTowardsGoal();
70
+
71
+ if (tiles[currentAgent.getX()][currentAgent.getY()].getEntity() == MazeTile.EntityType.GOAL) {
72
+ gameOver = true;
73
+ timer.stop();
74
+
75
+ Agent loser = currentAgent == agent1 ? agent2 : agent1;
76
+ GameLog(currentAgent, loser);
77
+
78
+ JOptionPane.showMessageDialog(this,
79
+ finalReport(agent1, agent2, currentAgent),
80
+ "Game over!",
81
+ JOptionPane.INFORMATION_MESSAGE);
82
+ return;
83
+ }
84
+
85
+ agentQueue.enqueue(currentAgent);
86
+ currRount++;
87
+
88
+ });
89
+ timer.start();
90
+ }
91
+
92
+
93
+ private void generateMaze(int x, int y, boolean[][] visited) {
94
+ visited[x][y] = true;
95
+ Integer[] dirs = {0, 1, 2, 3};
96
+ Collections.shuffle(Arrays.asList(dirs));
97
+
98
+ for (int dir : dirs) {
99
+ int nx = x, ny = y;
100
+ switch (dir) {
101
+ case 0:
102
+ ny--;
103
+ break;
104
+ case 1:
105
+ nx++;
106
+ break;
107
+ case 2:
108
+ ny++;
109
+ break;
110
+ case 3:
111
+ nx--;
112
+ break;
113
+ }
114
+
115
+
116
+ if (isInMaze(nx, ny) && !visited[nx][ny]) {
117
+ removeWall(x, y, dir);
118
+ generateMaze(nx, ny, visited);
119
+ }
120
+ }
121
+ }
122
+
123
+ public boolean hasWall(int x, int y, int dir) {
124
+ return walls[x][y][dir];
125
+ }
126
+
127
+ public void removeWall(int x, int y, int dir) {
128
+ walls[x][y][dir] = false;
129
+ int nx = x, ny = y;
130
+ int opp = (dir + 2) % 4;
131
+ switch (dir) {
132
+ case 0:
133
+ ny--;
134
+ break;
135
+ case 1:
136
+ nx++;
137
+ break;
138
+ case 2:
139
+ ny++;
140
+ break;
141
+ case 3:
142
+ nx--;
143
+ break;
144
+ }
145
+ if (isInMaze(nx, ny)) walls[nx][ny][opp] = false;
146
+ }
147
+
148
+
149
+ //-WİP-
150
+ private void placeEntities() {
151
+ int goalX = cols / 2;
152
+ int goalY = rows / 2;
153
+ tiles[goalX][goalY].setEntity(MazeTile.EntityType.GOAL);
154
+
155
+ int total = cols * rows;
156
+ int trapCount = total * trapChance / 100;
157
+ int powerCount = total * powerUpChance / 100;
158
+
159
+ for (int i = 0; i < trapCount; i++) {
160
+ int x, y;
161
+ do {
162
+ x = random.nextInt(cols);
163
+ y = random.nextInt(rows);
164
+ } while (tiles[x][y].getEntity() != MazeTile.EntityType.EMPTY || (x == goalX && y == goalY));
165
+ tiles[x][y].setEntity(MazeTile.EntityType.TRAP);
166
+ }
167
+
168
+ for (int i = 0; i < powerCount; i++) {
169
+ int x, y;
170
+ do {
171
+ x = random.nextInt(cols);
172
+ y = random.nextInt(rows);
173
+ } while (tiles[x][y].getEntity() != MazeTile.EntityType.EMPTY || (x == goalX && y == goalY));
174
+ tiles[x][y].setEntity(MazeTile.EntityType.POWER_UP);
175
+ }
176
+ }
177
+
178
+ private void rotateCorridor() {
179
+ boolean rotateRow = random.nextBoolean();
180
+ int index = rotateRow ? random.nextInt(rows) : random.nextInt(cols); //1=row, 2=col
181
+ int goalX = cols / 2, goalY = rows / 2; //coordinats of goal
182
+
183
+ /////////////////////////////////////////////
184
+ if (rotateRow && index == goalY)
185
+ {
186
+ return;
187
+ }
188
+ if (!rotateRow && index == goalX) {
189
+ return;
190
+ }
191
+
192
+ if (rotateRow && index == agent1.getY())
193
+ {
194
+ return;
195
+ }
196
+ //for not touching goal,agent1, agent2
197
+ if (!rotateRow && index == agent1.getX()) {
198
+ return;
199
+ }
200
+
201
+ if (!rotateRow && index == agent2.getX()) {
202
+ return;
203
+ }
204
+ if (rotateRow && index == agent2.getY()) {
205
+ return;
206
+ }
207
+ /////////////////////////////////////////////
208
+
209
+ if (rotateRow) {
210
+ CircularLinkedList<MazeTile.EntityType> entityList = new CircularLinkedList<>();
211
+ CircularLinkedList<Boolean> activePowerUp = new CircularLinkedList<>();
212
+
213
+ // taking data of every tile( entity type, is trap active, is powerup active)
214
+
215
+ //taking them to same circular linked list
216
+ CircularLinkedList<Boolean> activeTrap = new CircularLinkedList<>();
217
+
218
+
219
+ //rewrite every tiles
220
+ for (int x = 0; x < cols; x++) {
221
+ MazeTile tile = tiles[x][index];
222
+ entityList.add(tile.getEntity());
223
+
224
+ activeTrap.add( tile.isTrapActive());
225
+
226
+ activePowerUp.add(tile.isPowerUpActive());
227
+ }
228
+
229
+ entityList.rotateOneStep(1);
230
+ activeTrap.rotateOneStep(1);
231
+ activePowerUp.rotateOneStep(1);
232
+
233
+
234
+ for (int x = 0; x < cols; x++) {
235
+
236
+
237
+ tiles[x][index].setPowerUpActive(activePowerUp.get(x));
238
+ tiles[x][index].setEntity(entityList.get(x));
239
+ tiles[x][index].setTrapActive(activeTrap.get(x));
240
+ }
241
+
242
+ } else {
243
+
244
+ CircularLinkedList<Boolean> trapActiveList = new CircularLinkedList<>();
245
+
246
+ CircularLinkedList<Boolean> powerUpActiveList = new CircularLinkedList<>();
247
+
248
+ CircularLinkedList<MazeTile.EntityType> entityList = new CircularLinkedList<>();
249
+
250
+
251
+ for (int y = 0; y < rows; y++) {
252
+ MazeTile tile = tiles[index][y];
253
+ entityList.add(tile.getEntity());
254
+ trapActiveList.add(tile.isTrapActive());
255
+ powerUpActiveList.add(tile.isPowerUpActive());
256
+ }
257
+
258
+ entityList.rotateOneStep(1);
259
+ trapActiveList.rotateOneStep(1);
260
+ powerUpActiveList.rotateOneStep(1);
261
+
262
+ for (int y = 0; y < rows; y++) {
263
+ tiles[index][y].setEntity(entityList.get(y));
264
+ tiles[index][y].setTrapActive(trapActiveList.get(y));
265
+ tiles[index][y].setPowerUpActive(powerUpActiveList.get(y));
266
+ }
267
+ }
268
+ }
269
+
270
+ public boolean isInMaze(int x, int y) {
271
+ return x >= 0 && y >= 0 && x < cols && y < rows;
272
+ }
273
+
274
+ public MazeTile getTile(int x, int y) {
275
+ return tiles[x][y];
276
+ }
277
+
278
+ public int getCols() {
279
+ return cols;
280
+ }
281
+
282
+ public int getRows() {
283
+ return rows;
284
+ }
285
+
286
+ private String finalReport(Agent a1, Agent a2, Agent winner) {
287
+ StringBuilder sb = new StringBuilder();
288
+ sb.append(winner.getName()).append(" reached the target!\nnumber of rount played: ").append(currRount).append("\n\n");
289
+ for (Agent agent : new Agent[]{a1, a2}) {
290
+ sb.append(agent.getName()).append(":\n");
291
+ Stack<String> stack = agent.getMoveHistory();
292
+ for (int i = 0; i < stack.getSize(); i++) {
293
+
294
+ sb.append(stack.getElements()[i]).append("");
295
+ }
296
+ sb.append("\n");
297
+ }
298
+ return sb.toString();
299
+ }
300
+
301
+ private void GameLog(Agent winner, Agent loser) {
302
+ // preparing console screen before printing results
303
+ System.out.print("\033[H\033[2J");
304
+ System.out.flush();
305
+ //-----------
306
+ System.out.println("\n=== Game Over ===");
307
+ System.out.println("Winner Agent: " + winner.getName());
308
+ System.out.println("Number of rount played: " + currRount);
309
+ System.out.println("----------------------");
310
+
311
+ System.out.println(winner.getName() + " Statistics:");
312
+ System.out.println("- Step number: " + winner.getStepCount());
313
+ System.out.println("- Trap number: " + winner.getTrapHits());
314
+ System.out.println("- Power-Up usage: " + winner.getPowerUpUses());
315
+ System.out.println();
316
+
317
+ System.out.println(loser.getName() + " Statistics:");
318
+ System.out.println("- Step number: " + loser.getStepCount());
319
+ System.out.println("- Trap number: " + loser.getTrapHits());
320
+ System.out.println("- Power-Up usage: " + loser.getPowerUpUses());
321
+
322
+ try (FileWriter writer = new FileWriter("game_log.txt", true)) {
323
+ writer.write("=== Game Over ===\n");
324
+ writer.write("Winner Agent: " + winner.getName() + " (ID: " + winner.getId() + ")\n");
325
+ writer.write("Number of rount played: " + currRount + "\n\n");
326
+
327
+ for (Agent agent : new Agent[]{winner, loser}) {
328
+ writer.write(agent.getName() + " (ID: " + agent.getId() + ")\n");
329
+ writer.write("- Step number: " + agent.getStepCount() + "\n");
330
+ writer.write("- Trap number: " + agent.getTrapHits() + "\n");
331
+ writer.write("- Power-Up usage: " + agent.getPowerUpUses() + "\n");
332
+ writer.write("- Moves: ");
333
+ Stack<String> stack = agent.getMoveHistory();
334
+ for (int i = 0; i < stack.getSize(); i++) {
335
+ Object move = stack.getElements()[i];
336
+ writer.write(String.valueOf(move));
337
+ }
338
+
339
+ writer.write("\n--------------------------\n");
340
+ }
341
+
342
+ } catch (IOException e) {
343
+ System.out.println("Log file error: ");
344
+ }
345
+
346
+ }
347
+
348
+ @Override
349
+ protected void paintComponent(Graphics g) {
350
+ super.paintComponent(g);
351
+ g.setColor(Color.BLACK);
352
+
353
+ for (int x = 0; x < cols; x++) {
354
+ for (int y = 0; y < rows; y++) {
355
+ int px = x * cellSize;
356
+ int py = y * cellSize;
357
+
358
+ if (walls[x][y][3]) g.drawLine(px, py, px, py + cellSize);
359
+ if (walls[x][y][1]) g.drawLine(px + cellSize, py, px + cellSize, py + cellSize);
360
+ if (walls[x][y][0]) g.drawLine(px, py, px + cellSize, py);
361
+ if (walls[x][y][2]) g.drawLine(px, py + cellSize, px + cellSize, py + cellSize);
362
+
363
+ switch (tiles[x][y].getEntity()) {
364
+ case GOAL -> {
365
+ g.setColor(Color.GREEN);
366
+ g.fillRect(px + 4, py + 4, cellSize - 8, cellSize - 8);
367
+ g.setColor(Color.BLACK);
368
+ }
369
+
370
+ case POWER_UP -> {
371
+ g.setColor(tiles[x][y].isPowerUpActive() ? Color.YELLOW : Color.GRAY);
372
+ g.fillRect(px + 4, py + 4, cellSize - 8, cellSize - 8);
373
+ g.setColor(Color.BLACK);
374
+ }
375
+ case TRAP -> {
376
+ g.setColor(tiles[x][y].isTrapActive() ? Color.RED : Color.GRAY);
377
+ g.fillRect(px + 4, py + 4, cellSize - 8, cellSize - 8);
378
+ g.setColor(Color.BLACK);
379
+ }
380
+ }
381
+ }
382
+ }
383
+
384
+ for (Agent agent : new Agent[]{agent1, agent2}) {
385
+ g.setColor(agent.passedWallThisTurn() ? Color.MAGENTA : agent.getColor());
386
+ g.fillOval(agent.getX() * cellSize + 5, agent.getY() * cellSize + 5, cellSize - 10, cellSize - 10);
387
+ }
388
+
389
+ g.setColor(Color.BLACK);
390
+ g.drawString("Curr Round: " + currRount, 10, 15);
391
+ }
392
+ }
mazeDataStructure/mazeDeneme/src/MazeTile.java ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ public class MazeTile {
2
+ public enum EntityType {
3
+ EMPTY, GOAL, TRAP, POWER_UP
4
+ }
5
+
6
+ private EntityType entity = EntityType.EMPTY;
7
+ private boolean trapActive = true;
8
+ private boolean powerUpActive = true;
9
+
10
+ public EntityType getEntity() {
11
+ return entity;
12
+ }
13
+
14
+ public void setEntity(EntityType entity) {
15
+ this.entity = entity;
16
+ }
17
+
18
+ public boolean isTrapActive() {
19
+ return trapActive;
20
+ }
21
+
22
+ public void deactivateTrap() {
23
+ this.trapActive = false;
24
+ }
25
+
26
+ public boolean isPowerUpActive() {
27
+ return powerUpActive;
28
+ }
29
+
30
+ public void deactivatePowerUp() {
31
+ this.powerUpActive = false;
32
+ }
33
+
34
+ public void setTrapActive(boolean active) {
35
+ this.trapActive = active;
36
+ }
37
+
38
+ public void setPowerUpActive(boolean active) {
39
+ this.powerUpActive = active;
40
+ }
41
+ }
mazeDataStructure/mazeDeneme/src/Queue.java ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ public class Queue<T> {
2
+ private Object[] elementsofqueue;
3
+ private int head = 0;
4
+ private int tail = 0;
5
+ private int sizeofqueue = 0;
6
+ private int capacity;
7
+
8
+ public Queue(int capacityval) {
9
+ this.capacity = capacityval;
10
+ elementsofqueue = new Object[capacityval];
11
+ }
12
+
13
+ public void enqueue(T item) {
14
+ if (sizeofqueue == capacity) {
15
+ System.out.println("Queue is full");
16
+ return;
17
+ }
18
+ elementsofqueue[tail] = item;
19
+ tail = (tail + 1) % capacity;
20
+ sizeofqueue++;
21
+ }
22
+
23
+ public T dequeue() {
24
+ if (isEmpty()) {
25
+ System.out.println("Queue is empty");
26
+ return null;
27
+ }
28
+ T item = (T) elementsofqueue[head];
29
+ head = (head + 1) % capacity;
30
+ sizeofqueue--;
31
+ return item;
32
+ }
33
+
34
+
35
+
36
+ public boolean isEmpty() {
37
+ return sizeofqueue == 0;
38
+ }
39
+
40
+ public int getSize() {
41
+ return sizeofqueue;
42
+ }
43
+ }
mazeDataStructure/mazeDeneme/src/Stack.java ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ public class Stack<T> {
2
+ private Object[] elementsofstack;
3
+ private int size = 0;
4
+
5
+ public Stack(int capacity) {
6
+ elementsofstack = new Object[capacity];
7
+ }
8
+
9
+ public void push(T item) {
10
+ int lengthofstack = elementsofstack.length;
11
+ if (size == lengthofstack) {
12
+ System.out.println("Stack is full!");
13
+ return;
14
+ }
15
+ //size= size +1;
16
+ elementsofstack[size] = item;
17
+ size = size + 1;
18
+ }
19
+
20
+ public T pop() {
21
+ if (isempty()) {
22
+ System.out.println("Stack is empty!");
23
+ return null;
24
+ }
25
+ size= size - 1;
26
+ return (T) elementsofstack[size];
27
+ }
28
+
29
+ public boolean isempty() {
30
+ if(size == 0)
31
+ {
32
+ return true;
33
+ }
34
+ else if(size<=0)
35
+ {
36
+ System.out.println("there might be issue!\n>size value:"+size);
37
+ return false;
38
+ }
39
+ else
40
+ {
41
+ return false;
42
+ }
43
+
44
+ }
45
+
46
+ public Object[] getElements() {
47
+ return elementsofstack;
48
+ }
49
+
50
+ public int getSize() {
51
+ //System.out.println("used getSize func.\n>size value:"+size);
52
+ return size;
53
+ }
54
+
55
+ }