Skip to content

Commit

Permalink
hell3
Browse files Browse the repository at this point in the history
  • Loading branch information
primayoriko committed Nov 18, 2019
1 parent 2afbc0c commit 6c222f0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 53 deletions.
3 changes: 0 additions & 3 deletions b.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
game_status(1).
game_status(0).
tinggiPeta(13).
lebarPeta(10).
ctrheal(0).
Expand Down Expand Up @@ -36,8 +35,6 @@ digym(0).
udahheal(0).
udahheal(0).
lagi_ketemu(0).
lagi_ketemu(0).
battle_status(0).
battle_status(0).
finish_battle(0).
finish_battle(0).
Expand Down
58 changes: 26 additions & 32 deletions main.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@
(udahheal(_)->retractall(udahheal(_))),assert(udahheal(0)),retract(tangkaptime(_)),assert(tangkaptime(0)),
retract(pick_time(_)),assert(pick_time(0)),
(lebarPeta(_)->retract(lebarPeta(_))),(tinggiPeta(_)->retract(tinggiPeta(_))),(posisiGym(_,_)->retractall(posisiGym(_,_))),(rintangan(_,_)->retractall(rintangan(_,_))),(ctrheal(_)->retractall(ctrheal(_))),
/*(posisiLegendary(_,_,_)->retractall(posisiLegendary(_,_,_))),*/
/*(udah_lari(_) -> retract(udah_lari(_))), (lagi_ketemu(_) -> retract(lagi_ketemu(_))),(battle_status(_) -> retract(battle_status(_))),
(digym(_)->retract(digym(_))),(maucapture(_)->retractall(maucapture(_))),(lagi_pick(_)->retractall(lagi_pick(_))),(finish_battle(_)->retractall(finish_battle(_))),
(current_tokemon1(_,_,_,_)-> retract(current_tokemon1(_,_,_,_))),(current_tokemon2(_,_,_,_) -> retract(current_tokemon2(_,_,_,_))),
(player_status(_)->retract(player_status(_))),*/ (player_position(_,_)->retract(player_position(_,_))),(inventory(_,_,_,_,_,_,_,_)->retractall(inventory(_,_,_,_,_,_,_,_))),(maxInventory(_)->retract(maxInventory(_))),(gameMain(_)->retractall(gameMain(_))),
(player_position(_,_)->retract(player_position(_,_))),(inventory(_,_,_,_,_,_,_,_)->retractall(inventory(_,_,_,_,_,_,_,_))),(maxInventory(_)->retract(maxInventory(_))),(gameMain(_)->retractall(gameMain(_))),
write('Terima Kasih telah bermain!'),nl,
write('Sampai jumpa lagi!'),nl,!.

Expand Down Expand Up @@ -112,20 +108,6 @@
printLegendaryKosong,
!.


% printListLegendaryTokemon:-
% forall(tokemon(Tokemon,A,B,C,D,E,X),
% forall(X > 12,forall(posisiLegendary(Tokemon,XX,YY),forall(\+inventory(Tokemon,_,_,_,_,_,_,_),(
% write('Tokemon: '), writeln(Tokemon),
% write(' Health: '),writeln(A),
% write(' Normal attack: '),writeln(B),
% write(' Special attack: '),writeln(C),
% write(' Nama special attack: '),writeln(D),
% write(' Type: '),writeln(E),
% write(' ID: '),writeln(X),
% write(' Posisi: '),write(XX),write(','),write(YY),nl)
% ))
% )),!.
printLegendaryKosong :-
findall(Tokemon,(tokemon(Tokemon,_,_,_,_,_,X),
X > 12,inventory(Tokemon,_,_,_,_,_,_,_)),ListLegendary),
Expand Down Expand Up @@ -218,17 +200,29 @@
( at_end_of_stream(Stream) -> Lines = [] ; Lines = [Line|NewLines],
read_file(Stream, NewLines)).

/*loads(_) :-
game_status(1),
write('Kamu tidak bisa memulai game lainnya ketika ada game yang sudah dimulai.'), nl, !.
loads(FileName):-
\+file_exists(FileName),
write('File tersebut tidak ada.'), nl, !.
/*source:
load file : https://stackoverflow.com/questions/37573618/how-to-read-a-file-in-prolog/37574687#37574687
*/


