Cov txheej txheem:
- Kauj Ruam 1: Tau Txais Txhua Qhov
- Kauj Ruam 2: Qhov 2.8 "Kov Xim Zaub rau Arduino
- Kauj Ruam 3: Tsim Txoj Haujlwm thiab Xeem Nws
- Kauj Ruam 4: Game Algorithm
- Kauj Ruam 5: Txoj Cai ntawm Txoj Haujlwm
- Kauj Ruam 6: Kev Xav Thaum Kawg thiab Kev Txhim Kho
Video: Arduino Touch Tic Tac Toe Game: 6 Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Nyob zoo cov phooj ywg zoo siab txais tos rau lwm qhov kev qhia Arduino! Hauv qhov kev qhia ntxaws no peb tab tom tsim Arduino Tic Tac Toe game. Raws li koj tuaj yeem pom, peb tab tom siv lub vijtsam kov thiab peb tabtom tawm tsam lub computer. Kev ua si yooj yim zoo li Tic Tac Toe yog qhov qhia zoo rau kev ua si game thiab Artificial Intelligence. Txawm hais tias peb yuav tsis siv Artificial Intelligence Algorithms hauv qhov kev ua si no, peb yuav nkag siab tias vim li cas Artificial Intelligence Algorithms yuav tsum muaj nyob hauv kev ua si nyuaj dua.
Tsim kev ua si rau Arduino tsis yooj yim thiab xav tau sijhawm ntau. Tab sis peb tuaj yeem tsim qee qhov kev ua si yooj yim rau Arduino vim tias nws lom zem thiab nws yuav tso cai rau peb tshawb xyuas qee cov ncauj lus kom zoo dua qub, zoo li Artificial txawj ntse. Nws yog qhov kev kawm paub zoo thiab thaum kawg koj yuav muaj kev ua si zoo rau cov menyuam!
Cia tam sim no tsim txoj haujlwm no.
Kauj Ruam 1: Tau Txais Txhua Qhov
Cov ntu xav tau txhawm rau txhawm rau tsim txoj haujlwm no yog cov hauv qab no:
Ib Arduino Uno ▶
A 2.8 "Touch Screen ▶
Tus nqi ntawm txoj haujlwm yog tsawg heev. Nws tsuas yog 15 $
Ua ntej sim tsim txoj haujlwm no thov saib cov vis dis aus Kuv tau npaj txog qhov kov cov khoom. Kuv tau txuas nws hauv cov lus qhia no. Nws yuav pab koj nkag siab cov cai, thiab ntsuas lub vijtsam kov.
Kauj Ruam 2: Qhov 2.8 "Kov Xim Zaub rau Arduino
Kuv pom lub vijtsam kov no ntawm banggood.com thiab txiav txim siab yuav nws txhawm rau sim siv nws hauv qee qhov ntawm kuv cov phiaj xwm. Raws li koj tuaj yeem pom cov zaub tsis kim, nws raug nqi ib ncig $ 11.
Tau nws ntawm no ▶
Cov zaub muaj kev daws teeb meem ntawm 320x240 pixels thiab nws los ua ib daim ntaub thaiv uas ua rau kev sib txuas nrog Arduino yooj yim heev. Raws li koj tuaj yeem pom, cov zaub siv yuav luag tag nrho cov digital thiab analog pins ntawm Arduino Uno. Thaum siv daim ntaub thaiv no peb tshuav nrog tsuas yog 2 tus pin thiab 1 tus pin analog rau peb cov phiaj xwm. Hmoov zoo, cov zaub ua haujlwm tau zoo nrog Arduino Mega ib yam nkaus, yog li peb thaum peb xav tau tus pin ntau dua peb tuaj yeem siv Arduino Mega hloov chaw ntawm Arduino Uno. Hmoov tsis zoo cov zaub no tsis ua haujlwm nrog Arduino Due lossis Wemos D1 ESP8266 board. Lwm qhov zoo ntawm daim ntaub thaiv yog tias nws muab lub micro SD qhov uas yog qhov yooj yim heev rau siv.
Kauj Ruam 3: Tsim Txoj Haujlwm thiab Xeem Nws
Tom qab txuas lub vijtsam mus rau Arduino Uno, peb tuaj yeem thauj cov cai thiab peb npaj ua si.
Thaum xub thawj, peb nias lub pob "Start Game" thiab qhov kev ua si pib. Arduino ua si ua ntej. Peb tuaj yeem ua si peb qhov txav yooj yim los ntawm kov lub vijtsam. Arduino tom qab ntawd ua nws qhov kev txav mus thiab lwm yam. Tus neeg ua si uas ua tiav hauv kev tso peb ntawm lawv cov cim hauv kab rov tav, ntsug, lossis kab pheeb ces kaum yeej qhov kev ua si. Thaum qhov kev ua si dhau lawm, Game Over screen tshwm. Peb tuaj yeem nias lub pob ua si dua kom pib qhov kev ua si dua.
Arduino zoo heev ntawm qhov kev ua si no. Nws yuav yeej feem ntau ntawm cov kev ua si, lossis yog tias koj yog tus neeg uas ua tau zoo heev qhov kev ua si yuav xaus nrog kev kos. Kuv txhob txwm tsim qhov txheej txheem no kom ua qee qhov yuam kev txhawm rau muab txoj hauv kev rau tib neeg ua si los yeej. Los ntawm kev ntxiv ob kab ntxiv rau cov cai ntawm kev ua si, peb tuaj yeem ua rau Arduino tsis tuaj yeem plam qhov kev ua si. Tab sis yuav ua li cas 2 $ nti, Arduino CPU, tuav tib neeg lub hlwb? Puas yog txoj haujlwm peb tsim ntse tshaj tib neeg lub hlwb?
Kauj Ruam 4: Game Algorithm
Txhawm rau teb lo lus nug no, cia saib lub algorithm uas kuv tau siv.
Lub computer ib txwm ua si ua ntej. Qhov kev txiav txim siab ib leeg no, ua rau kev ua si yooj yim dua rau Arduino los yeej. Thawj qhov txav mus yog ib lub ces kaum. Qhov thib ob, txav mus rau Arduino kuj tseem yog lub kaum ntse ntse los ntawm qhov seem uas tsis muaj kev saib xyuas txog cov neeg siv txav mus txhua. Txij ntawm no mus, Arduino thawj qhov kev tshuaj xyuas yog tias tus neeg uas ua ntawv tuaj yeem yeej hauv kev txav mus tom ntej thiab thaiv qhov uas txav mus. Yog tias tus neeg ua si tsis tuaj yeem yeej hauv kev txav mus ib leeg, nws ua lub ces kaum txav yog tias nws muaj lossis tsis raug xaiv los ntawm qhov seem. Qhov ntawd yog nws, qhov txheej txheem yooj yim no tuaj yeem tuav tib neeg cov neeg ua si txhua lub sijhawm lossis ntawm qhov xwm txheej phem tshaj plaws qhov kev ua si yuav ua rau raug kos. Qhov no tsis yog qhov zoo tshaj plaws tic tac ntiv taw game algorithm, tab sis ib qho ntawm qhov yooj yim tshaj plaws.
Qhov txheej txheem no tuaj yeem ua tiav hauv Arduino yooj yim, vim Tic Tac Toe game yog qhov yooj yim heev, thiab peb tuaj yeem txheeb xyuas nws yooj yim thiab daws nws. Yog tias peb tsim cov ntoo game peb tuaj yeem tshawb pom qee cov tswv yim yeej thiab siv tau yooj yim hauv cov lej lossis peb tuaj yeem cia CPU suav cov ntoo game hauv lub sijhawm tiag tiag thiab xaiv qhov zoo tshaj plaws txav los ntawm nws tus kheej. Tau kawg, lub algorithm peb siv hauv qhov kev ua si no yooj yim heev, vim tias qhov kev ua si yog yooj yim heev. Yog tias peb sim tsim cov txheej txheem yeej rau chess, txawm tias peb siv lub khoos phis tawj nrawm tshaj plaws peb tsis tuaj yeem suav cov ntoo game hauv ib txhiab xyoo! Txog kev ua si zoo li no, peb xav tau lwm txoj hauv kev, peb xav tau qee qhov kev txawj ntse Artificial Intelligence algorithms thiab tau kawg ua lub zog loj. Xav paub ntau ntxiv txog qhov no hauv video yav tom ntej.
Kauj Ruam 5: Txoj Cai ntawm Txoj Haujlwm
Cia peb saib nrawm ntawm txoj cai ntawm qhov haujlwm. Peb xav tau peb lub tsev qiv ntawv nyob rau hauv kev txiav txim tus lej los ua ke.
- Adafruit TFTLCD:
- Adafruit GFX:
- Touchscreen:
Raws li koj tuaj yeem pom, txawm tias qhov kev ua si yooj yim zoo li no, xav tau ntau dua 600 kab ntawm cov cai. Cov cai yog qhov nyuaj, yog li kuv yuav tsis sim piav qhia hauv kev qhia luv. Kuv yuav qhia koj qhov kev siv ntawm cov txheej txheem rau Arduino txav mus.
Thaum xub thawj, peb ua ob lub ces kaum tsis raug.
<int firstMoves = {0, 2, 6, 8}; // yuav siv cov haujlwm no ua ntej rau (counter = 0; counter <4; counter ++) // Suav thawj qhov txav mus ua si {yog (board [firstMoves [counter]! = 0) // Thawj qhov kev txav yog ua los ntawm ib tus neeg {movesPlayed ++; }} ua {yog (txav <= 2) {int randomMove = random (4); int c = firstMoves [randomMove]; yog (board [c] == 0) {ncua (1000); board [c] = 2; Serial.print (firstMoves [randomMove]); Serial.println (); drawCpuMove (firstMoves [randomMove]); b = 1; }}
Tom ntej no, hauv txhua qhov kev sib tw peb xyuas seb tus neeg uas ua ntawv tuaj yeem yeej hauv qhov kev txav mus tom ntej.
int checkOpponent ()
{yog (board [0] == 1 && board [1] == 1 && board [2] == 0) rov 2; lwm yog (board [0] == 1 && board [1] == 0 && board [2] == 1) rov 1; lwm yog (board [1] == 1 && board [2] == 1 && board [0] == 0) rov 0; lwm yog (board [3] == 1 && board [4] == 1 && board [5] == 0) rov 5; lwm yog (board [4] == 1 && board [5] == 1 && board [3] == 0) rov 3; lwm yog (board [3] == 1 && board [4] == 0 && board [5] == 1) rov 4; lwm yog (board [1] == 0 && board [4] == 1 && board [7] == 1) return 1; lwm tus xa rov qab 100; }
Yog tias yog peb thaiv qhov txav ntawd, feem ntau. Peb tsis thaiv txhua qhov kev txav chaw txhawm rau muab txoj hauv kev rau tib neeg ua si los yeej. Koj tuaj yeem pom qhov txav uas tsis raug thaiv? Tom qab thaiv qhov txav chaw, peb ua ib lub ces kaum ntxiv, lossis txav mus los yam tsis raug cai. Koj tuaj yeem kawm txoj cai, thiab siv koj tus kheej qhov tsis sib xws yooj yim dua. Raws li ib txwm koj tuaj yeem pom cov cai ntawm txoj haujlwm txuas nrog ntawm cov lus qhia no.
NCO TSEG: Txij li thaum Banggood muab cov duab zoo ib yam nrog ob lub vijtsam sib txawv, yog tias cov cai saum toj no tsis ua haujlwm, hloov pauv qhov pib ua haujlwm rau hauv qab no:
void initDisplay ()
{tft.reset (); tft.begin (0x9341); tft.setRotation (3); }
Kauj Ruam 6: Kev Xav Thaum Kawg thiab Kev Txhim Kho
Raws li koj tuaj yeem pom, txawm tias muaj Arduino Uno, peb tuaj yeem tsim qhov txheej txheem tsis txaus ntseeg rau kev ua si yooj yim. Txoj haujlwm no zoo heev, vim nws yooj yim los tsim, thiab tib lub sijhawm qhia zoo rau Artificial txawj ntse thiab kev ua si game. Kuv yuav sim tsim qee qhov haujlwm siab dua nrog Artificial Intelligence yav tom ntej siv Raspberry Pi muaj zog dua yog li nyob twj ywm! Kuv yuav nyiam hnov koj lub tswv yim hais txog qhov haujlwm no.
Thov tshaj tawm koj cov lus hauv qab no thiab tsis txhob hnov qab nyiam cov lus qhia yog tias koj pom nthuav. Ua tsaug!
Pom zoo:
Microbit Tic Tac Toe Game: 4 Kauj Ruam (nrog Duab)
Microbit Tic Tac Toe Game: Rau qhov haujlwm no, kuv tus neeg ua haujlwm ua haujlwm - @descartez thiab kuv tau tsim qhov txaus ntshai tic tac ntiv taw kev ua si siv xov tooj cua ua haujlwm ntawm microbits. Yog tias koj tsis tau hnov txog microbits ua ntej, lawv yog qhov txaus microcontroller tsim los qhia cov menyuam txoj haujlwm. Lawv
3D4x Game: 3D 4x4x4 Tic-Tac-Toe: 5 Kauj Ruam (nrog Duab)
3D4x Game: 3D 4x4x4 Tic-Tac-Toe: Koj puas nkees ua si ib yam, qub, tho txawv, 2-seem tic-tac-toe ?? Zoo peb muaj cov tshuaj rau koj! Tic-tac-ntiv taw hauv 3-qhov loj me !!! Rau 2 tus neeg ua si, hauv 4x4x4 lub voos xwmfab, tau txais 4 LEDs uake (hauv ib qho kev qhia) thiab koj yeej! Koj ua nws. Koj plam
Yuav Ua Li Cas Tic Tac Toe Game Siv Swift Nrog Xcode: 5 Kauj Ruam
Yuav Ua Li Cas Tic Tac Toe Game Siv Swift Nrog Xcode: Hauv qhov kev qhia Swift no kuv yuav qhia koj yuav tsim Tic Tac Toe App li cas. Cov app no yooj yim heev thiab yog txoj haujlwm zoo rau txhua tus pib. Kuv yuav tawg qhov kev qhia ua peb theem: 1. Tsim cov khoom 2. Txuas cov khoom rau hauv txoj cai 3. Cov c
Sib tham sib Tic-Tac Toe Game Tswj Nrog Arduino: 6 Cov Kauj Ruam
Sib tham sib Tic-Tac Toe Game Tswj Nrog Arduino: Lub hom phiaj ntawm Lub Cev Lub Cev Tic-Tac-Toe yog txhawm rau txav kev ua si uas paub zoo mus rau hauv lub cev tiag tiag. Thaum xub thawj, qhov kev ua si yog ua los ntawm ob tus neeg ua si ntawm ib daim ntawv - los ntawm kev tso 'X' thiab 'O' cov cim sib dhos. Peb lub tswv yim yog los tshuaj xyuas cov neeg ua yeeb yam
Arduino thiab Touchpad Tic Tac Toe: 8 Kauj Ruam (nrog Duab)
Arduino thiab Touchpad Tic Tac Toe: Los yog, kev tawm dag zog hauv kev tawm tswv yim thiab tso zis ntau ntxiv, thiab ua haujlwm nrog cov khoom. Thiab xa mus rau Arduino kev sib tw. Qhov no yog kev ua tiav ntawm tic tac ntiv taw kev ua si siv 3x3 array ntawm bicoloured LEDs rau cov zaub, ib qho yooj yim tiv taus touchpad