Knight's Tour

The Knight's Tour is game that I developed using the Unreal 4 Engine. It is based on the ancient game of the same name. Instead of the usual medieval chess based concept, I created a space theme for the game. The Knight here is a space hoverbike and the arena is a board of floating platforms. The player moves a gamepiece around a board in a L-shape pattern (2 steps forward and 1 step to the side) without moving into any previously visited tiles. I am responsible for all aspects of development: art, fx, design and scripting (blueprint). The game was expanded to Unity Engine in as part of my self-learning process. I programmed the Knight's Tour using the C-Sharp language.

The above script shows how the board is constructed. Both row and column sizes are variables that can be modified to allow either square size construction or rectangular construction of a board. The corresponding codes in Unity is as shown below.

The above script explains how the player is spawned in the game. When a tile is clicked, the system checks if the knight has been spawned. If spawned, then the tile that has been clicked becomes the target destination to move to. If not yet spawned, then the tile becomes the spawn location.

Here, the script checks to see if the tile that has been clicked is a valid destination. A valid desination is a tile that has not been visited and is within the moving range. Once moved into, the tile is flagged as visited and the board is updated.

 

The codes basically check if at a given location (i.e. end of the L shape pattern), there is a tile and if that tile has not been visited, then add that position to a list of valid moves that the player can make. Everytime, this function is entered, that list of valid moves is cleared.

The script allows highlighting of valid tiles to provide feedback for player.

The script above and the codes below handles the event when a tile is clicked. It checks if a player has been spawned. If not a new player is spawned at the tile location. If already spawned, the player is moved to the new location. If all tiles have been visited, the player wins.

Click here to download the game.

© 2018 by Sanath Shekar.

This site was designed with the
.com
website builder. Create your website today.
Start Now