The official NetHack repository is put on GitHub. First, we need to capture it and put it in our main directory.
Because NetHack supports many operating systems, we need to make some basic configuration to tell it that we are using Linux, and use open source gcc to replace the function of cc on Unix.
As I mentioned, there are several ways to achieve this. Some people want to put the configuration information in the hints file. Believe me, using the hints file will avoid a lot of trouble mentioned in the GitHub repository. The README file and other documents do not focus on how to use the hints file. We can do this:
This will set Makefile to correctly use the tools, libraries and their paths in Linux. This setting script is very powerful and has done a lot of configuration work. I'm glad it works well in WSL. If you are curious about how the script is written, you can use your editor to open it.
After the build is complete, you need to install it. This is to copy the executable file to the target location:
It will be installed to your ~ In the/nh folder, place NetHack IN ~ /Nh/install/games directory named nethack. To run it, switch to the directory (or enter the full path) and enter:
Then, the screen is displayed and you can play NetHack. Note that everything is done in this Ubuntu Linux environment and does not require anything unique to Windows.
Play NetHackDue to the limitations of terminal games and the complexity of NetHack, it is only possible here. There are some mysteries for those who first came into contact with it, but I think our programmers are never afraid of the unknown challenges.
The direction keys are the same as those in vi (vim). HJKL is left, bottom, top, and right. To exit the game, you can find the stairway exit on the top floor of the underground city and use it, or press the CTRL-C to force the exit.
In NetHack, the @ symbol represents yourself. Each floor consists of a room, corridor, door, And a stairway up or down. Monsters, treasure boxes, and items are comprised of various ASCII characters, and you will gradually become familiar with them. In order to comply with Roguelikes game specifications, there is no disk storage function, you only have one life. If you die, you can only play the game again. The underground city environment is randomly generated, and various items are disrupted.
The NetHack game aims to survive in the underground city, collect gold and items, and try to kill various monsters as much as possible. In addition to these purposes, you are constantly seeking for them. The rules generally follow the "Dragon and underground city (DnD)" weapons, skills, and other rules.
The following NetHack screenshot shows three rooms and two corridors. The upward stair is in the upper left corner of the room. I am now in the upper right corner of the room, there are some treasure chest and other items.
If no color is displayed in your game, you can create ~ /. Nethackrc file, and put the following content:
OPTIONS=color:true,dark_room:true,menucolors:true
Note: If the ASCII character graph is not your dish, but you like this type of game, you can search "roguelike" in the Microsoft Store to find a visually better game.
Of course, NetHack is very old and may only be liked by people of a specific age group. However, building it uses a large number of important development tools and * nix operating system functions, as well as terminal simulation functions. From here we can see that from gcc, gdb, make, bison and flex to more modern git, all work well in WSL.
If you want to see the demonstration at the Build Tour Conference, you can see this lecture at the Build Tour Canada conference. This section of WSL starts.
I hope you will enjoy exploring the NetHack underground.
C and C ++ are both great, just like other classic development tools. You can even use common Bash scripts. However, many developers prefer to use Python as their scripting language.
PythonYou can find many examples of Python scripts on the Internet, which means that Python is becoming more and more popular and useful. Of course, in most cases, these examples are run in Linux. In the past, we had to have another machine installed with Linux to run them, or use virtual machines and multi-boot, otherwise, you need to modify something to make them run in the Python environment in Windows.
This is not an unsolved problem, but it will gradually kill the daily lives of developers. With WSL, you have a compatible subsystem with Python functions and shell variables.
To install the latest Python development version and Python package installer pip, run the following command in Bash:
$ sudo apt install python-pip python-dev$ sudo pip install --upgrade pip
Now that Python is installed, I want to show you how to obtain a typical Python example in Linux from the Internet and let it work directly. I went to the Activestate Python menu station to find a top Python example. Well, I am just a little confused. The top one is the script that prints the integer name, which seems boring, so I chose the second place: Tetris. We can see Python in various places every day, so this time let's play another game.
I opened the nano Editor, copied the 275 lines of Python code from the page opened in a Windows browser, and pasted it into the nano in my WSL terminal window terminal, and save it as tetris. py, and then execute it:
$ python tetris.py
It immediately clears the screen and shows the game of Tetris. Like NetHack, you can use the direction keys of the same vi standard to move (in the past, the mouse and the WSAD key were used to move, while the right hand was more convenient to use the HJKL key ).
As I mentioned, you can certainly run Python in Windows without WSL. However, to be quick and easy, you do not need to modify the Python code in Linux, but simply copy and paste the code to run it, which can greatly improve the efficiency of developers.
This is true. This is not a substitute for Windows native tools, such as Python, PowerShell, C #, etc. It is when you need to quickly and effectively complete some things in modern development workflows, it can avoid all kinds of tossing.
Including Bash, Python, and all other native Linux Command Line development tools. WSL provides all the required tools for my development work. This is not a Linux server, or even a complete client. On the contrary, it is a tool that can help me avoid daily difficulties, let me develop something more efficient and exciting on Windows!
Reset your WSL EnvironmentTry it. If you break down your WSL environment, it will be easy to reinstall. Before proceeding, make sure that you have backed up any important content.
C:/> lxrun.exe /uninstall /fullC:/> lxrun.exe /install
How do you feel when using Bash and WSL?We hope that WSL, especially Bash, can help you increase efficiency and reduce the daily development difficulties.
What do you think about WSL on Windows 10? Do you like to use it?
The development team has done a lot of work to make WSL a powerful terminal tool for developers. If you have any feedback or running problems, we recommend that you check the GitHub feedback page and the user voice feedback and voting site. We really want to hear your voice.
Linux shell programming is a huge topic, and there are a lot of content on the Internet. If you are not familiar with them yet and want to learn more, you can take a look at various Bash tutorials. You can start with this.
From: https://linux.cn: 443/article-7613-1.html
Address: http://www.linuxprobe.com/windows-linux-system.html