/* Dump File : */

/*(posisiLegendary(_,_,_)->retractall(posisiLegendary(_,_,_))),*/
/*(udah_lari(_) -> retract(udah_lari(_))), (lagi_ketemu(_) -> retract(lagi_ketemu(_))),(battle_status(_) -> retract(battle_status(_))),
(digym(_)->retract(digym(_))),(maucapture(_)->retractall(maucapture(_))),(lagi_pick(_)->retractall(lagi_pick(_))),(finish_battle(_)->retractall(finish_battle(_))),
(current_tokemon1(_,_,_,_)-> retract(current_tokemon1(_,_,_,_))),(current_tokemon2(_,_,_,_) -> retract(current_tokemon2(_,_,_,_))),
(player_status(_)->retract(player_status(_))),*/

loads(FileName):-
open(FileName, read, Str),
read_file_lines(Str,Lines),
close(Str),
assertaList(Lines), !.
*/
% printListLegendaryTokemon:-
% forall(tokemon(Tokemon,A,B,C,D,E,X),
% forall(X > 12,forall(posisiLegendary(Tokemon,XX,YY),forall(\+inventory(Tokemon,_,_,_,_,_,_,_),(
% write('Tokemon: '), writeln(Tokemon),
% write(' Health: '),writeln(A),
% write(' Normal attack: '),writeln(B),
% write(' Special attack: '),writeln(C),
% write(' Nama special attack: '),writeln(D),
% write(' Type: '),writeln(E),
% write(' ID: '),writeln(X),
% write(' Posisi: '),write(XX),write(','),write(YY),nl)
% ))
% )),!.
58 changes: 40 additions & 18 deletions map.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

:- include('battle.pl').
/*UNTUK DEBUG*/
posisiLegendary(inkmon,10,10).
posisiLegendary(yorikomon,20,20).
posisiLegendary(iqbalmon,11,11).
posisiLegendary(malmon,21,21).
posisiLegendary(ascalon,22,22).

init_map :-
random(10,20,X),
Expand All @@ -21,6 +16,7 @@
asserta(lebarPeta(X)),
asserta(tinggiPeta(Y)),
asserta(player_position(1,1)),
generateLegendary,
generateGym,
generateRintangan,
!.
Expand Down Expand Up @@ -107,6 +103,8 @@

printMap(X,Y) :-
player_position(X,Y), !, write('P').
printMap(X,Y) :-
legendary_place(X,Y,_), !, write('L').
printMap(X,Y) :-
isGym(X,Y), !, write('G').
printMap(X,Y) :-
Expand All @@ -122,36 +120,60 @@
printMap(_,_) :-
write('-').

generateRintangan :-
isLegendary(A,B):-
legendary_place(A,B,_).

generateLegendary:-
lebarPeta(X),
tinggiPeta(Y),
XMin is 2,
XMax is X,
YMin is 2,
YMax is Y,
Sum is round(X*Y/10),

forall(between(1,Sum,_), (

forall(between(13,17,R), (
random(XMin,XMax, A),
random(YMin,YMax, B),
asserta(rintangan(A,B))
assert(legendary_place(A,B,R))
)),
!.
generateGym :-

generateGym:-
lebarPeta(X),
tinggiPeta(Y),
XMin is 2,
XMax is X,
YMin is 2,
XMax is X,
YMin is 2,
YMax is Y,
Sum is round(X*Y/100),

forall(between(1,Sum,_),(
random(XMin,XMax,A),
random(YMin,YMax,B),

forall(between(1,Sum,_), (
random(XMin,XMax, A),
random(YMin,YMax, B),
not(isLegendary(A,B)),
asserta(posisiGym(A,B))
)),
)),
!.


generateRintangan :-
lebarPeta(X),
tinggiPeta(Y),
XMin is 2,
XMax is X,
YMin is 2,
YMax is Y,
Sum is round(X*Y/10),

forall(between(1,Sum,_), (
random(XMin,XMax, A),
random(YMin,YMax, B),
not(isLegendary(A,B)),
not(posisiGym(A,B)),
asserta(rintangan(A,B))
)),
!.

map :-
lebarPeta(X),
tinggiPeta(Y),
Expand Down

0 comments on commit 6c222f0

Please sign in to comment.