ANACONDA : The game of an intelligent snake

      

1. This game was made by me & the paper was prepared by myself & Moksh Walia, my friend , who is  my class mate.

 

2. INTRODUCTION

 

                     Soft computing is the state-of-the-art approach to artificial intelligence, and it mainly comprises fuzzy logic, neural networks and probabilistic reasoning. It aims at mimic human reasoning particularly in computer milieu, and hence in practice, the Soft computing systems are adaptive and intelligent in nature. Unlike the respective hard computing methods, soft computing may cope with problems that deal with imprecision, uncertainty and learning, and we may effortlessly construct systems and models, which are simple, applicable, user-friendly and fast with respect to computing. Hundreds of concrete applications are already available in control, decision-making, pattern recognition and robotics, inter alia.

 

 

3. WHAT IS SOFT COMPUTING ?

                        Soft computing differs from conventional (hard) computing in that, unlike hard computing, it is tolerant of imprecision, uncertainty and partial truth. In effect, the role model for soft computing is the human mind. The guiding principle of soft computing is: Exploit the tolerance for imprecision, uncertainty and partial truth to achieve tractability, robustness and low solution cost. The basic ideas underlying soft computing in its current incarnation have links to many earlier influences, among them the 1965 paper on fuzzy sets; the 1973 paper on the analysis of complex systems and decision processes; and the 1979 report (1981 paper) on possibility theory and soft data analysis. The inclusion of neural network theory in soft computing came at a later point. At this juncture, the principal constituents of soft computing (SC) are fuzzy logic (FL), neural network theory (NN) and probabilistic reasoning (PR), with the latter subsuming belief in networks, genetic algorithms, chaos theory and parts of learning theory. What is important to note is that SC is not a mélange of FL, NN and PR. Rather; it is a partnership in which each of the partners contributes a distinct methodology for addressing problems in its domain. In this perspective, the principal contributions of FL, NN and PR are complementary rather than competitive.

 3.1 Implications & Applications of Soft Computing

 

                     The complementarily of FL, NN and PR has an important consequence: in many cases a problem can be solved most effectively by using FL, NN and PR in combination rather than exclusively. A striking example of a particularly effective combination is what has come to be known as neuro fuzzy systems. Such systems are becoming increasingly visible as consumer products ranging from air conditioners and washing machines to photocopiers and camcorders. Less visible but perhaps even more important are neurofuzzy systems in industrial applications. What is particularly significant is that in both consumer products and industrial systems, the employment of soft computing techniques leads to systems, which have high MIQ (Machine Intelligence Quotient). In large measure, it is the high MIQ of SC-based systems that accounts for the rapid growth in the number and variety of applications of soft computing - and especially fuzzy logic.

           BISC Program is the world-leading center for basic and applied research in soft

            computing

4. THE GAME ANACONDA.

4.1 About the technical specifications of the   software:

 

·        This software runs on windows95/98/NT/XP platform & at least 64 Kb of System memory with a

          monitor supporting a resolution of 640X480 using 16 colors.  

·        This game has been designed in C Programming language using graphics.

·        It has approximately 1000 Lines of Code.  

 

5. MODULE WISE DESCRIPTION OF THE PROGRAM.

               The basic strategy of the game is to let the user navigate the snake in any vertical and horizontal directions, and the food should keep coming at regular intervals.

                  5.1 Movement of the snake :

v     We have defined the body of the snake which is a series of circles which can be considered as bits of the snake body, as a structure holding the x & y coordinates of the body part in two different arrays. Initially the hurdles are placed onto the screen by the call to a function showblock ( ).As the snake moves the structure is constantly updated with the help of a module named define ( ). It takes as an argument i.e. the impending coordinates of the head of the snake & makes change accordingly. There is a module name fill ( ) which takes as arguments the x,y coordinates of the a bit of snake coordinate and the fill color. This module has been made inline so as to remove memory overhead, as it is to be used reiteratively to fill each bit of the snake.

v     The same function is also used to draw the hurdles on the screen randomly. At present the position of hurdle on the screen has been defined at the start, but it could be placed randomly in order to give a variety. It is also used to draw the food randomly on the screen.

v      The control ( ) function takes care of the user response and guides the snake to move in the direction as felt by the user. It has an infinite loop that keeps on moving the snake unless the snake dies or the user stops the game unconditionally. It also takes care not to hamper the movement of the snake if accidentally the user presses any keys other than the arrow keys.

v     The modules up ( ), down ( ), right ( ), left ( ) as the name suggests takes care of the motion of the snake in the specified direction. They also contain infinite loops to keep the snake moving all the time, unless the user presses a key.

