Recreating Games in MATLAB


Example of Playing Snake that I Created in MATLAB.

SNAKEPROJECT ONGOING
Using MATLAB, I am developing an automated version of the game snake. I first started by creating a version that required user input, then attempted to automate this game by having the snake find its own path to the next apple. The automate snake is able to find the apple in most cases, but some cases have not been solved yet, or become over complex. The complexity will be taken out of the picture when the structure of possible cases is improved as well as only calculating the next few steps at a time and update the path as the snake moves through each block. This removes the complex case tree  The purpose of this project is to teach myself path finding for discrete orthogonal movements and optimization algorithms. I developed this code from scratch.

AUTOMATED SNAKE CODE DESCRIPTION
The automated version was developed starting off with simple cases. These simple cases include where the path from the head of the snake to the apple in not hindered by preceding links, in a matrix representing a subsection in the game board where one corner would represent the location of the head of the snake, and another corner representing the location of the apple. This matrix is populated with a 1 representing the location of the snake head, a -1 representing an preceding link that may have a presence within this subsection of the game board, and a -2 representing the location of the apple. Simple cases can be solved by using a nested for loop structure that would allow for movement along rows and columns from the head of the snake until the apple has been reached. Simple cases occur when a preceding link does not obstruct the natural path that would be given by the nested for loop structure. If the preceding links obstruct in a way that does not allow this natural path to be created, a new matrix representing the entire game board will be used using the same representation of 1, -1, and -2 as was described earlier in the subsection matrix. Using this entire matrix, different special cases are used to try to find a path to the apple. If this is not found, the snake has then lost. 

FUTURE WORK
This game is currently under development, and some special cases still need to be figured out. The future goal of this game is to have both an automated snake, and a snake requiring user input. The purpose would be for the user to try to grow their snake bigger than the automated snake, while at the same time avoiding walls as usual, along with the preceding links in their own snake and the automated snake. This will bring a new dynamic the game of snake making it rather difficult for the user to grow their snake as compared to the original game since there is not another snake present on the game board.

NOTE: I will upload files after creating a more friendly user interface and finishing the automated snake code. Currently fixing the special cases section of the automated snake.


Example of Playing 2048 that I Recreated in MATLAB.

2048
Using MATLAB, I developed my own version of 2048. I have not yet added in numbers displaying what each blocks value currently is, but that will be added in the next version. I developed this code from scratch.

2048 CODE DESCRIPTION
This section will be added soon.

ċ
MATLAB2048_Version1.m
(20k)
Frederick Wachter,
Feb 2, 2015, 8:00 AM
ċ
snakeAutomatedNew.m
(51k)
Frederick Wachter,
Jan 29, 2015, 11:42 PM
Comments