battlegroundd#1
Open
afrsbrna wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/Tugas Besar IF2121 Logika Informatika/
/TIM Kata Bimo Bebas/
/13517004 - Bimo Adityarahman Wiraputra/
/13517100 - Irena Irmalasari/
/13517118 - Nada Afra Sabrina/
/13517133 - Fitria Budi Ananda/
/Predikat Dinamik/
:- dynamic(health/1).
:- dynamic(armor/1).
:- dynamic(map_state/1).
:- dynamic(position/2).
:- dynamic(at/3).
world_size(10).
newmap:-
/Fakta Terkait Peta/
world_size(WS),
asserta(at(1,,deadzone)),
asserta(at(WS,,deadzone)),
asserta(at(,1,deadzone)),
asserta(at(,WS,deadzone)),
/*Lokasi objek di peta pada awal permainan */
/Weapon/
asserta(at(3,3,weapon(glock-18))),
asserta(at(5,9,weapon(desert-eagle))),
asserta(at(7,2,weapon(p-2000))),
/Armor/
asserta(at(4,3,armor(tophat))),
asserta(at(6,8,armor(rider-vest))),
asserta(at(8,8,armor(jeans-jacket))),
/Medicine/
asserta(at(7,7,medicine(bandage))),
/Ammo/
asserta(at(1,3,ammo(glock-18))),
asserta(at(2,9,ammo(desert-eagle))),
asserta(at(5,2,ammo(p-2000))).
init:-
/Inisialisasi/
/Fakta Terkait Pemain/
/Pengaturan Awal Pemain/
asserta(position(3,3)),
asserta(health(100)),
asserta(inventory([])),
asserta(inv_cap(5)),
/Fakta Terkait Peta/
newmap.
/Fakta Terkait Objek/
/Rules/
/Rules kendali dasar/
/start -- Memulai permainan/
start:-
/retractall/
/help -- Menampilkan command yang tersedia dan legenda pada peta/
help:-
nl, print(' =================================================================='),
nl, print(' | Here are available commands for you to survive the game |'),
nl, print(' |==================================================================|'),
nl, print(' |start. | Start the game. |'),
nl, print(' |help. | Get some help to look over commands available.|'),
nl, print(' |quit. | Farewell, quit the game. |'),
nl, print(' |look. | Look around you. |'),
nl, print(' |map. | Open map and see where on Earth are you. |'),
nl, print(' |n. e. s. w. | Move to the North, East, South, or West. |'),
nl, print(' |take(Object). | Pick up an object. |'),
nl, print(' |drop(Object). | Drop an object. |'),
nl, print(' |use(Object). | Use an object from your inventory. |'),
nl, print(' |attack. | Attack the enemy that crosses your path. |'),
nl, print(' |status. | Show your status. |'),
nl, print(' |save(FileName). | Save your game. |'),
nl, print(' |load(FileName). | Load your previously saved game. |'),
nl, print(' |==================================================================|'),
nl, print(' | A useful legends of your map |'),
nl, print(' |==================================================================|'),
nl, print(' |W | Weapon |'),
nl, print(' |A | Armor |'),
nl, print(' |M | Medicine |'),
nl, print(' |O | Ammo |'),
nl, print(' |P | Player a.k.a YOU |'),
nl, print(' |E | Enemy |'),
nl, print(' |- | Accessible |'),
nl, print(' |X | Inaccessible |'),
nl, print(' ==================================================================').
map:-
printMap(1,1).
printMap(X,Y):-
world_size(WS),
X == WS,
Y == WS,
at(X,Y,deadzone), print('X'),!.
printMap(X,Y):-
world_size(WS),
Y == WS,
at(X,Y,deadzone), print('X'),
nl, !,
N is X+1, printMap(N,1).
printMap(X,Y):-
position(X,Y), print('P'), !,
N is Y+1, printMap(X,N).
printMap(X,Y):-
at(X,Y,deadzone), print('X'), !,
N is Y+1, printMap(X,N).
printMap(X,Y):-
print('-'),
N is Y+1, printMap(X,N).
take(X):-
position(A,B), at(A,B,weapon(X)), asserta(inventory([X|Y])),print('You took the '),print(X),!.
take(X):-
position(A,B), at(A,B,ammo(X)), asserta(inventory([X|Y])), print('You took the '),print(X),!.
take(X):-
position(A,B), at(A,B,medicine(X)), asserta(inventory([X|Y])), print('You took the '),print(X),!.
take(X):-
position(A,B), at(A,B,armor(X)), asserta(inventory([X|Y])), print('You took the '),print(X), !.
take(X):-
print('Object not found.').
n :-
position(A,B), N is A-1, at(N,B,deadzone), retract(health(X)), asserta(health(0)), !.
n :-
position(A,B), N is A-1, asserta(position(N,B)), retract(position(A,B)).
s :-
position(A,B), N is A+1, at(N,B,deadzone), retract(health(X)), asserta(health(0)), !.
s :-
position(A,B), N is A+1, asserta(position(N,B)), retract(position(A,B)).
w :-
position(A,B), N is B-1, at(A,N,deadzone), retract(health(X)), asserta(health(0)), !.
w :-
position(A,B), N is B-1, asserta(position(A,N)), retract(position(A,B)).
e :-
position(A,B), N is B+1, at(A,N,deadzone), retract(health(X)), asserta(health(0)), !.
e :-
position(A,B), N is B+1, asserta(position(A,N)), retract(position(A,B)).