v     A constraint on the movement of the snake is that it dies if it meets a hurdle or touches its own body. Hence the motion of the snake needs to be monitored for every single bit movement of the snakehead. The function check1 ( ) & check2 ( ) checks whether the snake has met a hurdle or has touched its own body.

v     The function provide ( )  puts the food on the screen randomly (with the use of food ( ) function ) of course checking whether accidentally the food has been placed on the snake body itself, the check3 ( ) functions takes its stride into such a possibility. The see ( ) module checks with the help of eat ( ) module whether snake has eaten food and increases the score based on the level at which the user is playing.

                                                                             Level             Score increases by:

1                                100

2                                200

3                                300

4                                400

5                                500

v     The food stays in the screen for a small period of time. The counter( )  function takes care of it, & after the stipulated time is over it deletes the food and then redraws it again using provide ( ) & food ( ) .

v     The body of the snake increases by two bits as it eats food. The increase ( ) function has to take care of the fact that the snake body increases by two bits by its head and if it has to increase in such a situation that its at the end of the window then the body of the snake will increase from the corresponding other end of the window. Hence there are four blocks inside increase ( ) taking into consideration the increase in the specified four directions.

v     The tune ( ) function plays the introductory & the concluding notes.

v     There is a system to store the current highest score.

v     The module highscore ( ) accepts an integer i.e. the present score at which the game is terminated and compares it with the score already stored in the file named high (it’s a binary file). If it is larger then it is stored.

 

                          5.2  Scintillating user interface :

v Remotely, there are some modules that define the overall outlook of the game & give it an attractive interface. These are instructions ( ),refresh( ),disclaimer ( ),   check ( ) , getkey ( ),intro ( ), playgame ( ),module ( ),credits ( ),options ( ), page3 ( )  page2( ),over ( ),loading ( ),outlook ( ). Let us discuss the function of each module one by one.

v The intro ( ) function displays the name of the Game & the group in a fashionable manner. The instructions ( ) module dictates the rules & procedure of playing the game , refresh ( ) refreshes the screen, disclaimer ( ) scans & prints the help file , getkey ( )  scan converts the user response from the keyboard, module ( ) helps the user to glide through  the various options for example  NEW GAME  , OPTION , HIGH  SCORES , EXIT.

v The options ( ) function helps the user set the level of the game (i.e. the speed of the snake). page3 ( )  displays some graphics which appears soothing to the eye of the user. page2 (  )  displays the four options given above .loading ( ) gives the user the feeling the game settings are being loaded into the  memory. outlook ( ) function integrates and streamlines the working of the above functions. Finally credits ( ) function displays in the exit screen the name of the designers. 

 

 

6. ARTIFICIAL INTELLIGENCE USED IN THE GAME.

               We can have more than one snake in this game. The snakes could be controlled by multi-users or by computer itself. If computer has to control the snake then we will use artificial intelligence so that computer is able to decide on its own modus operandi to eat the food considering the moves made by user’s snake. Here are some major points that should be considered to make computer’s snake intelligent.

¨     The computer’s snake will move as the user’s snake will move and with all those restrictions followed by users snake as mentioned above. Beside these computer’s snake will have to take care that it should not hit user’s snake.

¨     As the food appears the computer’s snake will decide the shortest path to reach the food and eat it. If user’s snake comes in the shortest route then it will find an optimal path to reach the food. To decide shortest path or optimal path the computer will have to take care of the hurdles also.

¨     So in this way modus operandi of computer’s snake will change with every iteration of loop.

¨     The computer’s snake may come closer to user’s snake up to a certain limit.

¨     Sometimes the computer will have to anticipate user’s snake moves, which it can do by knowing coordinates of the user’s snake head and its present direction of movement. The computer will calculate the optimal path which user’s snake might follow to reach the food. Computer will compare optimal path of user’s snake and computer’s snake if it matches then it will find another optimal solution to reach the food.

This will create a tug of war between user’s snake and computer’s snake and make game much more interesting.  

 

7. CONCLUSION

                As a future enhancement we are planning to do the coding in Java, so that we can incorporate multithreading which can support multiplayer concept, i.e. more than two players will be able to play at the same time. Overall, the road ahead for Java looks brighter than ever, especially in soft computing. As it stands now, Java is a full and complete general-purpose scientific language. The use of AI in the game makes it more interesting & astonishing because the versions of the snake game available at present, in general ,doesn’t use AI to its fullest. We also propose to upload the game (made in Java) in  our website, so that the user can download it onto their  mobile phones (which support JVM). This would open a new arena of game programming.

 

Hosted by www.Geocities.ws

1