(Almost) Infinite Elevator jest będącą w trakcie przygotowania aplikacją-zabawką internetową dla wielu graczy symulującą pracę 16 wind w wieżowcu wysokim na 65 535 pięter (nie licząc parteru).
Aplikacja stanowi zarazem demonstrację jednego z możliwych algorytmów pozwalających na (w miarę) wydajne przemieszczanie się wind w budynku.
W miastowcu I (czyt. $i$) - pierwszym z najnowszej generacji wieżowców-miast, liczącym sobie 65 535 pięter oraz parter (piętro 0) znajduje się rząd szesnastu Bardzo Pojemnych™ wind przywoływalnych na każdym piętrze za pomocą wspólnego dla nich panelu.
Wspólny panel posiada dwa pojemnościowo-dotykowe, wykrywające bezbłędnie palce przyciski: pierwszy, zajmujący cały sufit, wyraża chęć jazdy w górę, drugi, tak szeroki jak podłoga - w dół. Z oczywistymi wyjątkami:
Każda winda posiada pole do wprowadzania piętra, na które chce się udać jej użytkownik. Pole jest wykonane w technologii hologramu indywidualnego - wyświetla się z osobna dla każdej osoby, która wejdzie do windy. Osoba ta wpisuje w pole numer piętra, na które chce się udać, i zatwierdza klawiszem Enter. Na każdym przystanku ma też możliwość wyjścia z windy - wówczas winda automatycznie usuwa dokonany przez nią wybór piętra.
Windy wykorzystują wspólny dla nich, zbudowany redundantnie potężny silnik krokowy (jeden krok - 64 piętra), do którego każda posiada podłączoną własną wysoce złożoną przekładnię. Dzięki takiemu rozwiązaniu windy poruszają się z prędkością 64 pięter na sekundę, osiągalną w pomijalnie krótkim czasie. Chociaż jednak winda może przerwać ruch w każdej chwili, a więc zatrzymać się na dowolnym piętrze, to opisana budowa oznacza, że rozpocząć ruch może ona tylko raz na sekundę (krok), w momencie zsynchronizowania silnika i przekładni.
Bo bez wspaniałego algorytmu to bym chyba wybrał schody. Szczerze mówiąc, nawet z algorytmem mieszkańcy często narzekają! Ale wystarczy im przypomnieć komunikację miejską… W każdym razie:
Liczby pięter oraz wind są zakodowane na stałe, a skoro wszystkie równania są oczywiste, to mogłyby być dynamiczne. Ale wtedy w istocie algorytm miałby pewne przypadki szczególne, a jako że przecież windy i tak są bardzo drogie, to żaden problem ręcznie poprawić kod, gdy parametry się zmienią!
Oczywistym uproszczeniem niezmiernie usprawniającym działanie wind byłaby możliwość podania piętra, na które chce się udać użytkownik, już na etapie przywołania windy. Jak się jednak okazało:
Instalacja hologramu indywidualnego na każdym piętrze, zamiast jeżdżącego wraz z windami, byłaby zaporowo droga - w istocie, cena tego kosmicznej precyzji systemu jest tak wysoka, że tylko z tej przyczyny w wieżowcu znajduje się 16 wind, a nie 128, jak pierwotnie planowano,
Tradycyjny klawiszowy system wprowadzania obsługiwany przez najbliżej znajdującą się osobę, mimo wysokiej kooperacji użytkowników tego systemu, okazał się nieefektywny ze względu na wytwarzany w okolicach wind głośny hałas,
Z zamawiania windy za pomocą telefonu zrezygnowano ze względu na pewnych dwojga nienamierzalnych żartownisiów, którzy mimo wszystkich zabezpieczeń potrafili zdalnie zamawiać windę na wszystkie piętra. A jeżdżą pewnie schodami.
Dlatego wszystko zostało tak, jak jest. A system łatwo aplikuje się do zwyczajnych, XXI-wiecznych wind. Gdyby nie ta identyfikacja osób w środku - ale wystarczająco dobrym przybliżeniem byłoby umożliwić po prostu odznaczanie pięter…
Na aplikację składają się:
(Niestety nadal głębokie WIP) Strona internetowa wykonana w HTML/CSS/JavaScript - implementuje interaktywny interfejs użytkownika po stronie klienta, uruchomienie jej wymaga wyłącznie pobrania repozytorium i otwarcia pliku index.html w przeglądarce internetowej.
Serwer Node.JS/Socket.IO - centralnie kontroluje stan wind. Możemy go włączyć poprzez wywołanie następujących komend w systemie z prawidłowo skonfigurowanym oprogramowaniem Git oraz Node.JS i NPM, w katalogu, do którego mamy dostęp:
git clone --depth 1 https://github.com/infinite-elevator/infinite-elevator.github.io.git
cd infinite-elevator.github.io/server
npm install
node index.js
W celu permanentnego hostowania, albo jeżeli powyższe komendy nie działają, można wykorzystać Docker. Możemy w nim uruchomić serwer poprzez wywołanie następujących komend w systemie z prawidłowo skonfigurowanym oprogramowaniem Git oraz Docker wraz z buildx i niezablokowanym portem 37133, w katalogu, do którego mamy dostęp:
git clone --depth 1 https://github.com/infinite-elevator/infinite-elevator.github.io.git
cd infinite-elevator.github.io/server
docker buildx build -t infinite-elevator . || sudo docker buildx build -t infinite-elevator .
docker run -tidp 37133:37133 --restart=on-failure --name infinite-elevator infinite-elevator || sudo docker run -tidp 37133:37133 --restart=on-failure --name infinite-elevator infinite-elevator
Jeżeli chcemy uruchomić serwer na konkretnym adresie IP, np. gdyż nasze urządzenie ma wiele publicznych adresów IP, możemy zmienić 37133:37133 na adres_ip:37133:37133, w rezultacie uzyskując np. 141.147.52.46:37133:37133.
Powyższe komendy zostały przetestowane na systemach linuksowych, ale powinny działać też w systemie macOS, a nawet w wierszu poleceń systemu Windows.
Następnie należy zmodyfikować plik index.html, zamieniając 141.147.52.46 na adres IP nowo postawionego serwera.
W celu podłączenia się do panelu kontrolnego serwera, można wykonać komendę:
docker attach infinite-elevator || sudo docker attach infinite-elevator
Powinieneś wówczas ujrzeć podobny widok:
(Almost) Infinite Elevator Server Control Panel
1. Check elevator and player status
2. Call elevator
3. Teleport elevator
4. Toggle stepping: <every second> / manually
5. Step now
6. Close server
Choose an option by entering a number and pressing Enter:
(Może być trzeba wcisnąć Enter, aby odświeżyć panel; aby się rozłączyć, wciśnij Ctrl+P+Q.)
W celu odczytania logów serwera, można wykonać komendę:
docker logs infinite-elevator || sudo docker logs infinite-elevator
W celu zatrzymania serwera, można wykonać komendę:
docker stop infinite-elevator || sudo docker stop infinite-elevator
Aby wystartować go znowu, można wykonać komendę:
docker start infinite-elevator || sudo docker start infinite-elevator
W celu skasowania serwera, można wykonać komendę:
docker rm infinite-elevator || sudo docker rm infinite-elevator
MIT. Poza zawartościami katalogu ext - są one rządzone swoimi własnymi licencjami.
(Almost) Infinite Elevator is a work-in-progress multiplayer toy web application that simulates the operation of 16 elevators in a skyscraper 65,535 floors high (plus the ground floor).
The application simultaneously serves as a demonstration of one of the possible algorithms that allow for the (somewhat) efficient movement of elevators in a building.
In the cityscraper I (pronounced $e$) - the first in the latest generation of skyscraper cities, featuring 65,535 floors plus a ground floor (floor 0), there is a row of sixteen Very Capacious™ elevators that may be called onto each floor using a shared panel.
The shared panel has two impeccably finger-sensing touch-capacitive buttons: the first one, filling the whole ceiling, expresses the desire to go up, the second, as wide as the floor - down. With obvious exceptions:
Each elevator has a number input field for entering the floor to which its user wants to go. The field is made with the use of the individual hologram technology - it is displayed individually for each person who enters the elevator. The person enters into the field the number of the floor to which they want to go, and confirms with the Enter key. At each stop, they also have an option of leaving the elevator - then the elevator automatically cancels their floor selection.
The elevators use a common, redundantly built mighty stepper motor (one step - 64 floors), to which each elevator has a highly complex gearshift of its own connected. Thanks to this solution, the elevators move at a speed of 64 floors per second, achievable in a negligible time. However, although an elevator may stop moving at any time, i.e. stop at any floor, the described construction means that it can start moving only once per second (step), when the engine and the gearshift are synchronized.
Because without a great algorithm I would probably have chosen the stairs. Honestly, even with the algorithm residents often complain! But all we have to do is remind them how public transport was… Anyway:
This person has already selected a floor - the previously selected floor is deleted and the other conditions are checked,
There are no floors on the list - the floor is added to the list,
The floor is between the elevator and the first floor on the list - it is added to the beginning of the list,
The floor is between two floors on the list - it is added between them,
The floor is closer to the floor at the end of the list than the one at the beginning - it is added to the end of the list,
The floor is located, although this extends the route, closer to the floor at the beginning of the list than at the end, and there exist two floors on the list that are further apart than the first of these two floors and the selected floor - the selected floor is added between the first two such floors found,
If the above conditions are not met - the floor is added to the end of the list.
It has been noted that there is a chance of a situation happening wherein people, forming a group that calls elevators in both directions, will board the wrong one when both elevators arrive at the same time. However, the designers thought that this was too rare a problem to pay attention to. (To date, 11,738 lawsuits have been recorded.)
The numbers of floors and elevators are hardcoded, while, given that all the equations are obvious, they could perhaps be made dynamic. But then there would actually be some edge cases in the algorithm, and as elevators are very expensive anyways, it’s no problem to manually correct the code when the parameters change!
An obvious simplification that would greatly improve the operation of the elevators would be the possibility to specify the floor that the user wants to reach, already at the time of calling the elevator. However, as it turns out:
Installing an individual hologram on each floor, instead of one that travels with the elevators, would be prohibitively expensive - in fact, the price of this system of space-grade precision is so high that for this reason alone there are 16 elevators in the skyscraper, not 128, as originally planned,
A traditional keypad entry system operated by the nearest person, despite high levels of collaboration by the users, turned out to be ineffective due to the loud noise generated in the vicinity of the elevators,
Ordering an elevator by phone was abandoned due to a couple of untraceable pranksters who, despite all the security measures, were able to remotely order an elevator to all the floors. And they probably take the stairs.
That’s why everything stays the way it is. And the system is easily applied to ordinary, 21st-century elevators. If it weren’t for the identification of people inside - but a close enough approximation is simply to allow floors to be unchecked…
The application consists of:
(Sadly still deeply WIP) A website made in HTML/CSS/JavaScript - implements an interactive user interface on the client side, to start it you only have to download the repository and open the file index.html in a web browser.
A Node.JS/Socket.IO server - centrally controls the state of the elevators. You may run it with the following commands on a system with correctly configured Git, Node.JS and NPM, in a directory that you have write access to:
git clone --depth 1 https://github.com/infinite-elevator/infinite-elevator.github.io.git
cd infinite-elevator.github.io/server
npm install
node index.js
If you want to deploy it permanently, or if the above commands are not working, Docker may be used. You may host the server by calling the following commands on a system with correctly configured Git and Docker with buildx, and an unlocked port 37133, in a directory that you have write access to:
git clone --depth 1 https://github.com/infinite-elevator/infinite-elevator.github.io.git
cd infinite-elevator.github.io/server
docker buildx build -t infinite-elevator . || sudo docker buildx build -t infinite-elevator .
docker run -tidp 37133:37133 --restart=on-failure --name infinite-elevator infinite-elevator || sudo docker run -tidp 37133:37133 --restart=on-failure --name infinite-elevator infinite-elevator
If you want to run the server on a specific IP address, e.g. because your device has multiple public IP addresses, you may change 37133:37133 to adres_ip:37133:37133, resulting in e.g. 141.147.52.46:37133:37133.
The above commands were tested on Linux systems, but should work on macOS too, and even on the Windows command line.
Then, you need to modify the index.html file, replacing 141.147.52.46 with the IP address of the newly setup server.
To attach to the server control panel, you may run the command:
docker attach infinite-elevator || sudo docker attach infinite-elevator
You should then see something like this:
(Almost) Infinite Elevator Server Control Panel
1. Check elevator and player status
2. Call elevator
3. Teleport elevator
4. Toggle stepping: <every second> / manually
5. Step now
6. Close server
Choose an option by entering a number and pressing Enter:
(You may have to press Enter to refresh the panel; to detach, press Ctrl+P+Q.)
To read the server logs, you may run the command:
docker logs infinite-elevator || sudo docker logs infinite-elevator
To stop the server, you may run the command:
docker stop infinite-elevator || sudo docker stop infinite-elevator
To start it back again, you may run the command:
docker start infinite-elevator || sudo docker start infinite-elevator
To remove the server container, you may run the command:
docker rm infinite-elevator || sudo docker rm infinite-elevator
MIT. Except the contents of the ext directory - they are governed by their respective licenses.