Implementation Of Divide And Conquer In The Hanoi Tower Game

.


INTRODUCTION
Artificial Intelligence (AI) is a part of science that is used to solve various complex problems in a more human way by utilizing a machine [1].This human nature usually leads to system behavior that imitates the behavior and thinking patterns of human intelligence, and implements it as an algorithm known to computers.According to [2] artificial intelligence is a rule that follows existing examples and definitions to make predictions and make decisions.Artificial intelligence also means the activity of providing machines such as computers with the ability to display behaviors that are considered as intelligent as if these abilities are displayed by humans, while according to [3], artificial intelligence is technology in the field of computer science that simulates human intelligence into machines (computers) to solve various problems and jobs as well as humans do.
Artificial intelligence is generally associated with computer science but also has close links with other sciences such as Mathematics, Psychology, Observation, Biology, Philosophy, and others.The ability to formulate various disciplines is what ultimately can provide benefits for progress in an effort to create an artificial intelligence.The technology is in its infancy and more and more companies are investing resources in machine research, indicating strong growth in artificial intelligence technology products and applications in the near future.Unlike common perception, examples of the application of AI are not limited to the information technology industry, on the contrary it is widely used in other fields such as medical, business, education, law, and manufacturing.Examples where AI enables a number of new capabilities that were still impossible a few years ago, such as automotive manufacturers developing self-driving vehicles, online search engines that can recommend the desired search results, social media can recognize faces in photos and filter news news, media companies are able to recommend books and showcase to their customers, retail stores capable of creating personalized online experiences for customers, logistics companies capable of finding the most optimal delivery routes, governments able to predict an epidemic of disease, marketing professionals providing personalized content personally to customers in real time, virtual assistants use natural language to interact with consumers.The advantages of artificial intelligence are that it is easier to deploy, more permanent, can be repaired easily, is easy to modify, is consistent and is able to do tasks very quickly.[4].
According to [5], artificial intelligence has a scope which includes Natural Language Processing, Expert Systems, Robotics, Navigation Systems, and games.Game is an implementation of the field of computer science that can also embrace the concept of AI.According to [6], the game is a complete activity that contains rules and culture in it.The game can be considered as a system that involves players in an artificial conflict because the game is designed to have an interaction between the player and the engineered system.At this time, many games have been made ranging from action, combat, simulation, strategy, sports, music, education, adventure, to puzzles.
In the midst of the rampant types of games available, the author chose the Hanoi Tower.According to [7], hanoi tower is one example of a puzzle game related to mathematics which is quite famous.The game This puzzle is also often used in Computer Science as an example of implementing a recursive function, while according to [8], hanoi tower is a math logic puzzle game.In this game there are three poles and several discs of different sizes.Individual discs can be inserted in the post freely.The game begins with a neat pile of discs in the order of the largest discs on the bottom until the small discs are turned on top to form a cone on one pole.The goal of the puzzle is to move the entire pile to another pole.In this game, players are challenged to complete in the shortest possible time with a certain number of discs.The benefit of this game is that it can train how to think with certain patterns so as to improve the memory of players.
Computers cannot directly solve an existing problem without an algorithm.According to [9], an algorithm is a logical and systematic arrangement to solve a problem or to achieve certain goals.In the world of computers, algorithms play an important role in the development of a software.There are various kinds of Artificial Intelligence algorithms that are used, some of which are the Interative Deepening Search Algorithm, Minimax Algorithm, A * Algorithm, Cosine Similary Algorithm, Greedy Algorithm, Divide and Conquer Algorithm, Genetic Algorithm, Breadth First Search, Depth First Search, and so on.
The Divide and Conquer method is generally divided into three stages, namely divide which can be interpreted as the process of dividing the problem into the smallest parts (sub) of the problem, conquer which means completing the sub-problem recursively and the last one is combine, which is combining the results of sub-solving the sub-problem becomes the final solution for the expected solution [10].According to [11], The division in the Divide and Conquer algorithm is done through input tools in the form of tables (arrays), matrices, exponents, and other components according to the existing problem.In each sub-problem, it must contain problem characteristics that are similar to the characteristics of the initial problem, so that the divide and conquer method is able to work well on problems that are solved recursively (self-invoking repetition).Apart from recursive loops, this algorithm can also be used for regular repetition (iterative) processes.This is because in principle these two iterations have in common.In practice, the Divide and Conquer algorithm can be applied in various systems such as designing a fingerprint-based population identity system as a separator in data storage and data retrieval, for optimizing the conversion of decimal to binary numbers, to increasing the detection speed of client honeypots machines, for the calculation of eigenvalues in the field of linear algebra, and so on.This algorithm can also be applied to game programs.
In this game, players are challenged to complete in the shortest time with a certain number of discs.The problem with this game is the number discs used very much, then the player takes a very long time to finish this game.More and more discs existing the more needed memory enough to remember the patterns already used.Some of the previous scientific works that discuss the problem of the logic of the hanoi tower game are as follows : 1. Supiyandi [12] in a journal entitled Settlement Of The Problema Tower Of Hanoi Using Algorithm A *.This journal explains how to solve the Hanoi tower problem by calculating the A * Algorithm.The main difference with current research is that apart from the algorithm used in the testing process. in research that is currently being tested with discs that have the same size and there is also an explanation of the processing time of each disc being tested.2. D.D. Bhakti [8] in a journal entitled Game Education Menara Hanoi as an Alternative to Learning Mathematical Logic in SMK.This journal only explains the explanation of the use of dynamic programming using Java in the Hanoi tower game.There is no discussion of calculating the minimum disk displacement step for multiple disk counts.This research also discusses the testing of several discs to find the minimum number of steps for their displacement.3. Weiskhy, S.D. [13] in the journal entitled Hanoi Tower Logic Game Against Children's Thought Development Using Visual Basic.Net Programming Language explained the use of Hanoi tower games to help develop children's thinking power.
In this study, no trial was discussed to determine the number of steps required in detail.4. Dais, S. Et al [10] in the journal entitled Implementation Of Divide And Conquer Algorithm In Tajwid Science Learning Application explained the use of the Divide and Conquer algorithm in the Tajweed Science Learning Application.5. David, S., et al [11] in a journal entitled Application of the Divide and Conquer Algorithm in Designing a Fingerprint-Based Identity System, explained the benefits of using the Divide and Conquer algorithm in a shorter data search process.

