From 26a969ba23ecfc24d44a7455ecb421e0c7320e7d Mon Sep 17 00:00:00 2001 From: shaaqu Date: Tue, 7 Apr 2020 23:16:33 +0200 Subject: [PATCH 1/7] shelf rework, rapor 1 added --- README.md | 3 ++- environment.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ frontend/script.js | 10 ++++++---- 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 environment.md diff --git a/README.md b/README.md index 4d225d1..42b3be8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -Repozytorium projektu z sztucznej inteligencji, temat "Inteligentny wózek widłowy". +Repozytorium projektu z sztucznej inteligencji, temat "Inteligentny wózek widłowy".
+Zespół: 444420, 444428, 444430 diff --git a/environment.md b/environment.md new file mode 100644 index 0000000..a1d9ac1 --- /dev/null +++ b/environment.md @@ -0,0 +1,44 @@ +#Raport 1 + +###Środowisko +Środowiskiem agenta jest plansza (mapa magazynu), która jest podzielona na pola. Każde pole może być puste lub zajęte. +Agent może się poruszać tylko po polach pustych. Na polach zajętych znajdują się regały, na których przechowywane jest towar. Regały są zaznaczone za pomocą funkcji `pokolorujRegaly()` +Plansza ma wymiar 11 kolumn indeksowanych od 0 do 11 i 7 wierszy indeksowanych od 0 do 6. Pola mogą być ponumerowane dzięki funkcji `ponumerujPola()`. + +###Agent + +Agent jest reprezentowany za pomocą klasy `Agent`. +Agent jest wyświetlany na planszy przy użyciu ikony wózka widłowego (`umiescAgenta()`). +Agent porusza się po dzięki metodzie `przemieszczenie()`, która najpierw usuwa agenta z planszy (funkcja: `usunAgenta()`) nasępnie przesuwa go metodami `right()`, `left()`, +`up()`, `down()` i umieszcza go na nowej pozycji (funkcja: `umiescAgenta()`). Droga agenta jest ustala funkcją `droga()`. + +### Reprezentacja wiedzy + +Klasa `Field` - reprezentuje pola w magazynie. Posiada pola: +- `x` - współrzędna x +- `y` - współrzędna y +- `isEmpty` - określa czy pole jest puste, czy nie. + +
+ +Klasa `Product` - reprezentuje poszczególne produkty znajdujące się w magazynie. Posiada pola: +- `name` - nazwa produktu +- `type` - rodzaj produktu +- `specs` - krótki opis produktu +- `price` - cena produktu + +
+ +Klasa `Rack` - reprezentuje regały, które znajdują się w magazynie. Na jednym regale mogą znajdować się pordukty tego samego typu. Posiada pola: +- `noOfShelf` - liczbę półek danego regału + + +Metody: +- `addShelf()` - dodającą półkę do regału +- `isEmpty()` - zwracającą **true**, jeśli regał nie ma żadnych półek lub **false** w przeciwnym wypadku + +
+ +Klasa `Shelf` - reprezentuje półkę, w regale. Na jednej półce mogą znajdować się produkty o tej samej specyfikacji. Posiada pola: +- `number` - numer półki +- `typOfProduct` - rodzaj produktu, jaki znajduję się na półce \ No newline at end of file diff --git a/frontend/script.js b/frontend/script.js index 29cbec8..b3921a1 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -42,16 +42,17 @@ class Field { } class Product { - constructor(name, type, farcing, price) { + constructor(name, type, specs, price) { this.name = name; this.type = type; - this.farcing = farcing; + this.specs = specs; this.price = price } } + class Rack{ - constructor(noOfShelf, typOfProduct) { + constructor(noOfShelf) { this.noOfShelf = noOfShelf; } @@ -69,8 +70,9 @@ class Rack{ } class Shelf { - constructor(number) { + constructor(number, typeOfProduct) { this.number = number; + this.typeOfProduct = typeOfProduct; } } From 636737afd1a3d28472e694164820fbf0fd30ee21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=81ukaszewicz?= Date: Tue, 7 Apr 2020 21:17:15 +0000 Subject: [PATCH 2/7] Zaktualizuj 'environment.md' --- environment.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.md b/environment.md index a1d9ac1..aeae3c9 100644 --- a/environment.md +++ b/environment.md @@ -1,11 +1,11 @@ -#Raport 1 +# Raport 1 ###Środowisko Środowiskiem agenta jest plansza (mapa magazynu), która jest podzielona na pola. Każde pole może być puste lub zajęte. Agent może się poruszać tylko po polach pustych. Na polach zajętych znajdują się regały, na których przechowywane jest towar. Regały są zaznaczone za pomocą funkcji `pokolorujRegaly()` Plansza ma wymiar 11 kolumn indeksowanych od 0 do 11 i 7 wierszy indeksowanych od 0 do 6. Pola mogą być ponumerowane dzięki funkcji `ponumerujPola()`. -###Agent +### Agent Agent jest reprezentowany za pomocą klasy `Agent`. Agent jest wyświetlany na planszy przy użyciu ikony wózka widłowego (`umiescAgenta()`). From f8c09852af4ad2b4181ec7534de6249ec80f07e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=81ukaszewicz?= Date: Tue, 7 Apr 2020 21:17:28 +0000 Subject: [PATCH 3/7] Zaktualizuj 'environment.md' --- environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.md b/environment.md index aeae3c9..b7b319c 100644 --- a/environment.md +++ b/environment.md @@ -1,6 +1,6 @@ # Raport 1 -###Środowisko +### Środowisko Środowiskiem agenta jest plansza (mapa magazynu), która jest podzielona na pola. Każde pole może być puste lub zajęte. Agent może się poruszać tylko po polach pustych. Na polach zajętych znajdują się regały, na których przechowywane jest towar. Regały są zaznaczone za pomocą funkcji `pokolorujRegaly()` Plansza ma wymiar 11 kolumn indeksowanych od 0 do 11 i 7 wierszy indeksowanych od 0 do 6. Pola mogą być ponumerowane dzięki funkcji `ponumerujPola()`. From 2240589b2df349256fe7ca8e136bd6c77213b7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=81ukaszewicz?= Date: Tue, 7 Apr 2020 21:23:22 +0000 Subject: [PATCH 4/7] Zaktualizuj 'environment.md' --- environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.md b/environment.md index b7b319c..7c15074 100644 --- a/environment.md +++ b/environment.md @@ -10,7 +10,7 @@ Plansza ma wymiar 11 kolumn indeksowanych od 0 do 11 i 7 wierszy indeksowanych o Agent jest reprezentowany za pomocą klasy `Agent`. Agent jest wyświetlany na planszy przy użyciu ikony wózka widłowego (`umiescAgenta()`). Agent porusza się po dzięki metodzie `przemieszczenie()`, która najpierw usuwa agenta z planszy (funkcja: `usunAgenta()`) nasępnie przesuwa go metodami `right()`, `left()`, -`up()`, `down()` i umieszcza go na nowej pozycji (funkcja: `umiescAgenta()`). Droga agenta jest ustala funkcją `droga()`. +`up()`, `down()` i umieszcza go na nowej pozycji (funkcja: `umiescAgenta()`). Droga agenta jest ustala funkcją `droga()`.Przykład drogi agenta https://youtu.be/RLe2ZN5SFLo. ### Reprezentacja wiedzy From 7f67325c937bc9e802a5718937f2f19328725721 Mon Sep 17 00:00:00 2001 From: Tomek Date: Mon, 27 Apr 2020 20:47:43 +0200 Subject: [PATCH 5/7] =?UTF-8?q?Zmiany=20wprowadzone=20przez=20Wojtek=20?= =?UTF-8?q?=C5=81ukasik?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +- frontend/img/Down.png | Bin 0 -> 560 bytes frontend/img/Left.png | Bin 0 -> 567 bytes frontend/img/Right.png | Bin 0 -> 574 bytes frontend/img/Up.png | Bin 0 -> 509 bytes frontend/index.html | 102 ++-------------------------- frontend/js/Agent.js | 87 ++++++++++++++++++++++++ frontend/js/Board.js | 30 +++++++++ frontend/js/Field.js | 22 ++++++ frontend/js/main.js | 27 ++++++++ frontend/js/script.js | 125 ++++++++++++++++++++++++++++++++++ frontend/script.js | 150 ----------------------------------------- frontend/styles.css | 35 ++++++---- 13 files changed, 319 insertions(+), 262 deletions(-) create mode 100644 frontend/img/Down.png create mode 100644 frontend/img/Left.png create mode 100644 frontend/img/Right.png create mode 100644 frontend/img/Up.png create mode 100644 frontend/js/Agent.js create mode 100644 frontend/js/Board.js create mode 100644 frontend/js/Field.js create mode 100644 frontend/js/main.js create mode 100644 frontend/js/script.js delete mode 100644 frontend/script.js diff --git a/README.md b/README.md index 42b3be8..4d225d1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,2 @@ -Repozytorium projektu z sztucznej inteligencji, temat "Inteligentny wózek widłowy".
-Zespół: 444420, 444428, 444430 +Repozytorium projektu z sztucznej inteligencji, temat "Inteligentny wózek widłowy". diff --git a/frontend/img/Down.png b/frontend/img/Down.png new file mode 100644 index 0000000000000000000000000000000000000000..44308b3203e7047aa24bb6dad14c66dae4684f68 GIT binary patch literal 560 zcmV-00?+-4P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D03mcmSad^jWnpw_ zZ*Cw|X>DZyGB7eQIxsXkGB+SGI65^oIx;h~Qs5{600EduL_t(&L+zNm62l-21nvC) zKRcQsg(n!$;{?)}ZITLZ(Lv$!x~{{A^E`k5+IZ}aSK^q|0As+EbS5?SJOCw>%pFTA zlahzb9bLB1?^lku524#aGo=YKe~3bgr!?P(5N#?`TH;gSZ!J(-=u=<@;3_TmDR5%2 zl!EvahGE3dLwv?cp+;2bM;a&v^eJ?Ly{vd)M^tFVd*$N9x0QPRpm)h~UM8hE^^;Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D03mcmSad^jWnpw_ zZ*Cw|X>DZyGB7eQIxsXkGB+SGI65^oIx;h~Qs5{600Ey#L_t(&L+#nyZp0uAMbTvb z|DQ8wM8qKO7X!A%ercbAS3N~hdq2-}>FV=-Rn#F#=#V6&khI|vzwi6~F4p)w>qvP? zSodJlNv)Ew)(Iz)#xZX7bI!URXg#R@f%ID<$9NS7Cf?F)4=Nr(Nm}4B?LoQ+{YeTiruT!V#`CN7we@s5 z#nbn@^tO>Nfou(3mukUG+JeE}IAz%qEH%JKjJ002ovPDHLk FV1l3I_lf`j literal 0 HcmV?d00001 diff --git a/frontend/img/Right.png b/frontend/img/Right.png new file mode 100644 index 0000000000000000000000000000000000000000..edce10b0b49b34dd5b8c4c142fc4eb64fbc60fb0 GIT binary patch literal 574 zcmV-E0>S->P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D03mcmSad^jWnpw_ zZ*Cw|X>DZyGB7eQIxsXkGB+SGI65^oIx;h~Qs5{600E{+L_t(&L+zT~4#F@9MmOL8 zohOE+YS$my0)?jMMlXzT`Y~M0&g;64wRqjH3$c|vu%HspdN|MXe)rFm-P5m>)5xKw z*R0fP@B@T02doCgVkMSy8fT=9KP4kRNOv>l2Je?XtMA=|sfZ$)?l4TJ z6lgl`Tgh@n2)#oeDIr8FPf7sA>a!l~Pu-Kk!f=*Spb&#sB_Lu?72J^M=u zWXc&hQ!2|Kw-V)}(;+tLCMEizf0Zl;)zq7Vlv>X^e(u54-;{lW6Q^Wn{JJ|aI(Q=| zn||PC*7&i^NIIn{m6H zrW6>DOHKx9RtmJbNt*=vl>%iqHIo2?k~OI7!4X@@16#=h%PAel8{o6UAG1IE9{>OV M07*qoM6N<$f^N|B?EnA( literal 0 HcmV?d00001 diff --git a/frontend/img/Up.png b/frontend/img/Up.png new file mode 100644 index 0000000000000000000000000000000000000000..c71a34835986d85135aef485eb5e19d74948d845 GIT binary patch literal 509 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0g_2XK~!i%?a;xt z!ypJn(f1CdmrxtghbPNgxB8ubLlI?j4S6*nrblV$1{_=iwJM)aECM^Qy!{FKN9C^Ry7M_3xvy0q9y#3VzxzU~VG zQletVGAA*b7)4w5Noi2DrSXlS^r(BXPs)V4Coev!pmFX0SKht^rEB}7WGG$RCnZDa z+CC{6O4k-Rso?n=(75*Elc;;LPs)V4C+!amB}UPfeNq|}ZRvhvG$kr_taMUAKr)o; z8(o|XwJxo9QbAY(6dIA;od8t?#HT-s5;B_WAHsSuj1+=69##!1$OVU5Y$ zZ~&qwctkiMZkk(AK{X|Y{rD#ql)c1LcgOJs=AQXjhEVlz00000NkvXXu0mjfHhSH9 literal 0 HcmV?d00001 diff --git a/frontend/index.html b/frontend/index.html index e51cf90..f65b762 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,108 +2,18 @@ + Inteligentny wózek - + - +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
+
+ \ No newline at end of file diff --git a/frontend/js/Agent.js b/frontend/js/Agent.js new file mode 100644 index 0000000..1a51fc2 --- /dev/null +++ b/frontend/js/Agent.js @@ -0,0 +1,87 @@ +export default class Agent{ + constructor(positionX, positionY, turn){ + this.positionX = positionX; + this.positionY = positionY; + this.turn = turn; + } + + getParams(){ + let params = {}; + + positionX = this.positionX; + positionY = this.positionY; + turn = this.turn; + + params = {positionX, positionY, turn}; + + return params; + } + + goForward(){ + if(this.turn == 'Up'){ + this.positionY += 1; + } + else if(this.turn == 'Down'){ + this.positionY -= 1; + } + else if(this.turn == 'Left'){ + this.positionX -= 1; + } + else if(this.turn == 'Right'){ + this.positionX += 1; + } + } + + turnLeft(){ + if(this.turn == 'Up'){ + this.turn = 'Left'; + } + else if(this.turn == 'Down'){ + this.turn = 'Right'; + } + else if(this.turn == 'Left'){ + this.turn = 'Down'; + } + else if(this.turn == 'Right'){ + this.turn = 'Up' + } + } + + turnRight(){ + if(this.turn == 'Up'){ + this.turn = 'Right'; + } + else if(this.turn == 'Down'){ + this.turn = 'Left'; + } + else if(this.turn == 'Left'){ + this.turn = 'Up'; + } + else if(this.turn == 'Right'){ + this.turn = 'Down' + } + } + + showAgent(){ + console.log(this.turn) + if(this.turn === "Up"){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Up.png')"; + } + else if(this.turn === "Down"){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Down.png')"; + } + else if(this.turn === "Right"){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Right.png')"; + } + else if(this.turn === "Left"){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Left.png')"; + } + + } + + hideAgent(){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = ""; + } + + +} \ No newline at end of file diff --git a/frontend/js/Board.js b/frontend/js/Board.js new file mode 100644 index 0000000..178bfb1 --- /dev/null +++ b/frontend/js/Board.js @@ -0,0 +1,30 @@ +import Field from './Field.js' + +export function createBoard(rangeX, rangeY){ + const board = []; + + for(let y = 0; y < rangeY; y++){ + const row = []; + for(let x = 0; x < rangeX; x++){ + let field = new Field(x, y, false, false, 1); + row.push(field) + } + board.push(row) + } + return board +} + +export function showBoard(board){ + for(let y = board.length - 1; y >= 0 ; y--){ + document.getElementById("board").innerHTML += "
"; + + for(let x = 0; x < board[y].length; x++){ + document.getElementById("row-" + y).innerHTML += "
" + } + } +} + + + + + diff --git a/frontend/js/Field.js b/frontend/js/Field.js new file mode 100644 index 0000000..7e2b03b --- /dev/null +++ b/frontend/js/Field.js @@ -0,0 +1,22 @@ +export default class Field{ + constructor(x, y, isShelf, isOccupiedByAgent, costOfTravel){ + this.xField = x; + this.yField = y; + this.isShelf = isShelf; + this.isOccupiedByAgent = isOccupiedByAgent; + this.costOfTravel = costOfTravel; + } + + getParams(){ + let params = {}; + + xField = this.xField; + yField = this.yField; + isShelf = this.isShelf; + isOccupiedByAgent = this.isOccupiedByAgent; + costOfTravel = this.costOfTravel; + params = {xField, yField, isShelf, isOccupiedByAgent, costOfTravel} + + return params; + } +} \ No newline at end of file diff --git a/frontend/js/main.js b/frontend/js/main.js new file mode 100644 index 0000000..735d905 --- /dev/null +++ b/frontend/js/main.js @@ -0,0 +1,27 @@ +import * as Board from './Board.js' +import Agent from './Agent.js' + +let board = Board.createBoard(10,10); +Board.showBoard(board); + +let agent = new Agent(0,0, 'Right'); + +agent.showAgent(); + + + + + + + + + + + + + + + + + + diff --git a/frontend/js/script.js b/frontend/js/script.js new file mode 100644 index 0000000..44ad711 --- /dev/null +++ b/frontend/js/script.js @@ -0,0 +1,125 @@ +// import Agent from './Agent.js' + +// //Klasy + + +// class Field { +// constructor(x, y, isEmpty) { +// this.xField = x; +// this.yField = y; +// this.isFieldEmpty = isEmpty; +// } +// getCoordinates(){ +// return this.xField + this.yField; +// } + +// getStatus(){ +// return this.isFieldEmpty; +// } +// } + +// class Product { +// constructor(name, type, farcing, price) { +// this.name = name; +// this.type = type; +// this.farcing = farcing; +// this.price = price +// } +// } + +// class Rack{ +// constructor(noOfShelf, typOfProduct) { +// this.noOfShelf = noOfShelf; +// } + +// addShelf(){ +// this.noOfShelf = this.noOfShelf + 1; +// } + +// isEmpty(){ +// if (this.noOfShelf === 0){ +// return true; +// }else { +// return false; +// } +// } +// } + +// class Shelf { +// constructor(number) { +// this.number = number; +// } +// } + + +// //Objekty i zmienne +// var regaly = ['1-1', '1-3', '1-4', '1-6', '1-7', '1-9', '2-1', '2-9', '3-3', '3-4', '3-6', '3-7', '4-1', '4-9', '5-1', '5-3', '5-4', '5-6', '5-7', '5-9'] +// const agent1 = new Agent(3, 0); + +// //Funkcja uruchamiająca prace calego scriptu +// function start(){ +// //ponumerujPola(); +// pokolorujRegaly(); +// umiescAgenta(agent1); +// droga(agent1); +// } + +// //Funkcja kolorujaca miejsca na planszy gdzie znajduja sie regaly +// function pokolorujRegaly(){ +// let x; +// for(x = 0; x < regaly.length; x++){ +// document.getElementById(regaly[x]).className = 'regal'; +// } +// } + +// //Funkcja wyswietlajaca id pol +// function ponumerujPola(){ +// let x,y +// for(x = 0; x < 7; x++){ +// for(y = 0; y < 11; y++){ +// id = x.toString() + "-" + y.toString(); +// document.getElementById(id).innerHTML = id; +// } +// } +// } + +// //Funkcja usuwająca agenta z pola, przed przemieszczeniem +// function usunAgenta(agent){ +// document.getElementById(agent.getId()).style.backgroundImage = "none"; +// } + + +// //Funckja wyswietlajaca agenta gdy ten zmieni polozenie +// function umiescAgenta(agent) { +// document.getElementById(agent.getId()).style.backgroundImage = "url('Agent.jpg')"; +// } + +// //Funkcja zmieniajaca polozenie agenta o 1 pole +// function przemieszczenie(side, time, agent){ +// const lastPosition = agent.getId(); +// setTimeout(function(){ +// usunAgenta(agent) +// if(side == "left") +// agent.left(); +// if(side == "right") +// agent.right(); +// if(side == "up") +// agent.up(); +// if(side == "down") +// agent.down(); +// umiescAgenta(agent); +// }, time); +// } + +// //Funkcja ktora ustala droge agenta do przebycia +// function droga(agent) { +// przemieszczenie("right", 1000, agent); +// przemieszczenie("right", 2000, agent); +// przemieszczenie("up", 3000, agent); +// przemieszczenie("right", 4000, agent); +// przemieszczenie("right", 5000, agent); +// przemieszczenie("right", 6000, agent); +// przemieszczenie("right", 7000, agent); +// przemieszczenie("right", 8000, agent); +// przemieszczenie("right", 9000, agent); +// } diff --git a/frontend/script.js b/frontend/script.js deleted file mode 100644 index b3921a1..0000000 --- a/frontend/script.js +++ /dev/null @@ -1,150 +0,0 @@ -//Klasy -class Agent { - constructor(x, y){ - this.xField = x; - this.yField = y; - } - - getId(){ - return this.xField + "-" + this.yField; - } - - right(){ - this.yField++; - } - - left(){ - this.yField--; - } - - up(){ - this.xField--; - } - - down(){ - this.xField++; - } -} - -class Field { - constructor(x, y, isEmpty) { - this.xField = x; - this.yField = y; - this.isFieldEmpty = isEmpty; - } - getCoordinates(){ - return this.xField + this.yField; - } - - getStatus(){ - return this.isFieldEmpty; - } -} - -class Product { - constructor(name, type, specs, price) { - this.name = name; - this.type = type; - this.specs = specs; - this.price = price - } -} - - -class Rack{ - constructor(noOfShelf) { - this.noOfShelf = noOfShelf; - } - - addShelf(){ - this.noOfShelf = this.noOfShelf + 1; - } - - isEmpty(){ - if (this.noOfShelf === 0){ - return true; - }else { - return false; - } - } -} - -class Shelf { - constructor(number, typeOfProduct) { - this.number = number; - this.typeOfProduct = typeOfProduct; - } -} - - -//Objekty i zmienne -var regaly = ['1-1', '1-3', '1-4', '1-6', '1-7', '1-9', '2-1', '2-9', '3-3', '3-4', '3-6', '3-7', '4-1', '4-9', '5-1', '5-3', '5-4', '5-6', '5-7', '5-9'] -const agent1 = new Agent(3, 0); - -//Funkcja uruchamiająca prace calego scriptu -function start(){ - //ponumerujPola(); - pokolorujRegaly(); - umiescAgenta(agent1); - droga(agent1); -} - -//Funkcja kolorujaca miejsca na planszy gdzie znajduja sie regaly -function pokolorujRegaly(){ - let x; - for(x = 0; x < regaly.length; x++){ - document.getElementById(regaly[x]).className = 'regal'; - } -} - -//Funkcja wyswietlajaca id pol -function ponumerujPola(){ - let x,y - for(x = 0; x < 7; x++){ - for(y = 0; y < 11; y++){ - id = x.toString() + "-" + y.toString(); - document.getElementById(id).innerHTML = id; - } - } -} - -//Funkcja usuwająca agenta z pola, przed przemieszczeniem -function usunAgenta(agent){ - document.getElementById(agent.getId()).style.backgroundImage = "none"; -} - - -//Funckja wyswietlajaca agenta gdy ten zmieni polozenie -function umiescAgenta(agent) { - document.getElementById(agent.getId()).style.backgroundImage = "url('Agent.jpg')"; -} - -//Funkcja zmieniajaca polozenie agenta o 1 pole -function przemieszczenie(side, time, agent){ - const lastPosition = agent.getId(); - setTimeout(function(){ - usunAgenta(agent) - if(side == "left") - agent.left(); - if(side == "right") - agent.right(); - if(side == "up") - agent.up(); - if(side == "down") - agent.down(); - umiescAgenta(agent); - }, time); -} - -//Funkcja ktora ustala droge agenta do przebycia -function droga(agent) { - przemieszczenie("right", 1000, agent); - przemieszczenie("right", 2000, agent); - przemieszczenie("up", 3000, agent); - przemieszczenie("right", 4000, agent); - przemieszczenie("right", 5000, agent); - przemieszczenie("right", 6000, agent); - przemieszczenie("right", 7000, agent); - przemieszczenie("right", 8000, agent); - przemieszczenie("right", 9000, agent); -} diff --git a/frontend/styles.css b/frontend/styles.css index 877c58c..0fbed01 100644 --- a/frontend/styles.css +++ b/frontend/styles.css @@ -1,33 +1,39 @@ +body { + padding: 0; + margin: 0; +} + .container{ width: 100%; height: 100%; + min-width: 1920px; + min-height: 1080px; position: absolute; - background-color: grey; + background-color: rgb(37, 36, 36); } -.plansza{ - width: 1100px; - height:700px; +#board{ + width: 700px; + height: 700px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); - background-color: lightyellow; - + background-color: white; } .row{ - width: 1100px; - height: 100px; + width: 100%; + height: 70px; display: flex; flex-direction: row; } -.pole{ - height: 100px; - width: 100px; - background-color: lightyellow; +.field{ + height: 70px; + width: 70px; + background-color: white; background-image: none; background-size: cover; border-color: black; @@ -43,8 +49,8 @@ } .regal{ - height: 100px; - width: 100px; + height: 50px; + width: 50px; color: lightyellow; background-color: darkslategrey; border-color: black; @@ -57,3 +63,4 @@ justify-content: center; align-items: center; } + From 56e96947c1a3cfd1fdf460bb331a8b4f1398e9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kuczy=C5=84ski?= Date: Mon, 27 Apr 2020 18:52:44 +0000 Subject: [PATCH 6/7] Zaktualizuj 'README.md' --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d225d1..bc67ef5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -Repozytorium projektu z sztucznej inteligencji, temat "Inteligentny wózek widłowy". +Repozytorium projektu z sztucznej inteligencji, temat "Inteligentny wózek widłowy".
+Zespół: 444420, 444428, 444430 \ No newline at end of file From 701ca39a18b41c13456c0b7c2b9df6d8abb3f556 Mon Sep 17 00:00:00 2001 From: Tomek Date: Mon, 27 Apr 2020 21:44:32 +0200 Subject: [PATCH 7/7] =?UTF-8?q?Scalenie=20plik=C3=B3w=20js=20i=20dostosowa?= =?UTF-8?q?nie=20pliku=20index.html=20do=20wprowadzonych=20zmian?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/index.html | 3 +- frontend/js/{ => Archiwum}/Agent.js | 0 frontend/js/{ => Archiwum}/Board.js | 0 frontend/js/{ => Archiwum}/Field.js | 0 frontend/js/{ => Archiwum}/script.js | 0 frontend/js/main.js | 163 +++++++++++++++++++++++---- 6 files changed, 142 insertions(+), 24 deletions(-) rename frontend/js/{ => Archiwum}/Agent.js (100%) rename frontend/js/{ => Archiwum}/Board.js (100%) rename frontend/js/{ => Archiwum}/Field.js (100%) rename frontend/js/{ => Archiwum}/script.js (100%) diff --git a/frontend/index.html b/frontend/index.html index f65b762..88e9da8 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -8,12 +8,11 @@ - +
- \ No newline at end of file diff --git a/frontend/js/Agent.js b/frontend/js/Archiwum/Agent.js similarity index 100% rename from frontend/js/Agent.js rename to frontend/js/Archiwum/Agent.js diff --git a/frontend/js/Board.js b/frontend/js/Archiwum/Board.js similarity index 100% rename from frontend/js/Board.js rename to frontend/js/Archiwum/Board.js diff --git a/frontend/js/Field.js b/frontend/js/Archiwum/Field.js similarity index 100% rename from frontend/js/Field.js rename to frontend/js/Archiwum/Field.js diff --git a/frontend/js/script.js b/frontend/js/Archiwum/script.js similarity index 100% rename from frontend/js/script.js rename to frontend/js/Archiwum/script.js diff --git a/frontend/js/main.js b/frontend/js/main.js index 735d905..4aae68b 100644 --- a/frontend/js/main.js +++ b/frontend/js/main.js @@ -1,27 +1,146 @@ -import * as Board from './Board.js' -import Agent from './Agent.js' +//Klasy +class Agent{ + constructor(positionX, positionY, turn){ + this.positionX = positionX; + this.positionY = positionY; + this.turn = turn; + } -let board = Board.createBoard(10,10); -Board.showBoard(board); + getParams(){ + let params = {}; + positionX = this.positionX; + positionY = this.positionY; + turn = this.turn; + + params = {positionX, positionY, turn}; + + return params; + } + + goForward(){ + if(this.turn == 'Up'){ + this.positionY += 1; + } + else if(this.turn == 'Down'){ + this.positionY -= 1; + } + else if(this.turn == 'Left'){ + this.positionX -= 1; + } + else if(this.turn == 'Right'){ + this.positionX += 1; + } + } + + turnLeft(){ + if(this.turn == 'Up'){ + this.turn = 'Left'; + } + else if(this.turn == 'Down'){ + this.turn = 'Right'; + } + else if(this.turn == 'Left'){ + this.turn = 'Down'; + } + else if(this.turn == 'Right'){ + this.turn = 'Up' + } + } + + turnRight(){ + if(this.turn == 'Up'){ + this.turn = 'Right'; + } + else if(this.turn == 'Down'){ + this.turn = 'Left'; + } + else if(this.turn == 'Left'){ + this.turn = 'Up'; + } + else if(this.turn == 'Right'){ + this.turn = 'Down' + } + } + + showAgent(){ + console.log(this.turn) + if(this.turn === "Up"){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Up.png')"; + } + else if(this.turn === "Down"){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Down.png')"; + } + else if(this.turn === "Right"){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Right.png')"; + } + else if(this.turn === "Left"){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Left.png')"; + } + + } + + hideAgent(){ + document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = ""; + } + + +} + +class Field{ + constructor(x, y, isShelf, isOccupiedByAgent, costOfTravel){ + this.xField = x; + this.yField = y; + this.isShelf = isShelf; + this.isOccupiedByAgent = isOccupiedByAgent; + this.costOfTravel = costOfTravel; + } + + getParams(){ + let params = {}; + + xField = this.xField; + yField = this.yField; + isShelf = this.isShelf; + isOccupiedByAgent = this.isOccupiedByAgent; + costOfTravel = this.costOfTravel; + params = {xField, yField, isShelf, isOccupiedByAgent, costOfTravel} + + return params; + } +} + +//funckcje + +function createBoard(rangeX, rangeY){ + const board = []; + + for(let y = 0; y < rangeY; y++){ + const row = []; + for(let x = 0; x < rangeX; x++){ + let field = new Field(x, y, false, false, 1); + row.push(field) + } + board.push(row) + } + return board +} + +function showBoard(board){ + for(let y = board.length - 1; y >= 0 ; y--){ + document.getElementById("board").innerHTML += "
"; + + for(let x = 0; x < board[y].length; x++){ + document.getElementById("row-" + y).innerHTML += "
" + } + } +} + +let board = createBoard(10,10); let agent = new Agent(0,0, 'Right'); - -agent.showAgent(); - - - - - - - - - - - - - - - - +function start(){ + showBoard(board); + agent.showAgent(); +}