"Amazon Cloud Technology Product Review" event call for papers|Build a backgammon game based on Lightsail

"Amazon Cloud Technology Product Review" event call for papers|Build a backgammon game based on Lightsail

Authorization statement: This article authorizes the official Amazon Cloud Technology article to forward and rewrite the rights, including but not limited to Amazon Cloud Technology official channels such as Developer Centre, Zhihu, self-media platforms, third-party developer media, etc.

background

When I was wandering around recently, I saw that new Amazon users can use one year of EC2 for free and three months ofLightsail, this wave of benefits must not be missed, so I registered an Amazon account.

Then what interesting things can we do with this server? I suddenly wanted to play backgammon before.
I am going to deploy a backgammon game on the server

Buy a server

After logging in to AWS, search for "Lightsail" in the search bar, and click to enter the Lightsail console

Insert image description here
After entering the Lightsail console, click Create Instance. If an instance has been created before, it will also be displayed in the list.

Insert image description here
The instance configuration I plan to purchase:
Instance region: Seoul, Zone A
Operating system: Linux/Unix + Amazon Linux 2023
Instance plan: 1GB 2vCPUs

You can buy it according to my configuration, or you can modify it according to actual needs.
Insert image description here

You can see that there are three plans that can be used for free for three months. We choose one of the appropriate plans. The plan configuration I chose here is $5 per month.

Insert image description here
After clicking Create Instance, wait for a while and we will see the instance we just created in the console.
Insert image description here
We can use the tools provided by the web page to connect to the server. You can also use SSH tools to connect via secret key.
Insert image description here
Insert image description here

deploy

I am going to use the project on github here. The author also provides tutorials. If you are interested in the algorithm, you can follow the tutorials. Research. Now we are just deploying it on the server and not studying the code in detail

Tutorial content:
Gomoku AI Design Tutorial Second Edition 1: Preface
Gobang AI Design Tutorial 2nd Edition 2: The Past and Present of Game Algorithms
Gobang AI Design Tutorial Second Edition 3: Minimization and Maximum Search
Gobang AI Design Tutorial 2nd Edition 4: Alpha Beta Pruning Algorithm a> Backgammon AI Design Tutorial Second Edition 9: Performance Optimization Backgammon AI Design Tutorial Second Edition 8: Kill Count Gobang AI Design Tutorial Second Edition 7: Zobrist Cache Gobang AI Design Tutorial Second Edition Six: Iterative Deepening
Gobang AI Design Tutorial Second Edition Five: Heuristic Evaluation Function



Install docker

We directly use the system package manager to install docker

sudo yum install -y docker

Insert image description here
Check whether docker installation is complete
Insert image description here
You can see that docker installation is complete, let’s start docker

sudo systemctl start docker   #启动
sudo systemctl enable docker  #开机自启

Insert image description here

deploy

Here we can build the image ourselves, or we can directly use the image in dockerhub to build it

When we search for gobang in dockerhub, we can see that there are many image files. I will choose the second one here wbsu2003/gobang

Insert image description here

We pull the image file to the server

sudo docker pull wbsu2003/gobang

Insert image description here
Run the following command to start the container

sudo docker run -d \
--name=gobang \
-p 8081:80 \
wbsu2003/gobang

Insert image description here
Let's run sudo docker ps to see if the container we just started started normally. We can see that the container we just started started normally.

Insert image description here

When starting the container, we stipulated that port 8081 should be used for access, so we have to go to the server to release port 8081, because only ports 22 and 80 are released by default when creating the instance. If you don't want to add a new port here, you can also map it to port 80 when starting the container.

We enter the instance details page, clickNetworking, and scroll down to findIPv4 Firewall a> ClickAdd rule to add port 8081
Insert image description here

Access: http://server ip:8081;
The screenshot is as follows:
Insert image description here

Insert image description here

Click start and you can have fun playing, but I have played a few games so far and basically haven’t won yet. It shows that my level is still too average.
I’ll stop here this time and study the code implementation in detail next time.

Guess you like

Origin blog.csdn.net/hacks8/article/details/134510032