RESEARCH METHOD
In conducting this research, researchers used experimental methods.According to [14] The experimental method is defined as a series of experimental activities that aim to observe a problem so that results are obtained, whereas according to [15], experimental research method is defined as a method to find the effect of a particular treatment under controlled conditions.
Based on the steps of the experimental method according to [15] the research stages carried out by the researcher are shown as shown in Figure 1.From Figure 1, the steps can be explained as follows:

Collect and analyze data
There are data collection activities carried out before the treatment, namely in the form of a preliminary test on the tower hanoi game.The data collected is the data on how long it took the player to finish the game in the absence of the help of a finishing step, how many steps the player has taken, and the speed of playing.The collected data is then analyzed to find a solution.

Make a design
With the Divide and Conquer algorithm, the authors designed the hanoi tower game application interface and its solution.

Conduct experiments
After the experimental design was prepared.The next step is to go into the field to conduct experiments, namely to carry out treatment in order to compare the treatment of games that do not use algorithms and those that use algorithms.

Implement the right algorithm
With this the authors use the Divide and Conquer algorithm to be applied as a solution.
7. Make interpretations based on the algorithm tests that are performed Based on the results of testing the application of the algorithm, it can be concluded whether the Divide and Conquer algorithm can be a solution or not.Then carried out a discussion of the research results obtained.

Collecting Data Method
According to [14] data collection methods are techniques used to collect data and find facts in studying the existing system.This method is the most important stage in research, because research has the main objective of obtaining data.
Data collection for this study was carried out in a secondary way through literature studies.According to [16], Literature study is a research supporting data collection technique that is obtained from the main points of the expert's thoughts as outlined in writing in reference books, journals, research reports or other scientific works.Researchers used the literature study data collection method through reference books and journals related to Artificial Intelligence (AI), the Divide and Conquer algorithm and the hanoi tower game.

2.3.Analysis Data Method
The method of data analysis is part of the implementation of research where the data that the researcher has collected are processed and used as an answer to the identification or formulation of the problems obtained.In this research, the data analysis method used is descriptive qualitative data analysis method.The qualitative descriptive data analysis method is useful for developing theories that have been built from data that has been obtained in the field.The qualitative descriptive method was initially carried out by the researcher, then the data was collected in depth, from observation to report preparation.

