How can I 'hook up' my own Algorithm/AI with the server to remotely control a custom game?


There are 2 ways in which you can visualize your work and access the API.

For both of them to work, you must of course use the functions/requests provided by the API accordingly.


1. Let your program play via the server that provides the API

If you want to hook up your project with the server providing the API, you will need to send the requests to the originated server. The current URLs the servers are:

https://teris-api.vercel.app
or
https://teris-api.herokuapp.com (While this one probably has got a lot less latency)

Further important is the usage of a unique (custom) gameID. It is recommended following the logics of the provided template, which assigns each started game of yours to an unique ID.

As soon as you are able to get an insight in your gameID, you will be able to observe the requests visually, that are send to the server. For that, you will need to append the gameID to the originated server in your browser manually as following:

https://teris-api.herokuapp.com/game?gameID=id

If you have fetched an ID from the server via the parameter gameID, you can i.e. print your ID to further manual usage.

This method is usually accompanied by a very high latency if the server is accessed by several clients at the same time. Accordingly, it is not suitable for training an AI.


2. Host your own server to reduce latency

In order to create your own instance of the server you'll need to have Docker installed on your local machine. As soon as that is the case, you may pull the latest image of the server via the following command:

sudo docker pull clk1006/tetris:latest

Then you can start the server with

sudo docker run -p [PORT]:3000 clk1006/tetris:lastest

where [PORT] is the port on which you want your server to listen.

Sorry, there is nothing to see here :/

Please use a device with a bigger display. This application is not designed for small medias.