├── Emerging Trends ├── AI-openAI-v01.ipynb ├── Agentic.md └── Readme.md ├── Exercises ├── 08 - Logic.md ├── 09-01-ProbabilityBayes.md ├── 09-02-BayesNET.md ├── AI-W03-Search01.ipynb ├── AI-W04-Search02.ipynb ├── AI-W05-TikTakToe.ipynb ├── AI-W07-TikTakToe-Score.ipynb ├── AI-W08-Minimax.ipynb ├── AStar-Algorithm.pdf └── Readme.md ├── LABs ├── L.01.md ├── L.02.md ├── L.03.md ├── L.04.md ├── L.05.md ├── L.06.md ├── L.07.md ├── L.08.md ├── L.09.md ├── L.10.md ├── L.11.md ├── L.12.md └── Readme.md ├── Links.md ├── Midtem Exam ├── AI-W09-MidTerm-Minimax.ipynb └── Readme.md ├── Project-TikTakToe ├── AI-W05-TikTakToe.ipynb ├── AI-W07-TikTakToe-Score.ipynb ├── APIs │ ├── CLIENT-TicTacYoe.rar │ └── Readme.md ├── PR.Exercise.01.md ├── PR.Rubrics.md ├── PR.ref.md └── Readme.md ├── README.md ├── Seminar ├── Readme.md └── Topics-2025.03.md └── Test └── Readme.md /Emerging Trends/AI-openAI-v01.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "487b4030", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import openai" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "id": "eb44bbb7", 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "# Use OpenAI API Key\n", 21 | "openai.api_key= \"sk-......\"" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "id": "978d8530", 27 | "metadata": {}, 28 | "source": [] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 11, 33 | "id": "7a91b4f9", 34 | "metadata": { 35 | "scrolled": true 36 | }, 37 | "outputs": [ 38 | { 39 | "name": "stdout", 40 | "output_type": "stream", 41 | "text": [ 42 | "What would you Like to ask OpenAI? Translate the following English sentence to Vietnamese: 'The cat is on the mat.'\n" 43 | ] 44 | } 45 | ], 46 | "source": [ 47 | "# Ask the user for question\n", 48 | "question = input(\"What would you Like to ask OpenAI? \")" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 12, 54 | "id": "75c61757", 55 | "metadata": {}, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "{\n", 62 | " \"choices\": [\n", 63 | " {\n", 64 | " \"finish_reason\": \"stop\",\n", 65 | " \"index\": 0,\n", 66 | " \"logprobs\": null,\n", 67 | " \"text\": \"\\n\\nM\\u00e8o \\u1edf tr\\u00ean c\\u00e1i \\u0111\\u1ec7m.\"\n", 68 | " }\n", 69 | " ],\n", 70 | " \"created\": 1683221527,\n", 71 | " \"id\": \"cmpl-7CX6FQFtDBGrMtVT13doHq3XwRmvA\",\n", 72 | " \"model\": \"text-davinci-003\",\n", 73 | " \"object\": \"text_completion\",\n", 74 | " \"usage\": {\n", 75 | " \"completion_tokens\": 21,\n", 76 | " \"prompt_tokens\": 17,\n", 77 | " \"total_tokens\": 38\n", 78 | " }\n", 79 | "}\n" 80 | ] 81 | } 82 | ], 83 | "source": [ 84 | "# Response\n", 85 | "response = openai.Completion.create(\n", 86 | " engine=\"text-davinci-003\",\n", 87 | " prompt=question,\n", 88 | " max_tokens=512,\n", 89 | " n=1,\n", 90 | " stop=None,\n", 91 | " temperature=0.8,\n", 92 | ")\n", 93 | "print(response)" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": 13, 99 | "id": "a9d807ec", 100 | "metadata": { 101 | "scrolled": true 102 | }, 103 | "outputs": [ 104 | { 105 | "name": "stdout", 106 | "output_type": "stream", 107 | "text": [ 108 | "OpenAI:\n", 109 | "\n", 110 | "Mèo ở trên cái đệm.\n" 111 | ] 112 | } 113 | ], 114 | "source": [ 115 | "# choice 1 solution as answer\n", 116 | "answer = response[\"choices\"][0][ \"text\"]\n", 117 | "print(\"OpenAI:\" + answer)" 118 | ] 119 | }, 120 | { 121 | "cell_type": "markdown", 122 | "id": "f2d2ca8c", 123 | "metadata": {}, 124 | "source": [ 125 | "## CHAT" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 18, 131 | "id": "108bde75", 132 | "metadata": { 133 | "scrolled": true 134 | }, 135 | "outputs": [ 136 | { 137 | "name": "stdout", 138 | "output_type": "stream", 139 | "text": [ 140 | "You: đại học hoa sen có giáo viên nào dạy công nghệ thông tin ?\n", 141 | "OpenAI:\n", 142 | "\n", 143 | "Đại học Hoa Sen có nhiều giáo viên dạy Công nghệ Thông tin, trong đó có: \n", 144 | "- PGS.TS. Phan Minh Đức \n", 145 | "- ThS. Nguyễn Thành Long \n", 146 | "- PGS.TS. Phan Trí Tuấn \n", 147 | "- ThS. Vũ Ngọc Hùng \n", 148 | "- PGS.TS. Nguyễn Văn Tùng \n", 149 | "- ThS. Trương Quang Huy\n" 150 | ] 151 | } 152 | ], 153 | "source": [ 154 | "\n", 155 | "question = input(\"You: \")\n", 156 | "\n", 157 | "response = openai.Completion.create(\n", 158 | " model=\"text-davinci-003\",\n", 159 | " prompt=question,\n", 160 | " temperature=0.5,\n", 161 | " max_tokens=600,\n", 162 | " top_p=1.0,\n", 163 | " frequency_penalty=0.5,\n", 164 | " presence_penalty=0.0,\n", 165 | " stop=[\"You:\"]\n", 166 | ")\n", 167 | "\n", 168 | "answer = response[\"choices\"][0][ \"text\"]\n", 169 | "print(\"OpenAI:\" + answer)" 170 | ] 171 | }, 172 | { 173 | "cell_type": "markdown", 174 | "id": "654697f6", 175 | "metadata": {}, 176 | "source": [ 177 | "## Models " 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 10, 183 | "id": "36ce11a5", 184 | "metadata": {}, 185 | "outputs": [ 186 | { 187 | "data": { 188 | "text/plain": [ 189 | "openai.openai_object.OpenAIObject" 190 | ] 191 | }, 192 | "execution_count": 10, 193 | "metadata": {}, 194 | "output_type": "execute_result" 195 | } 196 | ], 197 | "source": [ 198 | "lst = openai.Model.list()\n", 199 | "type(lst)" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 13, 205 | "id": "6918a48e", 206 | "metadata": { 207 | "scrolled": true 208 | }, 209 | "outputs": [ 210 | { 211 | "data": { 212 | "text/plain": [ 213 | "['babbage',\n", 214 | " 'davinci',\n", 215 | " 'text-davinci-edit-001',\n", 216 | " 'babbage-code-search-code',\n", 217 | " 'text-similarity-babbage-001',\n", 218 | " 'code-davinci-edit-001',\n", 219 | " 'text-davinci-001',\n", 220 | " 'ada',\n", 221 | " 'babbage-code-search-text',\n", 222 | " 'babbage-similarity',\n", 223 | " 'code-search-babbage-text-001',\n", 224 | " 'text-curie-001',\n", 225 | " 'code-search-babbage-code-001',\n", 226 | " 'text-ada-001',\n", 227 | " 'text-embedding-ada-002',\n", 228 | " 'text-similarity-ada-001',\n", 229 | " 'curie-instruct-beta',\n", 230 | " 'ada-code-search-code',\n", 231 | " 'ada-similarity',\n", 232 | " 'gpt-3.5-turbo-0301',\n", 233 | " 'code-search-ada-text-001',\n", 234 | " 'text-search-ada-query-001',\n", 235 | " 'davinci-search-document',\n", 236 | " 'gpt-3.5-turbo',\n", 237 | " 'ada-code-search-text',\n", 238 | " 'text-search-ada-doc-001',\n", 239 | " 'davinci-instruct-beta',\n", 240 | " 'text-similarity-curie-001',\n", 241 | " 'code-search-ada-code-001',\n", 242 | " 'ada-search-query',\n", 243 | " 'text-search-davinci-query-001',\n", 244 | " 'curie-search-query',\n", 245 | " 'davinci-search-query',\n", 246 | " 'babbage-search-document',\n", 247 | " 'ada-search-document',\n", 248 | " 'text-search-curie-query-001',\n", 249 | " 'whisper-1',\n", 250 | " 'text-search-babbage-doc-001',\n", 251 | " 'curie-search-document',\n", 252 | " 'text-davinci-003',\n", 253 | " 'text-search-curie-doc-001',\n", 254 | " 'babbage-search-query',\n", 255 | " 'text-babbage-001',\n", 256 | " 'text-search-davinci-doc-001',\n", 257 | " 'text-search-babbage-query-001',\n", 258 | " 'curie-similarity',\n", 259 | " 'curie',\n", 260 | " 'text-similarity-davinci-001',\n", 261 | " 'text-davinci-002',\n", 262 | " 'davinci-similarity',\n", 263 | " 'cushman:2020-05-03',\n", 264 | " 'ada:2020-05-03',\n", 265 | " 'babbage:2020-05-03',\n", 266 | " 'curie:2020-05-03',\n", 267 | " 'davinci:2020-05-03',\n", 268 | " 'if-davinci-v2',\n", 269 | " 'if-curie-v2',\n", 270 | " 'if-davinci:3.0.0',\n", 271 | " 'davinci-if:3.0.0',\n", 272 | " 'davinci-instruct-beta:2.0.0',\n", 273 | " 'text-ada:001',\n", 274 | " 'text-davinci:001',\n", 275 | " 'text-curie:001',\n", 276 | " 'text-babbage:001']" 277 | ] 278 | }, 279 | "execution_count": 13, 280 | "metadata": {}, 281 | "output_type": "execute_result" 282 | } 283 | ], 284 | "source": [ 285 | "[ x[\"root\"] for x in lst[\"data\"] ]" 286 | ] 287 | }, 288 | { 289 | "cell_type": "markdown", 290 | "id": "395faacc", 291 | "metadata": {}, 292 | "source": [ 293 | "## Create/Generate Image" 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": 32, 299 | "id": "afb183a5", 300 | "metadata": {}, 301 | "outputs": [], 302 | "source": [ 303 | "response = openai.Image.create(\n", 304 | " prompt=\"beautiful girl, handsome guy and laptop\",\n", 305 | " n=1,\n", 306 | " size=\"1024x1024\"\n", 307 | ")\n", 308 | "image_url = response['data'][0]['url']" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": 15, 314 | "id": "d5c0f1c6", 315 | "metadata": { 316 | "scrolled": false 317 | }, 318 | "outputs": [ 319 | { 320 | "data": { 321 | "text/plain": [ 322 | "'https://oaidalleapiprodscus.blob.core.windows.net/private/org-rtG8DN0HUad9EhYbvrq9DM1w/user-UZgIWnRpQGZxfKqJ8lkyV8dK/img-3vHmh5jpwfkNjvtt1tstrX1B.png?st=2023-05-04T17%3A00%3A01Z&se=2023-05-04T19%3A00%3A01Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-05-04T16%3A06%3A00Z&ske=2023-05-05T16%3A06%3A00Z&sks=b&skv=2021-08-06&sig=apofHo3O2Asl68sYOPsRGSo3eTkpwoPzUfAQdbnFpsE%3D'" 323 | ] 324 | }, 325 | "execution_count": 15, 326 | "metadata": {}, 327 | "output_type": "execute_result" 328 | } 329 | ], 330 | "source": [ 331 | "image_url" 332 | ] 333 | }, 334 | { 335 | "cell_type": "code", 336 | "execution_count": 16, 337 | "id": "f1ee4a67", 338 | "metadata": {}, 339 | "outputs": [], 340 | "source": [ 341 | "from skimage import data, io" 342 | ] 343 | }, 344 | { 345 | "cell_type": "code", 346 | "execution_count": null, 347 | "id": "08dddc19", 348 | "metadata": {}, 349 | "outputs": [], 350 | "source": [ 351 | "img = io.imread(image_url)\n", 352 | "io.imshow(img)" 353 | ] 354 | }, 355 | { 356 | "cell_type": "markdown", 357 | "id": "75656eaa", 358 | "metadata": {}, 359 | "source": [ 360 | "## Assistant" 361 | ] 362 | }, 363 | { 364 | "cell_type": "code", 365 | "execution_count": 35, 366 | "id": "64fba3e1", 367 | "metadata": { 368 | "scrolled": true 369 | }, 370 | "outputs": [ 371 | { 372 | "name": "stdout", 373 | "output_type": "stream", 374 | "text": [ 375 | "assistant: Là một trợ lý ảo, tôi có thể giúp bạn trả lời các câu hỏi, cung cấp thông tin hoặc hướng dẫn về các vấn đề liên quan đến truy cập internet, tìm kiếm thông tin, tính toán, lịch, dịch văn bản và nhiều hơn nữa. Tuy nhiên, trong một số trường hợp, tôi có thể không thể giúp được bạn và bạn cần tìm kiếm thông tin từ nguồn đáng tin cậy khác.\n" 376 | ] 377 | } 378 | ], 379 | "source": [ 380 | "question = 'Bạn giúp được gì ?'\n", 381 | "\n", 382 | "\n", 383 | "completion = openai.ChatCompletion.create(\n", 384 | " model=\"gpt-3.5-turbo\",\n", 385 | " messages=[\n", 386 | " {\"role\": \"user\", \"content\": question}\n", 387 | " ]\n", 388 | ")\n", 389 | "print(f\"{completion['choices'][0]['message']['role']}: {completion['choices'][0]['message']['content']}\")" 390 | ] 391 | }, 392 | { 393 | "cell_type": "code", 394 | "execution_count": null, 395 | "id": "32238c4d", 396 | "metadata": {}, 397 | "outputs": [], 398 | "source": [] 399 | } 400 | ], 401 | "metadata": { 402 | "kernelspec": { 403 | "display_name": "Python 3 (ipykernel)", 404 | "language": "python", 405 | "name": "python3" 406 | }, 407 | "language_info": { 408 | "codemirror_mode": { 409 | "name": "ipython", 410 | "version": 3 411 | }, 412 | "file_extension": ".py", 413 | "mimetype": "text/x-python", 414 | "name": "python", 415 | "nbconvert_exporter": "python", 416 | "pygments_lexer": "ipython3", 417 | "version": "3.11.2" 418 | } 419 | }, 420 | "nbformat": 4, 421 | "nbformat_minor": 5 422 | } 423 | -------------------------------------------------------------------------------- /Emerging Trends/Agentic.md: -------------------------------------------------------------------------------- 1 | 2 | # Agentic AI 3 | 4 | 5 | ## Protocols 6 | 7 | - Model Context Protocol (MCP) 8 | - Agent Communication Protocol (ACP) 9 | - Agent-to-Agent (A2A) 10 | 11 | ANP, Agora, LMOS, ... 12 | 13 | ![image](https://github.com/user-attachments/assets/ad3821ca-ba10-4d83-a08b-4e9eb88aa9a7) 14 | 15 | ![image](https://github.com/user-attachments/assets/1152c1ff-3153-4f1f-960c-1d0ae4283b84) 16 | 17 | 18 | ![image](https://github.com/user-attachments/assets/036dc657-85df-4ea8-a8ad-b8701dd5e4d3) 19 | 20 | ![image](https://github.com/user-attachments/assets/d9b95f1b-642a-4552-88fc-2b26d0333368) 21 | 22 | ![image](https://github.com/user-attachments/assets/ceb36a17-7102-475d-8e28-7b5897c76608) 23 | 24 | ![image](https://github.com/user-attachments/assets/03bee636-378f-4f15-9263-ee720e22ff43) 25 | 26 | ![image](https://github.com/user-attachments/assets/872fa41c-7db2-4a22-9e98-ac1f7a062064) 27 | 28 | 29 | ## REFs 30 | - https://medium.com/@elisowski/what-every-ai-engineer-should-know-about-a2a-mcp-acp-8335a210a742 31 | - https://www.linkedin.com/pulse/evolution-ai-communication-mcp-acp-agent2agent-a2a-sudhanshu-sharma--owqgf/ 32 | - https://viblo.asia/p/a2a-agent-and-agent-protocol-Rk74aXR6VeO 33 | - 34 | -------------------------------------------------------------------------------- /Emerging Trends/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Exercises/08 - Logic.md: -------------------------------------------------------------------------------- 1 | ## FOL 2 | 3 | ### 01 4 | Translate the following sentences into FOL. 5 | 1. Everything is bitter or sweet 6 | 2. Either everything is bitter or everything is sweet 7 | 3. There is somebody who is loved by everyone 8 | 4. Nobody is loved by no one 9 | 5. If someone is noisy, everybody is annoyed 10 | 6. Frogs are green. 11 | 7. Frogs are not green. 12 | 8. No frog is green. 13 | 9. Some frogs are not green. 14 | 10. A mechanic likes Bob. 15 | 11. A mechanic likes herself. 16 | 12. Every mechanic likes Bob. 17 | 13. Some mechanic likes every nurse. 18 | 14. There is a mechanic who is liked by every nurse 19 | 20 | ### 02 21 | Represent the following sentences in first-order logic, using a consistent vocabulary (which you must define): 22 | 1. Some students took French in spring 2001. 23 | 2. Every student who takes French passes it. 24 | 3. Only one student took Greek in spring 2001. 25 | 4. The best score in Greek is always higher than the best score in French. 26 | 5. Every person who buys a policy is smart. 27 | 6. No person buys an expensive policy. 28 | 7. There is an agent who sells policies only to people who are not insured. 29 | 8. There is a barber who shaves all men in town who do not shave themselves. 30 | 9. A person born in the UK, each of whose parents is a UK citizen or a UK resident, is a UK citizen by birth. 31 | 10. A person born outside the UK, one of whose parents is a UK citizen by birth, is a UK citizen by descent. 32 | 11. Politicians can fool some of the people all of the time, and they can fool all of the people some of the time, but they can’t fool all of the people all of the time. 33 | 12. All Greeks speak the same language. (Use Speaks(x,l) to mean that person x speaks language l .) 34 | 35 | ### 03 36 | 37 | What is the meaning of the followinf FOL formulas? 38 | 39 | ![image](https://github.com/AdTekDev/AI/assets/18588011/d064ead8-ad76-4d73-a830-b6f9c8a11f8e) 40 | 41 | 42 | ### 04 43 | Reduce to Conjunctive Normal Form (CNF) the formula 44 | 1. ![image](https://github.com/AdTekDev/AI/assets/18588011/ac396af1-8273-485a-a31a-487de138c450) 45 | 46 | 47 | 2. ![image](https://github.com/AdTekDev/AI/assets/18588011/7e398efa-8965-4834-a56b-f9f9ddd63848) 48 | 49 | 50 | 3-9. ![image](https://github.com/AdTekDev/AI/assets/18588011/8b847501-6fac-483c-b537-66f617d9a251) 51 | 52 | 53 | 54 | ## Links 55 | - https://aimacode.github.io/aima-exercises/fol-exercises/ 56 | - https://www.hansrajcollege.ac.in/hCPanel/uploads/elearning/elearning_document/logic_problemSet.pdf 57 | - https://www.logicmatters.net/ifl/ifl2-exercises-and-answers-2/ 58 | - https://wolfgangahrendt.gitlab.io/FMSD/Exercises/FOLAndJML/Exercises_FOLAndJML.html 59 | - 60 | -------------------------------------------------------------------------------- /Exercises/09-01-ProbabilityBayes.md: -------------------------------------------------------------------------------- 1 | 2 | ## Bayes 3 | 4 | ### B.01. 5 | An automobile manufacturer has three factories: A, B, and C. They produce 50%, 30%, and 20% respectively, of a specific model of car. 30% of the cars produced in factory A are white, 40% of those produced in factory B are white, and 25% produced in factory C are white. 6 | 7 | If an automobile produced by the company is selected at random, find the probability that it is white. 8 | Given that an automobile selected at random is white, find the probability that it came from factory B. 9 | 10 | ### B.02. 11 | Two manufacturers supply blankets to emergency relief organizations. 12 | Manufacturer A supplies 3000 blankets and 4% are irregular in workmanship. 13 | Manufacturer B supplies 2400 blankets and 7% are found to be irregular. 14 | Given that a blanket is irregular, find the probability that it came from manufacturer B. 15 | 16 | ### B.03. 17 | It is estimated that 50% of emails are spam emails. Some software has been applied to filter these spam emails before they reach your inbox. A certain brand of software claims that it can detect 99% of spam emails, and the probability for a false positive (a non-spam email detected as spam) is 5%. 18 | Now if an email is detected as spam, then what is the probability that it is in fact a non-spam email? 19 | 20 | ### B.04. 21 | Three persons A, B and C have applied for a job in a private company. The chance of their selections is in the ratio 1 : 2 : 4. The probabilities that A, B and C can introduce changes to improve the profits of the company are 0.8, 0.5 and 0.3, respectively. If the change does not take place, find the probability that it is due to the appointment of C. 22 | 23 | 24 | ### B.05. 25 | 26 | In ATD' class, if a student does homework most days, the chance of passing the course is 90%. On the other hand, if a student does not do homework most days, the chance of passing the course is only 20%. 27 | H = event that the student did homework 28 | C = event that the student passed the course 29 | ATD claims that 80% of his students do homework on a regular basis. If a student is chosen at random from ATD' class, find the following probabilities. 30 | - P(C) 31 | - P(H|C) 32 | - P(C|H) 33 | 34 | ### B.06. 35 | A computer company buys its chips from three different manufacturers. Manufacturer I provides 60% of the chips and is known to produce 5% defective; Manufacturer II supplies 30% of the chips and makes 4% defective; while the rest are supplied by Manufacturer III with 3% defective chips. If a chip is chosen at random, find the following probabilities: 36 | - P(the chip is defective) 37 | - P(chip is from Manufacturer II | defective) 38 | - P(defective |chip is from manufacturer III) 39 | 40 | ### B.07. 41 | At a retail store, 20% of customers use the store’s online app to assist them when shopping in the store ; 80% of store shoppers don’t use the app. 42 | 43 | Of those customers that use the online app while in the store, 50% are very satisfied with their purchases, 40% are moderately satisfied, and 10% are dissatisfied. 44 | 45 | Of those customers that do not use the online app while in the store, 30% are very satisfied with their purchases, 50% are moderately satisfied and 20% are dissatisfied. 46 | 47 | Indicate the events by the following: 48 | 49 | A = shopper uses the app in the store 50 | N = shopper does not use the app in the store 51 | V = very satisfied with purchase 52 | M = moderately satisfied 53 | D = dissatisfied 54 | 55 | - Find P(A and D), the probability that a store customer uses the app and is dissatisfied 56 | - Find P(A|D), the probability that a store customer uses the app if the customer is dissatisfied. 57 | 58 | ### B.08. 59 | In a casino in Blackpool there are two slot machines: one that pays out 10 % of the time, and one that pays out 20 % of the time. Obviously, you would like to play on the machine that pays out 20 % of the time but you do not know which of the two machines is the more generous. You thus adopt the following strategy: you assume initially that the two machines are equally likely to be the generous machine. You then select one of the two machines at random and put a coin into it. Given that you loose that first bet estimate the probability that the machine you selected is the more generous of the two machines. 60 | 61 | ### B.09. 62 | A radar system is designed such that the probability of detecting the presence of an aircraft in its range is 98%. However if no aircraft is present in its range it still report (falsely) that an aircraft is present with a probability of 5%. At any time, the probability that an aircraft is present within the range of the radar is 7%. 63 | - What is the probability that no aircraft is present in the range of the radar given that an aircraft is detected? 64 | - What is the probability that an aircraft is present in the range of the radar given that an aircraft is detected? 65 | - What is the probability that an aircraft is present in the range of the radar given that no aircraft is detected? 66 | 67 | ### B.10. 68 | An aircraft emergency locator transmitter (ELT) is a device designed to transmit a signal in the case of a crash. The KonTek Manufacturing Company makes 80% of the ELTs, the Edopa Company makes 15% of them, and the InoBox Company makes the other 5%. The ELTs made by KonTek have a 4% rate of defects, the Edopa ELTs have a 6% rate of defects, and the InoBox ELTs have a 9% rate of defects (which helps to explain why InoBox has the lowest market share). 69 | - If an ELT is randomly selected from the general population of all ELTs, find the probability that it was made by the KonTek Manufacturing Company. 70 | - If a randomly selected ELT is then tested and is found to be defective, find the probability that it was made by the KonTek Manufacturing Company 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /Exercises/09-02-BayesNET.md: -------------------------------------------------------------------------------- 1 | 2 | ### BN.01 3 | 4 | ![image](https://github.com/AdTekDev/AI/assets/18588011/a9857a5f-9a16-43ea-be08-98d8d565bf60) 5 | 6 | 7 | ### BN.02 8 | 9 | Let us have three tram lines - 6, 22 and 24 - regularly coming to the stop in front of the faculty building. Line 22 operates more frequently than line 24, 24 goes more often than line 6 (the ratio is 5:3:2, it is kept during all the hours of operation). Line 6 uses a single car setting in 9 out of 10 cases during the daytime, in the evening it always has the only car. Line 22 has one car rarely and only in evenings (1 out of 10 tramcars). 10 | Line 24 can be short whenever, however, it takes a long setting with 2 cars in 8 out of 10 cases. DiLinh is available by line 24, lines 6 and 22 are headed in the direction of IP Dallat. The line changes appear only when a tram goes to depot (let 24 have its depot in the direction of IP Dallat, 6 and 22 have their depots in the direction of DiLinh). 11 | Every tenth tram goes to the depot evenly throughout the operation. The evening regime is from 6pm to 24pm, the daytime regime is from 6am to 6pm. 12 | - a) Draw a correct, efficient and causal Bayesian network. 13 | - b) Annotate the network with the conditional probability tables. 14 | - c) It is evening. A short tram is approaching the stop. What is the probability it will go to DiLinh? 15 | - d) There is a tram 22 standing in the stop. How many cars does it have? 16 | 17 | 18 | ### BN.03 19 | 20 | A patient has a disease N. Physicians measure the value of a parameter P to see the disease development. 21 | The parameter can take one of the following values {low, medium, high}. 22 | The value of P is a result of patient’s unobservable condition/state S. 23 | S can be {good, poor}. The state changes between two consecutive days in one fifth of cases. 24 | If the patient is in good condition, the value for P is rather low (having 10 sample measurements, 5 of them are low, 3 medium and 2 high), while if the patient is in poor condition, the value is rather high (having 10 measurements, 3 are low, 3 medium and 4 high). 25 | On arrival to the hospital on day 0, the patient’s condition was unknown, i.e., P(S0 = good) = 0:5. 26 | - a) Draw the transition and sensor model of the dynamic Bayesian network modeling the domain under consideration, 27 | - b) calculate probability that the patient is in good condition on day 2 given low P values on days 1 and 2, 28 | - c) can you determine the most likely patient state sequence in days 0, 1 and 2 without any additional computations?, justify. 29 | -------------------------------------------------------------------------------- /Exercises/AI-W03-Search01.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 10, 6 | "id": "ac744e79", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "graph = {\n", 11 | " \"Nodes\" : [1,2,3],\n", 12 | " \"Edges\" : {\n", 13 | " 1 : [2,3],\n", 14 | " 2 : [3]\n", 15 | " }\n", 16 | "}" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 11, 22 | "id": "e7b4074c", 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "data": { 27 | "text/plain": [ 28 | "{'Nodes': [1, 2, 3], 'Edges': {1: [2, 3], 2: [3]}}" 29 | ] 30 | }, 31 | "execution_count": 11, 32 | "metadata": {}, 33 | "output_type": "execute_result" 34 | } 35 | ], 36 | "source": [ 37 | "graph" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 13, 43 | "id": "87e402a4", 44 | "metadata": {}, 45 | "outputs": [ 46 | { 47 | "data": { 48 | "text/plain": [ 49 | "[1, 2, 3]" 50 | ] 51 | }, 52 | "execution_count": 13, 53 | "metadata": {}, 54 | "output_type": "execute_result" 55 | } 56 | ], 57 | "source": [ 58 | "graph[\"Nodes\"]" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 23, 64 | "id": "1a3c2503", 65 | "metadata": {}, 66 | "outputs": [], 67 | "source": [ 68 | "visitedNodes = []\n", 69 | "pathToGoal = {}\n", 70 | "\n", 71 | "def DFS(xgraph, x, nGoal, level=0):\n", 72 | " global visitedNodes\n", 73 | " global pathToGoal\n", 74 | " visitedNodes.append(x)\n", 75 | " pathToGoal[level] = x\n", 76 | " if (x == nGoal):\n", 77 | " return True\n", 78 | " else:\n", 79 | " tt = False\n", 80 | " i = 0\n", 81 | " n = 0\n", 82 | " childs = []\n", 83 | " if (x in xgraph[\"Edges\"]):\n", 84 | " childs = xgraph[\"Edges\"][x]\n", 85 | " n = len(childs)\n", 86 | " while (tt==False and i < n):\n", 87 | " if (childs[i] in set(visitedNodes)):\n", 88 | " tt = False\n", 89 | " else:\n", 90 | " tt = DFS(xgraph, childs[i], nGoal, level+1)\n", 91 | " i += 1\n", 92 | " return tt" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 25, 98 | "id": "0fedaa31", 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [ 102 | "kq = DFS(graph, 1, 3)" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 28, 108 | "id": "0faa274e", 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "data": { 113 | "text/plain": [ 114 | "(True, {0: 's', 1: 'd', 2: 'e', 3: 'r', 4: 'f', 5: 'g'})" 115 | ] 116 | }, 117 | "execution_count": 28, 118 | "metadata": {}, 119 | "output_type": "execute_result" 120 | } 121 | ], 122 | "source": [ 123 | "kq, pathToGoal" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 18, 129 | "id": "1082c14b", 130 | "metadata": {}, 131 | "outputs": [], 132 | "source": [ 133 | "graph2 = {\n", 134 | " \"Nodes\" : [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \n", 135 | " \"g\", \"h\", \"p\", \"q\", \"r\", \"s\"],\n", 136 | " \"Edges\" : {\n", 137 | " \"s\" : [\"d\", \"e\", \"p\"],\n", 138 | " \"d\" : [\"b\", \"c\", \"e\"],\n", 139 | " \"b\" : [\"a\"],\n", 140 | " \"c\" : [\"a\"],\n", 141 | " \"p\" : [\"q\"],\n", 142 | " \"e\" : [\"h\", \"r\"],\n", 143 | " \"h\" : [\"q\"],\n", 144 | " \"r\" : [\"f\"],\n", 145 | " \"f\" : [\"c\", \"g\"]\n", 146 | " }\n", 147 | "}" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 27, 153 | "id": "157e0475", 154 | "metadata": {}, 155 | "outputs": [], 156 | "source": [ 157 | "kq = DFS(graph2, \"s\", \"g\")" 158 | ] 159 | } 160 | ], 161 | "metadata": { 162 | "kernelspec": { 163 | "display_name": "Python 3 (ipykernel)", 164 | "language": "python", 165 | "name": "python3" 166 | }, 167 | "language_info": { 168 | "codemirror_mode": { 169 | "name": "ipython", 170 | "version": 3 171 | }, 172 | "file_extension": ".py", 173 | "mimetype": "text/x-python", 174 | "name": "python", 175 | "nbconvert_exporter": "python", 176 | "pygments_lexer": "ipython3", 177 | "version": "3.10.9" 178 | } 179 | }, 180 | "nbformat": 4, 181 | "nbformat_minor": 5 182 | } 183 | -------------------------------------------------------------------------------- /Exercises/AI-W05-TikTakToe.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "020ff4dd", 6 | "metadata": {}, 7 | "source": [ 8 | "# Tik Tak Toe \n", 9 | "\n", 10 | "Lần 1: (10%)\n", 11 | "1. 3x3\n", 12 | "2. 5x5\n", 13 | "3. 10x10\n", 14 | "- Người chơi với máy\n", 15 | "\n", 16 | "Lần 2: (30%)\n", 17 | "1. 100x100 \n", 18 | "2. 1000x1000 \n", 19 | "3. Heuristic + Alg\n", 20 | "- Máy chơi với máy (call APIs) - Team A vs Team B \n", 21 | "- Run (5đ)\n", 22 | "- Qua mỗi vòng + 1 điểm \n", 23 | "\n", 24 | "\n" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 10, 30 | "id": "8adbbfe3", 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "import numpy as np\n", 35 | "import math\n", 36 | "import random\n" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 2, 42 | "id": "bcedb74b", 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "N = 5\n", 47 | "rSize = 5 # số ô liên tiếp cho phép chiến thắng\n" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 3, 53 | "id": "26838840", 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "tiktaktoeBoard = np.zeros( (N, N) )" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 4, 63 | "id": "531977ce", 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "def printState(xState):\n", 68 | " print(\"\\n\\n\\n _____________________________ \")\n", 69 | " #print(xState)\n", 70 | " #print(\"\\n ....... \")\n", 71 | " for row in xState:\n", 72 | " s = \"\"\n", 73 | " for cell in row:\n", 74 | " curr = \"-\"\n", 75 | " if (cell == 1):\n", 76 | " curr = \"X\"\n", 77 | " if (cell == 2):\n", 78 | " curr = \"O\"\n", 79 | " s += \"\\t\" + curr\n", 80 | " print(s)\n", 81 | " print(\"\\n ....... \")\n", 82 | "\n", 83 | "def inputOPosition():\n", 84 | " r = int ( input(\"Nhap ROW ( 14\u001b[0m r,c \u001b[38;5;241m=\u001b[39m \u001b[43minputXY\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# inputOPosition()\u001b[39;00m\n\u001b[0;32m 15\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (checkRCvalid(r,c)):\n\u001b[0;32m 16\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m ( checkAvailable(r,c) ):\n", 245 | "Cell \u001b[1;32mIn[4], line 25\u001b[0m, in \u001b[0;36minputXY\u001b[1;34m()\u001b[0m\n\u001b[0;32m 23\u001b[0m inXY \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNhap vi tri can Danh: ROW COLUMN ( 25\u001b[0m r \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mint\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43m \u001b[49m\u001b[43minXY\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 26\u001b[0m c \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m ( inXY[\u001b[38;5;241m1\u001b[39m] )\n\u001b[0;32m 27\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (r,c)\n", 246 | "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'sdwq'" 247 | ] 248 | } 249 | ], 250 | "source": [ 251 | "## Zero State \n", 252 | "currentState = np.zeros(( N, N )) # tiktaktoeBoard\n", 253 | "\n", 254 | "\n", 255 | "## Playing\n", 256 | "printState(currentState)\n", 257 | "\n", 258 | "while ( not (isWinner(1) or isWinner(2)) ): \n", 259 | " ## Máy chơi\n", 260 | " selectSolution() # Máy chọn nước đi kế tiếp\n", 261 | " printState(currentState)\n", 262 | "\n", 263 | " ## Người chơi\n", 264 | " r,c = inputXY() # inputOPosition()\n", 265 | " if (checkRCvalid(r,c)):\n", 266 | " if ( checkAvailable(r,c) ):\n", 267 | " currentState[r,c] = 2\n", 268 | " printState(currentState)\n", 269 | " else:\n", 270 | " print(\" ....... vi tri da DANH ! \")\n", 271 | " else:\n", 272 | " print(\" ...... r,c NGOAI pham vi \")\n", 273 | "\n", 274 | "\n", 275 | "if isWinner(1):\n", 276 | " print(\"Player 1 la Nguoi THANG\")\n", 277 | "if isWinner(2):\n", 278 | " print(\"Player 2 la Nguoi THANG\")" 279 | ] 280 | } 281 | ], 282 | "metadata": { 283 | "kernelspec": { 284 | "display_name": "Python 3 (ipykernel)", 285 | "language": "python", 286 | "name": "python3" 287 | }, 288 | "language_info": { 289 | "codemirror_mode": { 290 | "name": "ipython", 291 | "version": 3 292 | }, 293 | "file_extension": ".py", 294 | "mimetype": "text/x-python", 295 | "name": "python", 296 | "nbconvert_exporter": "python", 297 | "pygments_lexer": "ipython3", 298 | "version": "3.11.2" 299 | } 300 | }, 301 | "nbformat": 4, 302 | "nbformat_minor": 5 303 | } 304 | -------------------------------------------------------------------------------- /Exercises/AI-W07-TikTakToe-Score.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "020ff4dd", 6 | "metadata": {}, 7 | "source": [ 8 | "# Tik Tak Toe \n", 9 | "\n", 10 | "Lần 1: (10%)\n", 11 | "1. 3x3\n", 12 | "2. 5x5\n", 13 | "3. 10x10\n", 14 | "- Người chơi với máy\n", 15 | "\n", 16 | "Lần 2: (30%)\n", 17 | "1. 100x100 \n", 18 | "2. 1000x1000 \n", 19 | "3. Heuristic + Alg\n", 20 | "- Máy chơi với máy (call APIs) - Team A vs Team B \n", 21 | "- Run (5đ)\n", 22 | "- Qua mỗi vòng + 1 điểm \n", 23 | "\n", 24 | "\n" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 1, 30 | "id": "8adbbfe3", 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "import numpy as np\n", 35 | "import math\n", 36 | "import random\n" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 2, 42 | "id": "bcedb74b", 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "N = 3\n", 47 | "rSize = 3 # số ô liên tiếp cho phép chiến thắng\n" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 3, 53 | "id": "26838840", 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "tiktaktoeBoard = np.zeros( (N, N) )" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 4, 63 | "id": "531977ce", 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "def printState(xState):\n", 68 | " print(\"\\n\\n\\n _____________________________ \")\n", 69 | " #print(xState)\n", 70 | " #print(\"\\n ....... \")\n", 71 | " for row in xState:\n", 72 | " s = \"\"\n", 73 | " for cell in row:\n", 74 | " curr = \"-\"\n", 75 | " if (cell == 1):\n", 76 | " curr = \"X\"\n", 77 | " if (cell == 2):\n", 78 | " curr = \"O\"\n", 79 | " s += \"\\t\" + curr\n", 80 | " print(s)\n", 81 | " print(\"\\n ....... \")\n", 82 | "\n", 83 | "def inputOPosition():\n", 84 | " r = int ( input(\"Nhap ROW ( score01[1]):\n", 219 | " minSteps = score01[1]\n", 220 | " totalSols += score01[0]\n", 221 | " #--- Row 2\n", 222 | " score01 = checkOneLine( \n", 223 | " ( solution[2,0], solution[2,1], solution[2,2] ) , x)\n", 224 | " if (minSteps > score01[1]):\n", 225 | " minSteps = score01[1]\n", 226 | " totalSols += score01[0]\n", 227 | " #--- Col 0\n", 228 | " score01 = checkOneLine( \n", 229 | " ( solution[0,0], solution[1,0], solution[2,0] ) , x)\n", 230 | " if (minSteps > score01[1]):\n", 231 | " minSteps = score01[1]\n", 232 | " totalSols += score01[0]\n", 233 | " #--- Col 1\n", 234 | " score01 = checkOneLine( \n", 235 | " ( solution[0,1], solution[1,1], solution[2,1] ) , x)\n", 236 | " if (minSteps > score01[1]):\n", 237 | " minSteps = score01[1]\n", 238 | " totalSols += score01[0]\n", 239 | " #--- Col 2\n", 240 | " score01 = checkOneLine( \n", 241 | " ( solution[0,2], solution[1,2], solution[2,2] ) , x)\n", 242 | " if (minSteps > score01[1]):\n", 243 | " minSteps = score01[1]\n", 244 | " totalSols += score01[0]\n", 245 | " #--- diagonal 1\n", 246 | " score01 = checkOneLine( \n", 247 | " ( solution[0,0], solution[1,1], solution[2,2] ) , x)\n", 248 | " if (minSteps > score01[1]):\n", 249 | " minSteps = score01[1]\n", 250 | " totalSols += score01[0]\n", 251 | " #--- diagonal 2\n", 252 | " score01 = checkOneLine( \n", 253 | " ( solution[2,0], solution[1,1], solution[0,2] ) , x)\n", 254 | " if (minSteps > score01[1]):\n", 255 | " minSteps = score01[1]\n", 256 | " totalSols += score01[0]\n", 257 | " return (totalSols, minSteps)" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 8, 263 | "id": "9d314a91", 264 | "metadata": {}, 265 | "outputs": [], 266 | "source": [ 267 | "def selectSolution():\n", 268 | " #r = random.randint(0, N)\n", 269 | " #c = random.randint(0, N)\n", 270 | " bestSols = None\n", 271 | " for r in range(N):\n", 272 | " for c in range(N):\n", 273 | " if (checkRCvalid(r,c)):\n", 274 | " if ( checkAvailable(r,c) ):\n", 275 | " ##### currentState[r,c] = 1\n", 276 | " newState = currentState.copy()\n", 277 | " newState[r,c] = 1\n", 278 | " scoreSol = calculateSCORE_H01(newState, 2)\n", 279 | " if (bestSols == None):\n", 280 | " bestSols = { \"score\" : scoreSol,\n", 281 | " \"pos\" : (r,c) }\n", 282 | " else:\n", 283 | " if (bestSols[\"score\"][1] < scoreSol[1]):\n", 284 | " bestSols = { \"score\" : scoreSol,\n", 285 | " \"pos\" : (r,c) }\n", 286 | " if (bestSols != None):\n", 287 | " r = bestSols[\"pos\"][0]\n", 288 | " c = bestSols[\"pos\"][1]\n", 289 | " currentState[r,c] = 1\n", 290 | " print(\"... Chon nuoc di \", bestSols)\n", 291 | " else:\n", 292 | " print(\".... khong chon duoc giai phap !!!\")" 293 | ] 294 | }, 295 | { 296 | "cell_type": "markdown", 297 | "id": "67293a5b", 298 | "metadata": {}, 299 | "source": [ 300 | "## Main Process" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 9, 306 | "id": "e1e182f0", 307 | "metadata": {}, 308 | "outputs": [ 309 | { 310 | "name": "stdout", 311 | "output_type": "stream", 312 | "text": [ 313 | "\n", 314 | "\n", 315 | "\n", 316 | " _____________________________ \n", 317 | "\t-\t-\t-\n", 318 | "\t-\t-\t-\n", 319 | "\t-\t-\t-\n", 320 | "\n", 321 | " ....... \n", 322 | "... Chon nuoc di {'score': (0, 1000), 'pos': (0, 0)}\n", 323 | "\n", 324 | "\n", 325 | "\n", 326 | " _____________________________ \n", 327 | "\tX\t-\t-\n", 328 | "\t-\t-\t-\n", 329 | "\t-\t-\t-\n", 330 | "\n", 331 | " ....... \n", 332 | "Nhap vi tri can Danh: ROW COLUMN ( 14\u001b[0m r,c \u001b[38;5;241m=\u001b[39m \u001b[43minputXY\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# inputOPosition()\u001b[39;00m\n\u001b[0;32m 15\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (checkRCvalid(r,c)):\n\u001b[0;32m 16\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m ( checkAvailable(r,c) ):\n", 245 | "Cell \u001b[1;32mIn[4], line 25\u001b[0m, in \u001b[0;36minputXY\u001b[1;34m()\u001b[0m\n\u001b[0;32m 23\u001b[0m inXY \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNhap vi tri can Danh: ROW COLUMN ( 25\u001b[0m r \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mint\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43m \u001b[49m\u001b[43minXY\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 26\u001b[0m c \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m ( inXY[\u001b[38;5;241m1\u001b[39m] )\n\u001b[0;32m 27\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (r,c)\n", 246 | "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'sdwq'" 247 | ] 248 | } 249 | ], 250 | "source": [ 251 | "## Zero State \n", 252 | "currentState = np.zeros(( N, N )) # tiktaktoeBoard\n", 253 | "\n", 254 | "\n", 255 | "## Playing\n", 256 | "printState(currentState)\n", 257 | "\n", 258 | "while ( not (isWinner(1) or isWinner(2)) ): \n", 259 | " ## Máy chơi\n", 260 | " selectSolution() # Máy chọn nước đi kế tiếp\n", 261 | " printState(currentState)\n", 262 | "\n", 263 | " ## Người chơi\n", 264 | " r,c = inputXY() # inputOPosition()\n", 265 | " if (checkRCvalid(r,c)):\n", 266 | " if ( checkAvailable(r,c) ):\n", 267 | " currentState[r,c] = 2\n", 268 | " printState(currentState)\n", 269 | " else:\n", 270 | " print(\" ....... vi tri da DANH ! \")\n", 271 | " else:\n", 272 | " print(\" ...... r,c NGOAI pham vi \")\n", 273 | "\n", 274 | "\n", 275 | "if isWinner(1):\n", 276 | " print(\"Player 1 la Nguoi THANG\")\n", 277 | "if isWinner(2):\n", 278 | " print(\"Player 2 la Nguoi THANG\")" 279 | ] 280 | } 281 | ], 282 | "metadata": { 283 | "kernelspec": { 284 | "display_name": "Python 3 (ipykernel)", 285 | "language": "python", 286 | "name": "python3" 287 | }, 288 | "language_info": { 289 | "codemirror_mode": { 290 | "name": "ipython", 291 | "version": 3 292 | }, 293 | "file_extension": ".py", 294 | "mimetype": "text/x-python", 295 | "name": "python", 296 | "nbconvert_exporter": "python", 297 | "pygments_lexer": "ipython3", 298 | "version": "3.11.2" 299 | } 300 | }, 301 | "nbformat": 4, 302 | "nbformat_minor": 5 303 | } 304 | -------------------------------------------------------------------------------- /Project-TikTakToe/AI-W07-TikTakToe-Score.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "020ff4dd", 6 | "metadata": {}, 7 | "source": [ 8 | "# Tik Tak Toe \n", 9 | "\n", 10 | "Lần 1: (10%)\n", 11 | "1. 3x3\n", 12 | "2. 5x5\n", 13 | "3. 10x10\n", 14 | "- Người chơi với máy\n", 15 | "\n", 16 | "Lần 2: (30%)\n", 17 | "1. 100x100 \n", 18 | "2. 1000x1000 \n", 19 | "3. Heuristic + Alg\n", 20 | "- Máy chơi với máy (call APIs) - Team A vs Team B \n", 21 | "- Run (5đ)\n", 22 | "- Qua mỗi vòng + 1 điểm \n", 23 | "\n", 24 | "\n" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 1, 30 | "id": "8adbbfe3", 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "import numpy as np\n", 35 | "import math\n", 36 | "import random\n" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 2, 42 | "id": "bcedb74b", 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "N = 3\n", 47 | "rSize = 3 # số ô liên tiếp cho phép chiến thắng\n" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 3, 53 | "id": "26838840", 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "tiktaktoeBoard = np.zeros( (N, N) )" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 4, 63 | "id": "531977ce", 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "def printState(xState):\n", 68 | " print(\"\\n\\n\\n _____________________________ \")\n", 69 | " #print(xState)\n", 70 | " #print(\"\\n ....... \")\n", 71 | " for row in xState:\n", 72 | " s = \"\"\n", 73 | " for cell in row:\n", 74 | " curr = \"-\"\n", 75 | " if (cell == 1):\n", 76 | " curr = \"X\"\n", 77 | " if (cell == 2):\n", 78 | " curr = \"O\"\n", 79 | " s += \"\\t\" + curr\n", 80 | " print(s)\n", 81 | " print(\"\\n ....... \")\n", 82 | "\n", 83 | "def inputOPosition():\n", 84 | " r = int ( input(\"Nhap ROW ( score01[1]):\n", 219 | " minSteps = score01[1]\n", 220 | " totalSols += score01[0]\n", 221 | " #--- Row 2\n", 222 | " score01 = checkOneLine( \n", 223 | " ( solution[2,0], solution[2,1], solution[2,2] ) , x)\n", 224 | " if (minSteps > score01[1]):\n", 225 | " minSteps = score01[1]\n", 226 | " totalSols += score01[0]\n", 227 | " #--- Col 0\n", 228 | " score01 = checkOneLine( \n", 229 | " ( solution[0,0], solution[1,0], solution[2,0] ) , x)\n", 230 | " if (minSteps > score01[1]):\n", 231 | " minSteps = score01[1]\n", 232 | " totalSols += score01[0]\n", 233 | " #--- Col 1\n", 234 | " score01 = checkOneLine( \n", 235 | " ( solution[0,1], solution[1,1], solution[2,1] ) , x)\n", 236 | " if (minSteps > score01[1]):\n", 237 | " minSteps = score01[1]\n", 238 | " totalSols += score01[0]\n", 239 | " #--- Col 2\n", 240 | " score01 = checkOneLine( \n", 241 | " ( solution[0,2], solution[1,2], solution[2,2] ) , x)\n", 242 | " if (minSteps > score01[1]):\n", 243 | " minSteps = score01[1]\n", 244 | " totalSols += score01[0]\n", 245 | " #--- diagonal 1\n", 246 | " score01 = checkOneLine( \n", 247 | " ( solution[0,0], solution[1,1], solution[2,2] ) , x)\n", 248 | " if (minSteps > score01[1]):\n", 249 | " minSteps = score01[1]\n", 250 | " totalSols += score01[0]\n", 251 | " #--- diagonal 2\n", 252 | " score01 = checkOneLine( \n", 253 | " ( solution[2,0], solution[1,1], solution[0,2] ) , x)\n", 254 | " if (minSteps > score01[1]):\n", 255 | " minSteps = score01[1]\n", 256 | " totalSols += score01[0]\n", 257 | " return (totalSols, minSteps)" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 8, 263 | "id": "9d314a91", 264 | "metadata": {}, 265 | "outputs": [], 266 | "source": [ 267 | "def selectSolution():\n", 268 | " #r = random.randint(0, N)\n", 269 | " #c = random.randint(0, N)\n", 270 | " bestSols = None\n", 271 | " for r in range(N):\n", 272 | " for c in range(N):\n", 273 | " if (checkRCvalid(r,c)):\n", 274 | " if ( checkAvailable(r,c) ):\n", 275 | " ##### currentState[r,c] = 1\n", 276 | " newState = currentState.copy()\n", 277 | " newState[r,c] = 1\n", 278 | " scoreSol = calculateSCORE_H01(newState, 2)\n", 279 | " if (bestSols == None):\n", 280 | " bestSols = { \"score\" : scoreSol,\n", 281 | " \"pos\" : (r,c) }\n", 282 | " else:\n", 283 | " if (bestSols[\"score\"][1] < scoreSol[1]):\n", 284 | " bestSols = { \"score\" : scoreSol,\n", 285 | " \"pos\" : (r,c) }\n", 286 | " if (bestSols != None):\n", 287 | " r = bestSols[\"pos\"][0]\n", 288 | " c = bestSols[\"pos\"][1]\n", 289 | " currentState[r,c] = 1\n", 290 | " print(\"... Chon nuoc di \", bestSols)\n", 291 | " else:\n", 292 | " print(\".... khong chon duoc giai phap !!!\")" 293 | ] 294 | }, 295 | { 296 | "cell_type": "markdown", 297 | "id": "67293a5b", 298 | "metadata": {}, 299 | "source": [ 300 | "## Main Process" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 9, 306 | "id": "e1e182f0", 307 | "metadata": {}, 308 | "outputs": [ 309 | { 310 | "name": "stdout", 311 | "output_type": "stream", 312 | "text": [ 313 | "\n", 314 | "\n", 315 | "\n", 316 | " _____________________________ \n", 317 | "\t-\t-\t-\n", 318 | "\t-\t-\t-\n", 319 | "\t-\t-\t-\n", 320 | "\n", 321 | " ....... \n", 322 | "... Chon nuoc di {'score': (0, 1000), 'pos': (0, 0)}\n", 323 | "\n", 324 | "\n", 325 | "\n", 326 | " _____________________________ \n", 327 | "\tX\t-\t-\n", 328 | "\t-\t-\t-\n", 329 | "\t-\t-\t-\n", 330 | "\n", 331 | " ....... \n", 332 | "Nhap vi tri can Danh: ROW COLUMN ( 26/6) 4 | 5 | ### TikTokToe Client 6 | - Windows: https://drive.google.com/file/d/15bhgf8_Yw0S2wbLnEkpNOEvmugFwLR1F/view?usp=drive_link 7 | - Linux: 8 | - MacOS: 9 | 10 | ## Mô tả các tình huống sử dụng 11 | 12 | CLIENT-TicTacToe.exe start ABC BaDoSa 13 | --> thông báo cho Server biết là người chơi BaDoSa sẵn sàng chơi trận game ABC 14 | 15 | CLIENT-TicTacToe.exe status ABC 16 | --> kiểm tra trạng thái của trận game ABC và coi tới lượt chơi chưa 17 | 18 | CLIENT-TicTacToe.exe play ABC BaDoSa 2 3 19 | --> thông báo cho Server biết là người chơi BaDoSa đi nước cờ tại dòng 2 cột 2 trong trận game ABC 20 | 21 | ### * Code gọi và parse dữ liệu từ python (chạy trên colab, notebook) [đã viết sẵn trong client] 22 | 23 | ### Code gọi từ Python trên Colab hoặc Notebook 24 | * (chú ý vị trí thư mục của tập tin thực thi CLIENT-TicTacYoe) 25 | - Cách 1 26 | import os 27 | stream = os.popen('CLIENT-TicTacToe start ABC BaDoSa') 28 | output = stream.read() 29 | output 30 | 31 | - Cách 2 32 | import subprocess 33 | 34 | xCaro = subprocess.Popen(["CLIENT-TicTacToe", "start", "ABC", "BaDoSa"], 35 | stdin =subprocess.PIPE, 36 | stdout=subprocess.PIPE, 37 | stderr=subprocess.PIPE, 38 | universal_newlines=True, 39 | bufsize=0) 40 | /// fetch output 41 | for line in xCaro.stdout: 42 | print(line.strip()) 43 | 44 | 45 | -------------------------------------------------------------------------------- /Project-TikTakToe/PR.Exercise.01.md: -------------------------------------------------------------------------------- 1 | # Tik Tak Toe - Heuristic Function 2 | 3 | **Objective:** 4 | This exercise is designed to help students understand how decision-making processes are modeled in Artificial Intelligence through the implementation of a simple turn-based game: Tic-Tac-Toe. Students will explore how rule-based systems and evaluation functions guide an AI agent to make optimal moves. 5 | 6 | **Group Task:** 7 | Each group of students is required to complete the following tasks: 8 | 9 | 1. **Define Move Selection Rules:** 10 | - Develop a clear set of rules or heuristics that an AI player can use to select the next move in a Tic-Tac-Toe game. 11 | - These rules should reflect rational decision-making aimed at achieving a win or preventing the opponent from winning (e.g., prioritizing a winning move, blocking an opponent’s winning move, or optimizing for future opportunities). 12 | - Ensure the rules are concise, prioritized, and easy for an AI to follow. 13 | 14 | 2. **Define Evaluation Functions or Formulas:** 15 | - Create a mathematical function or algorithm to evaluate the desirability of a given Tic-Tac-Toe game state from the AI’s perspective. 16 | - The function should assign a numerical score to each possible move, enabling the AI to select the most promising option among all available moves. 17 | - Explain how the function accounts for key factors, such as: 18 | - Potential for a win in the current or future turns. 19 | - Threats posed by the opponent’s potential winning moves. 20 | - Opportunities to block the opponent or create strategic advantages. 21 | - Provide a clear example of how the function evaluates a sample board state. 22 | 23 | 3. **Scenario Description:** 24 | - Describe a specific Tic-Tac-Toe game scenario where player X (controlled by the AI) must make a move immediately after player O places their mark at position A. 25 | ``` 26 | - - - 27 | O - - 28 | - - - 29 | ``` 30 | 31 | - Using the move selection rules and evaluation function defined above, explain step-by-step how the AI-controlled X determines its next move. Include: 32 | - The evaluation scores for all possible moves. 33 | - The rationale for selecting the optimal move based on the rules and function. 34 | 35 | -------------------------------------------------------------------------------- /Project-TikTakToe/PR.Rubrics.md: -------------------------------------------------------------------------------- 1 | 2 | # Tik Tak Toe - Rubrics 3 | 4 | ## Stage/Sprint 1 5 | 6 | --- 7 | 8 | ### **1. Score Function / Heuristic Function – 3.5 points** 9 | 10 | | Score | Description | 11 | | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 12 | | **3.5 pts** | The heuristic function is well-designed, effectively evaluates board states considering both offensive and defensive strategies. It prioritizes winning moves, blocks losing moves, and weighs different patterns (rows, columns, diagonals) appropriately. | 13 | | **2.5 pts** | The heuristic function works reasonably but lacks depth in evaluating strategic situations (e.g., considers only wins but not threats). | 14 | | **1.5 pts** | The function exists but is overly simplistic, focusing only on basic counts without strategic value. | 15 | | **0.5 pt** | The function is written but incorrect or ineffective in real gameplay. | 16 | | **0 pt** | No heuristic function implemented or it crashes. | 17 | 18 | --- 19 | 20 | ### **2. Selection (Best Move Selection) – 1.5 points** 21 | 22 | | Score | Description | 23 | | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | 24 | | **1.5 pts** | Move selection is correctly based on the heuristic function (e.g., using Minimax, Alpha-Beta, or similar), consistently choosing the best move available. | 25 | | **1 pt** | Move selection uses logic but is not optimal, or contains minor flaws in applying the evaluation. | 26 | | **0.5 pt** | Move selection is random or not aligned with the evaluation function. | 27 | | **0 pt** | No move selection logic implemented or incorrect. | 28 | 29 | --- 30 | 31 | ### **3. Checking for Win – 1 point** 32 | 33 | | Score | Description | 34 | | ---------- | ---------------------------------------------------------------------------------------------------- | 35 | | **1 pt** | Fully correct win condition checking for all directions (rows, columns, diagonals) and both players. | 36 | | **0.5 pt** | Win checking is present but incomplete or buggy (e.g., misses diagonals). | 37 | | **0 pt** | No win checking or completely incorrect logic. | 38 | 39 | --- 40 | 41 | ### **4. Running Game – 2 points** 42 | 43 | | Score | Description | 44 | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | 45 | | **2 pts** | The game runs completely from start to finish. Has basic interface (console or GUI). Supports human vs AI or AI vs AI. Game flow and rules are correctly handled. | 46 | | **1 pt** | Game runs but has minor issues (e.g., improper end conditions, limited input handling). | 47 | | **0.5 pt** | Only partial gameplay runs (e.g., individual moves work but no full loop). | 48 | | **0 pt** | Game does not run or has critical errors. | 49 | 50 | --- 51 | 52 | ### **5. Answering / Presentation – 2 points** 53 | 54 | | Score | Description | 55 | | ---------- | ----------------------------------------------------------------------------------------------------------------------------- | 56 | | **2 pts** | Student clearly explains their approach, heuristic logic, and gameplay strategy. Answers questions confidently and correctly. | 57 | | **1 pt** | Can describe general ideas but lacks clarity or depth in explanation. | 58 | | **0.5 pt** | Weak explanation, shows limited understanding of their own solution. | 59 | | **0 pt** | Unable to explain or did not participate in the presentation. | 60 | 61 | --- 62 | 63 | ## Stage/Sprint 2 64 | 65 | --- 66 | 67 | ### **1. Updated Heuristic Function – 3 points** 68 | 69 | | Score | Description | 70 | | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 71 | | **3 pts** | Heuristic is significantly improved with better evaluation logic (e.g., considers multiple strategic patterns, blocks opponent threats effectively, prioritizes win). Justification of changes is clearly explained. | 72 | | **2 pts** | Heuristic shows some improvements and reflects moderate updates; explanation is provided but may lack depth. | 73 | | **1 pt** | Only minimal or cosmetic changes to the heuristic; limited or no impact on AI performance. | 74 | | **0 pt** | No update made, or update is invalid/ineffective. | 75 | 76 | --- 77 | 78 | ### **2. Online Playing (API Communication) – 2 points** 79 | 80 | | Score | Description | 81 | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | 82 | | **2 pts** | Online gameplay works smoothly using APIs (e.g., REST, sockets). Player can play against another machine in real-time. Communication is reliable. | 83 | | **1 pt** | Online play is implemented but buggy or partially working (e.g., desyncs, missing turns, or limited to local network only). | 84 | | **0 pt** | Online feature does not function or is missing. | 85 | 86 | --- 87 | 88 | ### **3. Ontime (Online Response Latency) – 1 point** 89 | 90 | | Score | Description | 91 | | ---------- | ------------------------------------------------------------------ | 92 | | **1 pt** | Latency is **under 1 second** (real-time response experience). | 93 | | **0.5 pt** | Latency is **between 1–2 seconds** (acceptable, minor delay). | 94 | | **0 pt** | Latency is **over 2 seconds**, or gameplay suffers noticeable lag. | 95 | 96 | --- 97 | 98 | ### **4. Running Game – 2 points** 99 | 100 | | Score | Description | 101 | | --------- | ---------------------------------------------------------------------------------------------------------------------------- | 102 | | **2 pts** | Game is fully operational, integrates both AI logic and online play. User interface (even console) is stable and responsive. | 103 | | **1 pt** | Game runs with some minor bugs or missing features. | 104 | | **0 pt** | Game crashes or is unplayable. | 105 | 106 | --- 107 | 108 | ### **5. Q\&A / Presentation – 2 points** 109 | 110 | | Score | Description | 111 | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | 112 | | **2 pts** | Student explains updated heuristic, online logic, and system architecture clearly. Answers questions confidently and shows strong understanding. | 113 | | **1 pt** | Student explains partially or with some confusion. | 114 | | **0 pt** | Cannot explain or does not participate in discussion. | 115 | 116 | --- 117 | 118 | -------------------------------------------------------------------------------- /Project-TikTakToe/PR.ref.md: -------------------------------------------------------------------------------- 1 | 2 | # Tik Tak Toe 3 | 4 | ![image](https://github.com/user-attachments/assets/2e8cba93-5e46-4918-bb76-3c5191d8df79) 5 | 6 | 7 | ## REFs 8 | - https://www.neverstopbuilding.com/blog/minimax 9 | - https://www.geeksforgeeks.org/finding-optimal-move-in-tic-tac-toe-using-minimax-algorithm-in-game-theory/ 10 | - https://www.freecodecamp.org/news/how-to-make-your-tic-tac-toe-game-unbeatable-by-using-the-minimax-algorithm-9d690bad4b37/ 11 | - https://thecodingtrain.com/challenges/154-tic-tac-toe-minimax 12 | - https://www.datacamp.com/tutorial/minimax-algorithm-for-ai-in-python 13 | - https://www.codechef.com/practice/course/intermediate-projects-java/ADVJAPR04/problems/ADJAPPR21 14 | - http://article.sapub.org/10.5923.j.jgt.20200901.01.html 15 | - https://www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-1-introduction/ 16 | - https://github.com/Cledersonbc/tic-tac-toe-minimax 17 | - https://kevinfengcs88.medium.com/tic-tac-go-a-gophers-approach-to-the-minimax-algorithm-1cb9433ae3cf 18 | -------------------------------------------------------------------------------- /Project-TikTakToe/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | ## Link - Python code: 3 | - https://colab.research.google.com/drive/1F_8qMr4hxAqFKqsNPKILrlTYiZW3Pmd0?usp=sharing 4 | 5 | ## Mô tả: 6 | - State lưu trong 1 Bảng / Array / Matrix 2 chiều 7 | - Đi "luân phiên" Player 1 , Player 2 8 | - Thời gian giới hạn ( người 30" ; máy 15" ) 9 | - Trạng thái ghi nhận người chơi đánh vào từng ô 10 | 0: chưa có ai 11 | 1: ô này do Player 1 đánh 12 | 2: ô này do Player 2 đánh 13 | - Thắng khi: liên tiếp max 5 ô được đi 14 | hàng 15 | cột 16 | chéo (thuận, ngược) 17 | 18 | 19 | ## Project Stage 01 - W10 - Đánh giá lần 1 (Mid) 20 | - 3.5p - Score Function / Heuristic function 21 | - 1.5p - Selection 22 | - 1p - Checking for win 23 | - 2p - Running Game 24 | - 2p - Answering 25 | 26 | ## Project Stage 02 - W14/15 - Đánh giá lần 2 (Final) 27 | - 3p - updated Heuristic 28 | - 2p - online playing (call APIs) 29 | - 1p - ontime 30 | - 2p - running Game 31 | - 2p - Q/A 32 | 33 | ## WEB: 34 | - http://adtekdev.top/ 35 | 36 | 37 | ## REFs 38 | - https://github.com/AvaibleUser/min-max-tree-exercise 39 | 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AI 2 | 3 | ## Slides (pdf) 4 | - https://drive.google.com/drive/folders/1b4Y_71dg9n9SB8GuBTbHbOyTffHm4VDC?usp=sharing 5 | 6 | 7 | ## Books 8 | - https://drive.google.com/drive/folders/1AfTxq11QjQJQFVYj8rWuiHK0Fx8hQren?usp=sharing 9 | 10 | ## Syllabus 11 | - https://drive.google.com/drive/folders/1PabfZeEU2TORWPDKTpsilgsTiyP279xN?usp=sharing 12 | 13 | ## Exercises 14 | - https://github.com/AdTekDev/AI/tree/main/Exercises 15 | - https://aimacode.github.io/aima-exercises/ 16 | - https://github.com/aimacode 17 | 18 | ## Project 19 | - https://github.com/AdTekDev/AI/tree/main/Project-TikTakToe 20 | 21 | ## FB group 22 | - https://www.facebook.com/groups/ArtificialIntelligenceCourses 23 | 24 | ## Tools 25 | - https://visualgo.net/en 26 | - https://algorithm-visualizer.org/ 27 | - https://www.cs.usfca.edu/~galles/visualization/Algorithms.html 28 | - https://qiao.github.io/PathFinding.js/visual/ 29 | - 30 | 31 | ## REFs 32 | - https://aima.cs.berkeley.edu/ 33 | - https://mat.uab.cat/~alseda/MasterOpt/ 34 | -------------------------------------------------------------------------------- /Seminar/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Seminar - Topics 3 | 4 | -------------------------------------------------------------------------------- /Seminar/Topics-2025.03.md: -------------------------------------------------------------------------------- 1 | 2 | # AI Topics - 2025.03 3 | 4 | ## General Instructions 5 | - Students will work in groups to complete this project. (2-5 students) 6 | - Each group must choose one topic only from the options listed below. 7 | - Topics are divided into three major categories: Tool-Based Topics, Application Domains, and Use Case Scenarios. 8 | - Each category contains several specific topics, along with a set of uniform requirements for all topics within that category. 9 | 10 | ## TOPICs 11 | 12 | ### Category 1: Tool-Based Topics 13 | **Objective**: Explore and evaluate AI-related tools and platforms. 14 | 15 | **Requirements**: 16 | 1. Clearly describe the main features and functionalities of the selected tool. 17 | 2. Analyze the advantages and limitations of the tool in practical use. 18 | 3. Identify and explain the machine learning models integrated into the tool that are applicable to real-world problems. 19 | 4. Demonstrate how to use the tool, specifying the types of inputs and outputs it accepts or generates. 20 | 5. Design five different prompts for a specific scenario, use them in the tool, and critically evaluate the outcomes in terms of relevance, accuracy, and usability. 21 | 22 | **Tools**: 23 | - **TO**.001 - Midjourney https://www.midjourney.com/ 24 | - **TO**.002 - synthesia https://www.synthesia.io/ 25 | - **TO**.003 - runway https://app.runwayml.com/ 26 | - **TO**.004 - filmora https://filmora.wondershare.com/ 27 | - **TO**.005 - opus https://www.opus.pro/ 28 | - **TO**.006 - cursor https://www.cursor.com/ 29 | - **TO**.007 - murf https://murf.ai/ 30 | - **TO**.008 - udio https://www.udio.com/ 31 | - **TO**.009 - kling https://www.klingai.com/global/ 32 | - **TO**.010 - GG AI Studio - Gen video https://aistudio.google.com/generate-video 33 | - **TO**.011 - pictory https://app.pictory.ai/v2/home 34 | - **TO**.012 - hailuoai https://hailuoai.video/ 35 | - **TO**.013 - lumen5 https://lumen5.com/ 36 | - **TO**.014 - seaart https://www.seaart.ai/ 37 | - **TO**.015 - virbo https://virbo.wondershare.com/app/ 38 | 39 | 40 | 41 | 42 | 43 | ### Category 2: Application Domains 44 | **Objective**: Investigate how AI tools are applied in specific professional or industrial domains. 45 | 46 | **Requirements**: 47 | 1. Provide an overview of the selected domain, including its core characteristics. 48 | 2. Explain the benefits of using AI tools in various tasks or operations within the domain. 49 | 3. Identify and describe relevant training models that can be applied in this domain using existing tools. 50 | 4. Select three real-world scenarios within the domain, and for each, demonstrate how an AI tool can be used, including details on inputs, processing, and outputs. 51 | 5. For one chosen scenario, create five different prompt variations, apply them using the tool, and analyze the results in terms of effectiveness and potential impact. 52 | 53 | **Domains**: 54 | 55 | - **DOM**.001 - Gen AI For Developers https://www.tutorialspoint.com/gen-ai/generative-ai-for-developers.htm 56 | - **DOM**.002 - Generative AI in Manufacturing https://www.tutorialspoint.com/gen-ai/generative-ai-in-manufacturing.htm 57 | - **DOM**.003 - Generative AI for Educators https://www.tutorialspoint.com/gen-ai/generative-ai-for-educators.htm 58 | - **DOM**.004 - Generative AI for Students https://www.tutorialspoint.com/gen-ai/generative-ai-for-students.htm 59 | - **DOM**.005 - Generative AI for Industry https://www.tutorialspoint.com/gen-ai/generative-ai-for-industry.htm 60 | - **DOM**.006 - Generative AI for Marketing https://www.tutorialspoint.com/gen-ai/generative-ai-for-marketing.htm 61 | - **DOM**.007 - Generative AI for Healthcare https://www.tutorialspoint.com/gen-ai/generative-ai-for-healthcare.htm 62 | - **DOM**.008 - Generative AI for Cooking https://www.tutorialspoint.com/gen-ai/generative-ai-for-cooking.htm 63 | 64 | ### Category 3: Use Case Scenarios 65 | **Objective**: Analyze specific real-world situations and propose AI-driven solutions. 66 | 67 | 68 | **Requirements**: 69 | 1. Clearly define the problem presented in the selected use-case. 70 | 2. Describe the context and characteristics of the scenario. 71 | 3. Identify appropriate AI models, architecture, algorithms, or solution workflows that can be applied to address the problem. 72 | 4. Discuss the results achieved by applying the chosen solution, supported by data or evidence where applicable. 73 | 5. Provide an in-depth evaluation of the solution’s performance and discuss future improvements or emerging trends related to the scenario. 74 | 75 | **Use Cases / Case Studies**: 76 | - **CA**.001 - Multiple Virtual Assistants in Walmart https://medium.com/walmartglobaltech/a-unified-multi-task-model-for-supporting-multiple-virtual-assistants-in-walmart-2b077c2c96e 77 | - **CA**.002 - AI Professor https://www.linkedin.com/pulse/ai-professor-harvard-chatltv-jeffrey-bussgang-oiaie/ 78 | - **CA**.003 - Leveraging Real-Time User Actions to Personalize Etsy Ads https://www.etsy.com/uk/codeascraft/leveraging-real-time-user-actions-to-personalize-etsy-ads https://arxiv.org/pdf/2302.01255 79 | - **CA**.004 - Scaling marketing for merchants with targeted and intelligent promos https://engineering.grab.com/scaling-marketing-for-merchants 80 | - **CA**.005 - Evolution of Ads Conversion Optimization Models at Pinterest https://medium.com/pinterest-engineering/evolution-of-ads-conversion-optimization-models-at-pinterest-84b244043d51 81 | - **CA**.006 - How We Automated Content Marketing to Acquire Users at Scale https://engineering.atspotify.com/2023/11/how-we-automated-content-marketing-to-acquire-users-at-scale/ 82 | - **CA**.007 - Leverage graph technology for real-time Fraud Detection and Prevention https://medium.com/booking-com-development/leverage-graph-technology-for-real-time-fraud-detection-and-prevention-438336076ea5 83 | - **CA**.008 - Machine Learning for Fraud Detection in Streaming Services https://netflixtechblog.com/machine-learning-for-fraud-detection-in-streaming-services-b0b4ef3be3f6 84 | 85 | 86 | 87 | ## Submission Notes: 88 | - Each group is expected to submit a comprehensive report and a presentation of their findings. 89 | - Proper citation and academic integrity must be maintained. 90 | - Creativity, critical thinking, and clarity of analysis will be highly valued in the evaluation. 91 | 92 | **Deadline**: Week 12th 93 | **Submit**: 94 | - pptx (30+ slides) 95 | - zip (input data + prompts -> output data) 96 | -------------------------------------------------------------------------------- /Test/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Test.A 3 | 4 | Describe a real family as a list of facts of the following form: 5 | 6 | father( f, c) /* f is father of child c */ 7 | mother( m, c) /* m is mother of child c */ 8 | man( m) /* m is man */ 9 | woman( w) /* w is woman */ 10 | drinks( x, y) /* x drinks y */ 11 | studies( x, y) / student x studies course y / 12 | teaches( x, y) / x teaches course y / 13 | 14 | ### Define the following predicates: (3 marks) 15 | 16 | parent( P, C) /* P is father or mother of C */ 17 | 18 | parents( F, M, C) /* F is father, M is mother of C */ 19 | 20 | child( C, P) /* C is child of P */ 21 | 22 | son( S, P) /* S is son of P */ 23 | 24 | daughter( D, P) /* D is daughter of P */ 25 | 26 | brother( B, SB) /* B is brother of sibling SB */ 27 | 28 | sister( S, SB) /* S is sister of sibling SB */ 29 | 30 | uncle( U, N) /* U is uncle of N */ 31 | 32 | aunt( A, N) /* A is aunt of N */ 33 | 34 | student ( X ) 35 | 36 | professor( Y ) 37 | 38 | professorFamily ( X ) / X is a professor and ( parent or child of X is a professor) / 39 | 40 | goodDrink ( X ) / Y and Z drink X / 41 | 42 | 43 | ### Define further family relations e.g. niece, cousin, spouse (5 marks . 1 mark / relation) 44 | 45 | ### Define Facts and Queries !!! 46 | 47 | 48 | 49 | 50 | 51 | # Test.B 52 | 53 | Describe a real family as a list of facts of the following form: 54 | 55 | father( f, c) /* f is father of child c */ 56 | mother( m, c) /* m is mother of child c */ 57 | man( m) /* m is man */ 58 | woman( w) /* w is woman */ 59 | 60 | ### Define the following predicates: (3 marks) 61 | 62 | parent( P, C) /* P is father or mother of C */ 63 | 64 | parents( F, M, C) /* F is father, M is mother of C */ 65 | 66 | child( C, P) /* C is child of P */ 67 | 68 | son( S, P) /* S is son of P */ 69 | 70 | daughter( D, P) /* D is daughter of P */ 71 | 72 | grandfather( GP, GC) /* GV is grandfather of GC */ 73 | 74 | grandmother( GM, E /* GM is grandmother of E */ 75 | 76 | grandchild( GC, G) /* GC is grandchild of G */ 77 | 78 | brother( B, SB) /* B is brother of sibling SB */ 79 | 80 | sister( S, SB) /* S is sister of sibling SB */ 81 | 82 | uncle( U, N) /* U is uncle of N */ 83 | 84 | aunt( A, N) /* A is aunt of N */ 85 | 86 | woman( w) /* w is woman */ 87 | 88 | 89 | ### Define further family relations e.g. niece, cousin, spouse (5 marks . 1 mark / relation) 90 | 91 | ### Define Facts and Queries !!! 92 | 93 | --------------------------------------------------------------------------------