calc_tokens changes

This commit is contained in:
Maximilian Wagner 2023-06-23 17:02:49 +02:00
parent 0c6f534bc2
commit 8c9993c172
3 changed files with 43 additions and 17 deletions

View File

@ -69,7 +69,7 @@ init_feld1 :-
reset_game :- reset_game :-
abolish(feld/3), abolish(feld/3),
abolish(einheit_active/4), abolish(einheit_active/4),
abolish(current_player/1), change_player_to(1),
abolish(game_window/1), abolish(game_window/1),
abolish(game_table/1), abolish(game_table/1),
abolish(game_control/1), abolish(game_control/1),

View File

@ -5,6 +5,26 @@ debug_init :-
init_player2(infantry,infantry,infantry), init_player2(infantry,infantry,infantry),
init_feld1. init_feld1.
debug_calc(Type, Loops) :-
debug_init,
debug_run(Type, Loops-1),!.
debug_run(1, Loops) :-
Loops > 0,
player_tokens(Player, Tokens),
write(Tokens), nl,
end_turn, end_turn,
debug_run(1, Loops-1).
% default case
debug_run(1, Loops) :-
player_tokens(Player, Tokens),
write(Tokens).
debug_run(2, Loops) :-
einheit_action(0,0,1,1),
debug_run(1, Loops).
print_info(Type,X,Y,HP) :- print_info(Type,X,Y,HP) :-
write("-------"),nl, write("-------"),nl,
write("Type: "), write("Type: "),

View File

@ -32,14 +32,14 @@ change_player_tokens_decrement :-
% Gibt den Betrag der Zahl zurück % Gibt den Betrag der Zahl zurück
betrag(Num1, Num2) :- betrag(In, Out) :-
( (
Num1 >= 0, In >= 0,
Num2 is Num1 Out is In
), ! ), !
; ;
( (
Num2 is -Num1 Out is -In
). ).
@ -172,13 +172,14 @@ change_player :-
% game_over ist true wenn das game over ist - surprise surprise % game_over ist true wenn das game over ist - surprise surprise
% Gibt den Gewinner zurück % Gibt den Gewinner zurück
game_over(Winner) :- game_over(Winner) :-
current_player(Active),
inactive_player(Inactive),
( (
current_player(Winner), \+ einheit_active(Inactive,_,_,_,_),
\+ einheit_active(Winner,_,_,_,_) Winner is Active, !
), !; ;
( \+ einheit_active(Active,_,_,_,_),
inactive_player(Winner), Winner is Inactive
\+ einheit_active(Winner,_,_,_,_)
). ).
@ -226,14 +227,19 @@ calc_tokens(Tokens) :-
current_player(Player), current_player(Player),
% Tokens die Pro Runde dazukommen herausfinden % Tokens die Pro Runde dazukommen herausfinden
player_tokens_per_turn(Player,Tturn), player_tokens_per_turn(Player, Tbase),
% Tokens aus der letzten und vorletzten Runde holen % Tokens aus der letzten (aktuellen) und vorletzten Runde holen
last_turn(LastTurn), last_turn(LastTurn),
PreLastTurn is LastTurn - 1, PreLastTurn is LastTurn - 1,
player_turn(Player, LastTurn, Tlast),
player_turn(Player, LastTurn, Tlast),
player_turn(Player, PreLastTurn, Tprelast), player_turn(Player, PreLastTurn, Tprelast),
% Neue Anzahl der Tokens ausgeben % Neue Anzahl der Tokens berechnen
Tokens is Tlast + Tturn - Tprelast. (
Tlast > Tbase,
Tokens is 2 * Tbase, !
;
Tokens is Tlast + Tbase
).