Hanoi Tower With 3 poles
In this section we will discuss a case analysis of a hanoi tower using 3 poles.To solve this problem, we need a recursive function to determine the minimum number of steps.The minimum number of steps to solve each disk level is always one step more than the two previous steps or written as in equation ( 1): (1) where Sn is the minimum number of steps for level n discs.The simple form of the recursive function is written as in equation ( 2) Next we will try to analyze the minimum steps for moving the disc by using 3 poles.For example, the number of discs is 2, 3 and 4 discs.The first case will be solved by the Hanoi tower using only 1 disc.Suppose 3 poles are given their respective names: X, X2 and X3 where X1 is considered the original pole, X2 is the support pole and X3 is the destination pole.To complete the Hanoi tower with only 1 disc, just use 1 step, which is to move the disc from the X1 to X3 pole.Suppose that the minimum number of steps for 1 disc is S1 then S1 = 1.Now it will be tested using 2 discs.To determine the number of solving steps with 2 discs, the minimum step equation can be used as in equation ( 2), so that the results of the steps are as follows :  If you pay attention to the completion of 2 discs, by changing the pattern and pole label, step 1 and step 3 on 2 discs have the same as step 1 on 1 disc, while the second step on 2 discs is a different step so that the steps can be written the minimum is as follows: . What is meant by the same step by changing the pattern or label here is: displacement of discs to the same number of discs.Like moving 1 disc, it can be seen that to complete it is only enough to move disc number 1.In the case of moving 2 discs it can be seen that the moving process requires 3 steps where the step of moving disc number 1 is located in steps 1 and 3 so it can be concluded that steps 1 and 3 To move 3 discs is the same step as to move 1 disc because it is disc number 1 being moved.
From the experiment using 2 discs, now it will be tested using 3 discs.To determine the number of steps required, equation (2) above can be determined so that the results are :

s
. From this equation, it is concluded that to move 3 discs requires 7 steps.Figure 3 shows the process of moving 3 discs.From these steps if you pay attention, by changing the label on the pole, steps 1-3 and steps 5-7 on disc 3 have the same finishing steps as finishing disc 2 namely by moving disc number 1,2,1 while step 4 disc 3 is a different step so that the minimum number of steps can be written as follows :

Generalization of the hanoi tower problem
From the 3 experiments described above, if you pay attention that it turns out that the solution of the Hanoi tower problem can be easily solved using a divide and conquer algorithm which contains a recursive concept.To move 3 discs, a 2-disc transfer step is used.To move 4 discs, used step removal of 3 discs and so on so that a transfer step ( -1) is required for move  discs.
The completion step can be stated in recurrent relations which can also be solved with the following algebraic notation : From the algebraic manipulation steps, the solution of the recurrence relation is obtained to determine the minimum number of disc displacement steps in the Hanoi tower game where  dish is : where n is the number of discs.
In general, the total displacement for a number of n discs is shown in table 1 below :

Results of program implementation
From the results of the analysis of the trials that have been carried out, these results can be applied in the application being made.Figure 4 shows the application implementation.

CONCLUSION
Based on the results of trial analysis to determine the minimum number of completion steps in the hanoi tower game, several conclusions can be drawn as follows: a.The Divide and Conquer algorithm is one of the algorithms that can be used to solve the Hanoi Tower game problem with its recursive nature by breaking the problem into sub-problems so that from solving these sub-problems, the solution to the original problem is obtained.b.With the recursive nature of the Dividde and Conquer algorithm, if there is  disc on one pole, then the  -1 top disc should be moved to the support post.After that the discs largest is moved to the destination pole, so  -1 the disc can be moved back onto the disc largest on the goalpost.By carrying out these recursive steps, the Hanoi tower problem can be solved in 2  -1 step.c.In its application in the Hanoi tower game, the Divide and Conquer algorithm can help provide a solution for the finishing steps to move a number of n discs to the target pole because of its recursive nature so that the game can be completed in a fast time.

FUTURE WORKS
For further development, this research will add another algorithm so that more effective algorithms can be seen that can be used to solve this Hanoi tower game.

1 .
Formulate research problems Researchers have formulated existing research problems, namely, how the concept of the Divide and Conquer algorithm in the hanoi tower logic game and how to apply the Divide and Conquer algorithm to the hanoi tower game.2. Do a library review Based on the research problem, a literature review is then carried out to look for theories that are relevant to the research problem.Researchers conducted a literature review by studying and understanding the concept of the Divide and Conquer algorithm proposed by several researchers.

.
From this equation it can be concluded that to move 2 discs from pole X1 to pole X3 requires 3 steps.The results are shown as in Figure2.

Figure 3 .
Figure 3. Steps to move 3 discs.The steps for moving the disc in Figure 3 are as follows : The first step : Move disc one from pole X1 to pole X3 Second step : Move disc two from pole X1 to pole X2 Third step : Move disc one from the X3 pole to the X2 pole Fourth step : Move disc three from pole X1 to pole X3 Fifth step : Move disc one from pole X2 to X1 Sixth step : Move the disc two from the X2 pole to the X3 pole Seventh step : Move disc one from pole X1 to pole X3 From all the experimental examples S1 to S3, it can be concluded that to determine the minimum number of steps to move n discs is :

Figure 4 .
Figure 4. Implementation of the Hanoi tower game.

Figure 4
Figure 4 shows the game of Hanoi tower level 4 with 5 discs.If during the game and the player wants a game solution, then a solution is obtained as shown in Figure 5.

Table 1 .
Calculation of the number of displacement steps