Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2024:vstoica:andrei.petrea1210 [2024/05/25 22:50]
andrei.petrea1210 [Software Design]
pm:prj2024:vstoica:andrei.petrea1210 [2024/05/27 00:19] (current)
andrei.petrea1210 [Bibliografie/Resurse]
Line 69: Line 69:
  
 <code cpp> <code cpp>
 +// Symbols depending on object type
 +#define PACMAN "​C"​
 +#define FOOD "​*"​
 +#define ENEMY "#"​
 +
 struct PacmanObject { struct PacmanObject {
   int16_t x;   int16_t x;
Line 145: Line 150:
       }       }
     }      } 
-      //Rest of code...+      // Rest of code...
 } }
 </​code>​ </​code>​
Line 159: Line 164:
   return (val >= low && val <= high);   return (val >= low && val <= high);
 } }
- 
 </​code>​ </​code>​
  
 +Inedit, pentru inamici, am folosit un algoritm de tip **[[https://​en.wikipedia.org/​wiki/​Hill_climbing|Hill-Climbing]]**,​ care este apelat atunci cand jucatorul face o mutare, facand ca acestia sa se deplaseze catre PacMan. Fiecare inamic se va uita la starile sale vecine (//UP//, //DOWN//, //LEFT//, //RIGHT// in ordinea aceasta) si va alege prima stare mai apropiata decat pozitia sa curenta, folosind distanta Manhattan ca euristica.
  
 +<code cpp>
 +void move(int16_t dx, int16_t dy)
 +{
 +   // Rest of code...
 +   for (i = 0; i < NR_ENEMIES; i++) {
 +    int8_t j, k;
 +    int16_t currDistance = manhattanDistance(pacMan,​ enemies[i]);​
 +    PacmanObject aux;
 +    for (j = -1; j <= 1; j++) {
 +      bool ok = true;
 +      for (k = -1; k <= 1; k++) {
 +        if (abs(j) != abs(k)) {
 +          aux.x = enemies[i].x + j;
 +          aux.y = enemies[i].y + k;
 +          int16_t distance = manhattanDistance(pacMan,​ aux);
 +          if (distance < currDistance) {
 +            enemies[i].x = aux.x;
 +            enemies[i].y = aux.y;
 +            ok = false;
 +            break;
 +          }
 +        }
 +      }
 +      if (!ok) {
 +        break;
 +      }
 +    }
 +  }
 +}
 +}
  
 +int16_t manhattanDistance(PacmanObject obj1, PacmanObject obj2) {
 +  return (abs(obj2.x - obj1.x) + abs(obj2.y - obj1.y));
 +}
 +</​code>​
  
  
-===== Rezultate Obţinute =====+== Final screen ​==
  
-<note tip> +La final, jucatorul ori a colectat toate punctele ori a fost ucis de catre inamicIn functie de cele 2 urmari, se va afisa la ecran un mesaj corespunzator,​ se va schimba culoarea led-ului intr-una care reflecta rezultatul final si  
-Care au fost rezultatele obţinute în urma realizării proiectului vostru+se va pune la speaker o melodie aferenta.
-</​note>​+
  
-===== Concluzii =====+<code cpp> 
 +void loop() 
 +
 +  // Rest of code... 
 +      TFTscreen.fillScreen(TFT_BLACK);​ 
 +      char scoreSir[11];​ 
 +      sprintf(scoreSir,​ "Scor: %d\n", score); 
 +      if (ateAll) { 
 +        TFTscreen.text("​Ati castigat! :)", 15, 50); 
 +        TFTscreen.text(scoreSir,​ 40, 70); 
 +        analogWrite(PIN_GREEN,​ 0); 
 +        analogWrite(PIN_BLUE,​ 64); 
 +        playPacmanIntro();​ 
 +      } else { 
 +        TFTscreen.text("​Ati pierdut! :(", 15, 50); 
 +        TFTscreen.text(scoreSir,​ 40, 70); 
 +        analogWrite(PIN_GREEN,​ 0); 
 +        analogWrite(PIN_RED,​ 64); 
 +        playFailedSong();​ 
 +      } 
 +      gameStarted ​false; 
 +   // Rest of code... 
 +
 +</​code>​
  
-===== Download ===== 
  
-<note warning> +===== Concluzii ===== 
-O arhivă ​(sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectuluisursescheme, etc. Un fişier READMEun ChangeLog, un script ​de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-).+  * Proiectul a fost amuzant de facut (exceptand partea hardware ​:( )si acum simt ca inteleg mai bine arhitectura calculatoarelor 
 +  * Nu pot sa folosesc memoria la fel ca si pe calculatordeoarece am foarte putina memorie si se umple foarte repede 
 +  * Sa va uitati ​de 10 ori in datasheet sa verificati ca ati legat bine firele :) 
 +  * Sa va aveti planuri cum o sa arate proiectul, ca sa nu va cumparati piese degeaba si sa va cumparati piese de calitate 
 + 
 +===== Rezultate Obţinute =====
  
-Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:pm:​prj20??:​c?​** sau **:​pm:​prj20??:​c?:​nume_student** (dacă este cazul)**Exemplu:​** Dumitru Alin, 331CC -> **:​pm:​prj2009:​cc:​dumitru_alin**. +<​html>​ 
-</note>+<iframe width="​560"​ height="​315"​ src="​https://www.youtube.com/​embed/​M0we7dr7Ifs?​si=FwVCBkxV57mRdraP"​ title="​YouTube video player"​ frameborder="​0"​ allow="​accelerometer;​ autoplay; clipboard-write; encrypted-media;​ gyroscope; picture-in-picture;​ web-share"​ referrerpolicy="​strict-origin-when-cross-origin"​ allowfullscreen></​iframe
 +</html>
  
 ===== Jurnal ===== ===== Jurnal =====
Line 190: Line 256:
   * **19.05** - Adaugat legarea initiala   * **19.05** - Adaugat legarea initiala
   * **21.05** - Adaugat design software initial + bibliografie + legarea finala   * **21.05** - Adaugat design software initial + bibliografie + legarea finala
 +  * **25.05** - Finalizat design software + pagina OCW
 ===== Bibliografie/​Resurse ===== ===== Bibliografie/​Resurse =====
  
Line 196: Line 263:
   * [[https://​docs.arduino.cc/​resources/​datasheets/​A000066-datasheet.pdf|Arduino UNO R3 Datasheet]]   * [[https://​docs.arduino.cc/​resources/​datasheets/​A000066-datasheet.pdf|Arduino UNO R3 Datasheet]]
   * [[https://​www.openhacks.com/​uploadsproductos/​tutorial_display_tft.pdf|KMR 1.8" TFT LCD Datasheet]]   * [[https://​www.openhacks.com/​uploadsproductos/​tutorial_display_tft.pdf|KMR 1.8" TFT LCD Datasheet]]
 +  * [[https://​www.youtube.com/​watch?​v=FGqRiPqg4Ds|TUTORIAL:​ How to work with a 1.8" SPI TFT with strange incorrect labelling!]]
 +  * [[https://​www.instructables.com/​Accessing-5-buttons-through-1-Arduino-pin-Revisi/​| Accessing 5 Buttons Through 1 Arduino Pin - Revisited]]
  
 === Resurse Software === === Resurse Software ===
Line 201: Line 270:
   * [[https://​www.arduino.cc/​en/​software| Arduino IDE]]   * [[https://​www.arduino.cc/​en/​software| Arduino IDE]]
   * [[https://​github.com/​robsoncouto/​arduino-songs| Arduino Songs]]   * [[https://​github.com/​robsoncouto/​arduino-songs| Arduino Songs]]
 +  * [[https://​en.wikipedia.org/​wiki/​Hill_climbing| Hill climbing]]
  
  
 +===== Download =====
  
 +<​html><​a class="​media mediafile mf_zip"​ href="​https://​ocw.cs.pub.ro/​courses/​_media/​pm/​prj2024/​vstoica/​petrea_andrei_pacman.zip">​Download archive</​a></​html>​
  
 <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​ <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​
  
pm/prj2024/vstoica/andrei.petrea1210.1716666646.txt.gz · Last modified: 2024/05/25 22:50 by andrei.petrea1210
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0