From 8c9993c1724fb82ae26540937279959fa6032744 Mon Sep 17 00:00:00 2001 From: Maximilian Wagner Date: Fri, 23 Jun 2023 17:02:49 +0200 Subject: [PATCH] calc_tokens changes --- daten.pl | 2 +- debug.pl | 20 ++++++++++++++++++++ logik.pl | 38 ++++++++++++++++++++++---------------- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/daten.pl b/daten.pl index a862a20..0eeb6af 100644 --- a/daten.pl +++ b/daten.pl @@ -69,7 +69,7 @@ init_feld1 :- reset_game :- abolish(feld/3), abolish(einheit_active/4), - abolish(current_player/1), + change_player_to(1), abolish(game_window/1), abolish(game_table/1), abolish(game_control/1), diff --git a/debug.pl b/debug.pl index 5930c9e..cf86d8a 100644 --- a/debug.pl +++ b/debug.pl @@ -5,6 +5,26 @@ debug_init :- init_player2(infantry,infantry,infantry), 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) :- write("-------"),nl, write("Type: "), diff --git a/logik.pl b/logik.pl index 42d3259..f8d1bb5 100644 --- a/logik.pl +++ b/logik.pl @@ -32,14 +32,14 @@ change_player_tokens_decrement :- % Gibt den Betrag der Zahl zurück -betrag(Num1, Num2) :- +betrag(In, Out) :- ( - Num1 >= 0, - Num2 is Num1 + In >= 0, + 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 % Gibt den Gewinner zurück game_over(Winner) :- + current_player(Active), + inactive_player(Inactive), ( - current_player(Winner), - \+ einheit_active(Winner,_,_,_,_) - ), !; - ( - inactive_player(Winner), - \+ einheit_active(Winner,_,_,_,_) + \+ einheit_active(Inactive,_,_,_,_), + Winner is Active, ! + ; + \+ einheit_active(Active,_,_,_,_), + Winner is Inactive ). @@ -226,14 +227,19 @@ calc_tokens(Tokens) :- current_player(Player), % 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), PreLastTurn is LastTurn - 1, - - player_turn(Player, LastTurn, Tlast), + player_turn(Player, LastTurn, Tlast), player_turn(Player, PreLastTurn, Tprelast), - % Neue Anzahl der Tokens ausgeben - Tokens is Tlast + Tturn - Tprelast. + % Neue Anzahl der Tokens berechnen + ( + Tlast > Tbase, + Tokens is 2 * Tbase, ! + ; + Tokens is Tlast + Tbase + ). +