From 27ad3aeba9eb4dfe65470464a56cc5b28d7e92cb Mon Sep 17 00:00:00 2001 From: EmmanuelTiamzon Date: Tue, 24 Mar 2026 12:29:31 +0100 Subject: [PATCH] update --- DEV.3.4/TP/TP4/stub/0Bad/Base.class | Bin 0 -> 820 bytes DEV.3.4/TP/TP4/stub/0Bad/Exemple.class | Bin 0 -> 1209 bytes DEV.3.4/TP/TP4/stub/0Bad/MonBrin.class | Bin 0 -> 331 bytes DEV.3.4/TP/TP4/stub/0Bad/MonMaillon.class | Bin 0 -> 530 bytes DEV.3.4/TP/TP4/stub/1Iterable/Base.class | Bin 0 -> 820 bytes DEV.3.4/TP/TP4/stub/1Iterable/Exemple.class | Bin 0 -> 1092 bytes DEV.4.1/tp/tp1/eratosthene/eratosthene.html | 40 +++++++ DEV.4.1/tp/tp1/eratosthene/eratosthene.js | 23 ++++ DEV.4.1/tp/tp1/langton/app.js | 65 ++++++++++++ DEV.4.1/tp/tp1/langton/css/style.css | 8 ++ DEV.4.1/tp/tp1/langton/index.html | 42 ++++++++ DEV.4.1/tp/tp1/langton/modules/Ant.js | 62 +++++++++++ .../modules/langton-renderer-canvas2d.js | 99 ++++++++++++++++++ 13 files changed, 339 insertions(+) create mode 100644 DEV.3.4/TP/TP4/stub/0Bad/Base.class create mode 100644 DEV.3.4/TP/TP4/stub/0Bad/Exemple.class create mode 100644 DEV.3.4/TP/TP4/stub/0Bad/MonBrin.class create mode 100644 DEV.3.4/TP/TP4/stub/0Bad/MonMaillon.class create mode 100644 DEV.3.4/TP/TP4/stub/1Iterable/Base.class create mode 100644 DEV.3.4/TP/TP4/stub/1Iterable/Exemple.class create mode 100644 DEV.4.1/tp/tp1/eratosthene/eratosthene.html create mode 100644 DEV.4.1/tp/tp1/eratosthene/eratosthene.js create mode 100644 DEV.4.1/tp/tp1/langton/app.js create mode 100644 DEV.4.1/tp/tp1/langton/css/style.css create mode 100644 DEV.4.1/tp/tp1/langton/index.html create mode 100644 DEV.4.1/tp/tp1/langton/modules/Ant.js create mode 100644 DEV.4.1/tp/tp1/langton/modules/langton-renderer-canvas2d.js diff --git a/DEV.3.4/TP/TP4/stub/0Bad/Base.class b/DEV.3.4/TP/TP4/stub/0Bad/Base.class new file mode 100644 index 0000000000000000000000000000000000000000..729c95aa7c84d10f02456fe4b81fb6f6acf26235 GIT binary patch literal 820 zcmX^0Z`VEs1_pBm6HW#e1~o1Qbp{P~261)MvBLi1(erZv1s#_+=HJl(n>VcfW!ypClPJi)-gz{0@EAi*HXz{nuQz`&ryz{mgsT$>mew=pmsU|`DKz=Els2^1;}Oknfn8JHQE85kJYwX|inGq7#M zFkFFwfq{uZk%5Cji9r!+NdW^3$W06(yBSy_h1i+5GjMEX-~@BHSil@^Fo%Z~%;5!d z_}IW4e)hc#ERoEc7&wC?SvE0n2S>7QV&DyqWZT5RAH11?5#a(Z1||ju24)5m1||k3 O28cV98C1aTQ3U{3c8($d literal 0 HcmV?d00001 diff --git a/DEV.3.4/TP/TP4/stub/0Bad/Exemple.class b/DEV.3.4/TP/TP4/stub/0Bad/Exemple.class new file mode 100644 index 0000000000000000000000000000000000000000..1e92419ea49d4d142d5b50cbccedcc016a45dab9 GIT binary patch literal 1209 zcmX^0Z`VEs1_pD6AT9=R21QN=B?e^<1{E#_RR%S726avb4F*jv237_w5K9}x(gCq_ zL4+PVgFY7n4}$>*gCR(_5eI`Y2ZISn$P}c~3}lKqh-JafV9Cy4#mK;BlbM%UV#mn9 ztf3jk$iU*9pOVVR!0(fpm+DuVo0M7?UR*QmZ+bTn3t{} zTvC*omu?Nx$QxXen4ImKSO8Ve6`WsMl$`383DV5tT9KMtkdvwh(#pdi!63=bV9mo| z!(hwEAf23_S6ot5np~2ZpQn&gs*qHanWy0H91`N_&dy-R!(h+gz{tSmo1f>Kn3fs8EnttWcI;TC7lzlbBhQ%EREr;LXS&>z}7kkXl-z z05Kx9NFg;(A+anm@9^@(yb?wRPtP0$uwljOsd);SdBp{pMX5y!1^J~#3YobDIfqx~ zrskET7AfSYXM*Uo#NfAq~mYzC?@BLjN@NKsB6BZH_0L?e3ivN$Ccr!q1yx-&Ac`GDBgj0~I_5Edx< z86ClT!7@IGxB@2)#t=pZMrTF_ehqXPj*@&x5@KW!(a^-SnUR4bJ+;IoH3{S;J`GJ| z{frFk>8T|k3mF+WG&CVj0XqWhMX(1T!31^$e|l<3aA{^qDl`=_C^CpKh%O4(;s>oKQ9w4mLNEI2)AB6REwOf!7ygF5fl= zmQ4&yI@=idAuJ&QC@r{+fkkHis5=I6dAK&~u-^9$Eocug% zMg}&U%)HDJJ4Ob64P*(;Fh&Lz=lqmZMh1SL%)C^;(%hufqL9R-oK!{zj`Y+L7l>(m z8k)%37#X;N^Gl18Q{6H_3VD3<^PGw@^YpS3%My7Q*cpU*7+4wD7#Y~15{wK2ASwNv z#JqHU|D>$c1_lN#1||k3 z1_lN$t?dkqTH0F~m^Ok{b1^V5@G&qmFfi~lurLTPa54xoFfwp6@Idv+GB7eQGB7Z( XYHeX)+5p$W1{M@yU}WG0Tg3+eS>8Ec literal 0 HcmV?d00001 diff --git a/DEV.3.4/TP/TP4/stub/0Bad/MonMaillon.class b/DEV.3.4/TP/TP4/stub/0Bad/MonMaillon.class new file mode 100644 index 0000000000000000000000000000000000000000..c5cdb93207476cbed252317b6c5a1c4736ea055f GIT binary patch literal 530 zcmX^0Z`VEs1_pBmX)Xp<22oB176vg8AoS#>cnpeumz~5`0TI#+V`N})&QD2YWZ?J7 z%uDqv%}q)z3Q0`LNo8aZg(^Ze7NmhaJ+%a6AR_~Zh9<-uMh5=$)RN%R%#u{70~i_j zG>QGBR)l=a&{Gr@Cc=4ChCCERlzSi$RKqfrEjQhk=cOosoeHp@5M=0Hj1e zCowNw-#;lUHMxY5fmuT{j6sosg@KiUfq{vE38V|m;$YxpU|?WjU}WH8;AUWC;9+23 z&;qMqVBpf)&cLXpy_JD!BLf2iBLgo30|OreGXnzyF9Qn$9|I=?KUg0hRG%>e6IhlX zu1`y6D+4n^vk(Id0|Nty6lUOL5MkhB5M^Lw;Aaqk8X(KS$iT?Jz`&}tg@I`U+)g&I apacUWgCK(t7NyMSN@W-r8HB;!69EACLRK39 literal 0 HcmV?d00001 diff --git a/DEV.3.4/TP/TP4/stub/1Iterable/Base.class b/DEV.3.4/TP/TP4/stub/1Iterable/Base.class new file mode 100644 index 0000000000000000000000000000000000000000..729c95aa7c84d10f02456fe4b81fb6f6acf26235 GIT binary patch literal 820 zcmX^0Z`VEs1_pBm6HW#e1~o1Qbp{P~261)MvBLi1(erZv1s#_+=HJl(n>VcfW!ypClPJi)-gz{0@EAi*HXz{nuQz`&ryz{mgsT$>mew=pmsU|`DKz=Els2^1;}Oknfn8JHQE85kJYwX|inGq7#M zFkFFwfq{uZk%5Cji9r!+NdW^3$W06(yBSy_h1i+5GjMEX-~@BHSil@^Fo%Z~%;5!d z_}IW4e)hc#ERoEc7&wC?SvE0n2S>7QV&DyqWZT5RAH11?5#a(Z1||ju24)5m1||k3 O28cV98C1aTQ3U{3c8($d literal 0 HcmV?d00001 diff --git a/DEV.3.4/TP/TP4/stub/1Iterable/Exemple.class b/DEV.3.4/TP/TP4/stub/1Iterable/Exemple.class new file mode 100644 index 0000000000000000000000000000000000000000..9e48e56ccc53a4f49f8d5f598d257feec224fad1 GIT binary patch literal 1092 zcmX^0Z`VEs1_pBmUoHkw26;{f1qMY91|=>AWd;>?231Z5H3oGq237_Q5K9xp(gLxx zL4*!FgDw{X4}%^DgFZ;N0SAL2h;IZUj6p`2urrvlGng?lu-RnhWtP}6GB9gshA}d* zIOnINGBWV{Wag#%mF6a;7KJ1x<)kt)u;eCY<}oseX+-;EC6*=X=OpH(>j#$VdTKFo-dTvoo0UFjz2HGBQXf z=jRod6qP2IWaj57q?9To6=mirxI2f0IJ&blSn)7eGuSXPaQWuv`6g!O{PEEfiQMh14@{5+?k%sh}1S4IZY9QDMsw9Mp;#Pn2!g2W<) zl*2325=%?qw&kTNlqD(@Bo-@_<(C#K6yzjk7NznqxG}ghGC26>DHNoZmMDM%pd>Xf zF|R}cVp?jELTa8uX361|MPR|Q)MSOyJcaU%%$!t(fAq~mYzC?@BLjN@NKsB6BZH_0L?e2Hu{b3br!q1yx-&Ac`GDBgj0~I_5Edvx z86ClT!7@IG&<960V+bPyqcbA|zXrMtM@c>;Q7|%yXlP>E%*eo=kyz}PT2TT{aZ!v6 zEO}rKhlVD^Zm_LjKY?8g2^VY4Fa|{i5e88P5MW|p1f?McMg|E61_oIMMg~R(1_oBG z?F@_?85kHC86+7P7}&sq%nY0iQVh~irB4}H7?>Ft7}_^6FbOelV_@0Mz#6%Ufo(ej zyAOoPp}n1f6Uyeo!RAI1XM?hNBDJ?O@cM$x<=e)^Ll%Q5LlJ{GLnVU*LmPtvgA4-$0}lh!Uxp%f23B?k9$^MX23ZCM1||kM E04yE#1^@s6 literal 0 HcmV?d00001 diff --git a/DEV.4.1/tp/tp1/eratosthene/eratosthene.html b/DEV.4.1/tp/tp1/eratosthene/eratosthene.html new file mode 100644 index 0000000..fa89a09 --- /dev/null +++ b/DEV.4.1/tp/tp1/eratosthene/eratosthene.html @@ -0,0 +1,40 @@ + + + + + + + + + +
+ +
+ + +
+
+

time :

+

time :

+

+
+
+ + + diff --git a/DEV.4.1/tp/tp1/eratosthene/eratosthene.js b/DEV.4.1/tp/tp1/eratosthene/eratosthene.js new file mode 100644 index 0000000..713fbc5 --- /dev/null +++ b/DEV.4.1/tp/tp1/eratosthene/eratosthene.js @@ -0,0 +1,23 @@ + +function eratosthene(n) +{ + let primes = []; + let filterArray = []; + for(let i = 2; i <=n; i++){ + // TODO + } + return primes; +} + +function eratosthene1(n) +{ + let numbers = Array.from({length : n - 2}, (v,k) => k + 2); + let p ,primes = []; + + while(numbers.length){ + [p,...numbers] = numbers; + numbers = numbers.filter( x => x%p != 0); + primes = [...primes,p]; + } + return primes; +} diff --git a/DEV.4.1/tp/tp1/langton/app.js b/DEV.4.1/tp/tp1/langton/app.js new file mode 100644 index 0000000..8871d05 --- /dev/null +++ b/DEV.4.1/tp/tp1/langton/app.js @@ -0,0 +1,65 @@ +import render from "./modules/langton-renderer-canvas2d"; +import Ant from "./modules/Ant.js"; + + +const options = { + antStateColors : ['red','yellow'], + tileStateColors : ['white','black'], + tileSize : 5 +}; + + +// For the view + +const STEP_INTERVAL = 5; +const BTN_AUTOPLAY_ID = 'autoplay'; +const BTN_NEXT_MOVE_ID = 'next-move'; +const MOVE_VAL_ID = 'move-value'; +const BTN_PLUS_100_ID = 'plus-100'; + + + + +let autoplayInterval; +let canvas = document.querySelector("canvas"); + + +canvas.width = window.innerWidth ; +canvas.height = window.innerHeight; + +let ant = new Ant(Math.floor(canvas.width / options.tileSize),Math.floor(canvas.height/options.tileSize)); + +document.getElementById(BTN_AUTOPLAY_ID).addEventListener('click', () => { + if (autoplayInterval) { + return + } + // TODO +}); + + +document.getElementById(BTN_PLUS_100_ID).addEventListener('click', () => { + if (autoplayInterval) { + clearInterval(autoplayInterval); + autoplayInterval = null; + } + // TODO +}); + +document.getElementById(BTN_NEXT_MOVE_ID).addEventListener('click', () => { + if (autoplayInterval) { + clearInterval(autoplayInterval); + autoplayInterval = null; + } + ant.moveForward(); + updateView(ant,canvas,options) +}) + + +function updateView(ant,canvas,options) +{ + document.getElementById(MOVE_VAL_ID).textContent = `${ant.move}`; + render(ant,canvas,options); +} + + +updateView(ant,canvas,options); diff --git a/DEV.4.1/tp/tp1/langton/css/style.css b/DEV.4.1/tp/tp1/langton/css/style.css new file mode 100644 index 0000000..192272f --- /dev/null +++ b/DEV.4.1/tp/tp1/langton/css/style.css @@ -0,0 +1,8 @@ +canvas { + position : absolute ; + top : 0; + left : 0; + z-index : -1; +} + + diff --git a/DEV.4.1/tp/tp1/langton/index.html b/DEV.4.1/tp/tp1/langton/index.html new file mode 100644 index 0000000..3b09a8a --- /dev/null +++ b/DEV.4.1/tp/tp1/langton/index.html @@ -0,0 +1,42 @@ + + + + + + + Fourmi de Langton + + + + + + + +
+

+ Fourmi de Langton +

+ + +
+ + + + diff --git a/DEV.4.1/tp/tp1/langton/modules/Ant.js b/DEV.4.1/tp/tp1/langton/modules/Ant.js new file mode 100644 index 0000000..86f70f7 --- /dev/null +++ b/DEV.4.1/tp/tp1/langton/modules/Ant.js @@ -0,0 +1,62 @@ +class Ant { + x = 0; // position + y = 0; + move = 0; + + w = 0; // universe dimensions + h = 0; + + direction = 0; // 0 90 180 270 + state = 0; + tiles = null; + + constructor (w,h) + { + this.tiles = new Array(w).fill(null); + this.tiles.forEach((el,i) => this.tiles[i] = new Array(h).fill(0)); + this.w = w; + this.h = h; + this.x = Math.floor(w/2); + this.y = Math.floor(h/2); + } + + moveForward() + { + switch (this.direction) { + case 0: + this.x = ((this.x + 1) + this.w) % this.w; + break + case 90: + this.y = ((this.y + 1) + this.h) % this.h; + break + case 180: + this.x = ((this.x - 1) + this.w) % this.w; + break + case 270: + this.y = ((this.y - 1) + this.h) % this.h; + break + } + this.move ++; + this.computeNextState(); + } + rotateRight() { + this.direction = (this.direction + 90)%360; + } + + rotateLeft() { + this.direction = (this.direction + 270)%360; + } + + computeNextState() { + if(this.tiles[this.x][this.y] === 1) { //On vérifie si la prochaine case est noire + //On fait en sorte à ce qu'elle soit repeinte en blanc et tourne de 90° à gauche. + this.tiles[this.x][this.y] = 0; + this.rotateLeft(); + } else { //Dans ce cas si la prochaine case est blanche + // On fait en sorte à ce qu'elle soit repeinte en noir et tourne de 90° à droite. + this.tiles[this.x][this.y] = 1; + this.rotateRight(); + } + } + +export default Ant; diff --git a/DEV.4.1/tp/tp1/langton/modules/langton-renderer-canvas2d.js b/DEV.4.1/tp/tp1/langton/modules/langton-renderer-canvas2d.js new file mode 100644 index 0000000..c5fdf60 --- /dev/null +++ b/DEV.4.1/tp/tp1/langton/modules/langton-renderer-canvas2d.js @@ -0,0 +1,99 @@ +/** + * render - renders the universe to a 2D canvas. + * + * @param langtonsAnt - the universe. + * @param canvas - The 2D canvas. + * @param options - The rendering options (all optional). + * @returns {undefined} - Nothing is returned. + */ + +function render(langtonsAnt, canvas, options) { + + // Grab our options. + const { + tileStateColors, + antStateColors, + tileSize + } = options; + + + // Drawing style. + const backgroundColor = '#FFFFFF'; + + // Size constants. + const w = canvas.width; + const h = canvas.height; + + // Bounds constants. + const gridSizeW = langtonsAnt.tiles.length; + const gridSizeH = langtonsAnt.tiles[0].length; + + // We're going to draw each square with a given edge size + + const tileSizeW = tileSize;//w / gridSizeW ; + const tileSizeH = tileSize; //h / gridSizeH ; + + // Get the drawing context. + var ctx = canvas.getContext('2d'); + + // Clear the background. + ctx.fillStyle = backgroundColor; + ctx.fillRect(0, 0, w, h); + + // Draw the grid. + ctx.strokeStyle='#00000011'; + for (let x = 0; x <= gridSizeW; x++) { + ctx.beginPath(); + ctx.moveTo(x * tileSizeW , 0); + ctx.lineTo(x * tileSizeW , h); + ctx.closePath(); + ctx.stroke(); + } + for (let y = 0 ; y <= gridSizeH; y++) { + ctx.beginPath(); + ctx.moveTo(0, y * tileSizeH); + ctx.lineTo(w, y * tileSizeH); + ctx.closePath(); + ctx.stroke(); + } + + + // Start drawing those tiles. + langtonsAnt.tiles.forEach((tileRow,i) => { + tileRow.forEach((tile,j)=>{ + + // Get the tile state index. + + // Skip state zero tiles (i.e. white tiles) + if (tile !== 0) { + // Set the tile colour, defaulting to grey if it is not set. + ctx.fillStyle = tileStateColors[tile] || '#CCCCCC'; + ctx.fillRect(i * tileSizeW + 1, j * tileSizeH +1, tileSizeW - 1, tileSizeH - 1); + } + + }) + }) + + + // Draw the ant. + var antX = langtonsAnt.x * tileSizeW, + antY = langtonsAnt.y * tileSizeH; + const antState = langtonsAnt.state; + + ctx.fillStyle = antStateColors[antState]; + // Tranform before we draw the ant, it makes it easier. + // + ctx.save(); + ctx.translate(antX + tileSizeW/2, antY+tileSizeH/2); + ctx.rotate((langtonsAnt.direction / 180) * Math.PI); + ctx.beginPath(); + ctx.moveTo(-tileSizeW/2, -tileSizeH/2); + ctx.lineTo(tileSizeW/2, 0); + ctx.lineTo(-tileSizeW/2, tileSizeH/2); + ctx.fill(); + ctx.closePath(); + ctx.restore(); +} + + +export default render;