Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

ProLog Program of Game EX

Posted By: Milind Mishra     Category: Artificial Intelligence     Views: 3559

Program of prolog Game Ex.

Code for ProLog Program of Game EX in Artificial Intelligence

%trace
domains
    game_list,Tmp_list=symbol* 
    name=symbol
    age,Counter,Counter1=integer

database
    student_db(name,age,game_list)

predicates

    go
    input_student_details
    read_Gamelist(symbol,integer,Game_list,Tmp_list,integer,integer) 
    display_Gamelist(Name,Age,Game_list,Tmp_list)
    get_Team
    find_Cricket(Game_list,Game_list,Counter,Counter1)
    repeate

clauses
    repeate. 
    repeate:-
              repeate.
    go:-
           
           input_student_details,
           save("abc.txt"),
           write("commit"),
           get_Team.
     
    input_student_details:-
           write("Enter Student Name: "),
           readln(Name),
           write("Enter Student Age: "),
           readInt(Age),
           write("\nEnter No. of Games Student Plays "),
           readInt(No_Game),
           read_Gamelist(Name,Age,Game_list,Tmp_list,No_Game,No_game),
           write("bye").
        
    get_Team:-     
           student_db(Name,Age,Game_list),    
           find_Cricket(Game_list,Game_list,Counter,Counter1), 
           write("\n No of Cricket Player %d",Counter1),
           Counter=Counter1 + 0,
           repeate.  

    find_Cricket(Game_list,[],Counter,Counter1):-
           Counter1= Counter+1 .        
     
   find_Cricket(Game_list,Tmp_list,Counter,Counter1):-
          Game_list1=[H |T],
          H<>"criket",
          find_Cricket(Game_list,T,Counter,Counter1).
          
     read_Gamelist(Name,Age,Game_list,Tmp_list,No_Game,0):-
           display_Gamelist(Name,Age,Game_list,Tmp_list).       

     read_Gamelist(Name,Age,Game_list,Tmp_list,No_Game,Count):-
           write("Enter Game name :"),
           readln(Game_nm),
           Game_list1=[Game_nm|Game_list],
           Count1=Count-1,
           read_Gamelist(Name,Age,Game_list1,Tmp_list,No_game,Count1).

     display_Gamelist(Name,Age,Game_list,[]):-
          assert(student_db(Name,Age,Game_list)),
        write("\nList is Displayed").      
                  
     display_Gamelist(Name,Age,Game_list,Tmp_list):-
           Tmp_list=[H|T],
           write(H),
           display_Gamelist(Name,Age,Game_list,T).   
           
           student_db("Mahesh",22,["football","Cricket"]).
           student_db("Ramesh",23,["volleyball","Cricket"]).       
       student_db("Suresh",24,["Basketball","Cricket"]).
       student_db("Paresh",25,["football","Cricket"]).
       student_db("Kamlesh",26,["Basketball","Cricket"]).
       student_db("Kamal",27,["football","Cricket"]).
       student_db("Pratap",18,["Basketball","Cricket"]).
       student_db("Ganpat",19,["football","Cricket"]).
       student_db("Bupesh",20,["Volleyball","Cricket"]).
       student_db("Sailesh",21,["football","Cricket"]).
       student_db("Ritesh",17,["Basketball","Cricket"]).
       student_db("Pritesh",16,["Volleyball","Cricket"]).
       student_db("Parag",15,["football","Cricket"]).                    
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on ProLog Program of Game EX Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of ProLog Program of Game EX is from India.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!