Skip to content
Extraits de code Groupes Projets
Valider 95416266 rédigé par Vany Ingenzi's avatar Vany Ingenzi
Parcourir les fichiers

Added another player but also fixed some bugs in the code

parent 28011ad5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -93,9 +93,9 @@ in
%%%% Players description %%%%
NbPlayers = 2
Players = [player020hunter player020hunter]
Colors = [c(245 88 203) c(255 102 0)]
NbPlayers = 3
Players = [player020hunter player020random player020hiderandseeker]
Colors = [c(245 88 203) c(255 102 0) black]
%%%% Surface time/turns %%%%
......@@ -103,7 +103,7 @@ in
%%%% Life %%%%
MaxDamage = 16
MaxDamage = 4
%%%% Number of load for each item %%%%
......@@ -129,8 +129,8 @@ in
%%%% Description of the map %%%%
NRow = ({OS.rand} mod 10) + (NbPlayers+(NbPlayers div 2))
NColumn = ({OS.rand} mod 10) + (NbPlayers *2)
NRow = ({OS.rand} mod 10) + (NbPlayers *2)
NColumn = ({OS.rand} mod 15) + (NbPlayers *2)
Map = {GenerateMap NRow NColumn nil}
end
\ No newline at end of file
......@@ -144,7 +144,10 @@ define
proc{ManagingDroneFiring Players SenderPlayer Drone}
{List.forAll Players proc{$ Player} ID Resp in
{Send Player.port sayPassingDrone(Drone ID Resp)}
{Send SenderPlayer.port sayAnswerDrone(Drone ID Resp)}
case ID of null then skip
else
{Send SenderPlayer.port sayAnswerDrone(Drone ID Resp)}
end
end}
end
......@@ -363,8 +366,11 @@ in
%%4. Launch the game
if Input.isTurnByTurn then
{TurnByTurn PlayersList 1}
{System.show '----'}
else
{List.forAll PlayersList proc{$ Player} thread {Simultaneous Player PlayersList} end end}
end
%%5. Termination
{List.forAll PlayersList proc{$ Player} {Send Player.port nil} end }
end
Ce diff est replié.
......@@ -97,7 +97,7 @@ define
of surface then
{NewRec {NewRec State pos NewPos} history nil}
else
{NewRec {NewRec State pos NewPos} history Pos|State.history}
{NewRec {NewRec State pos NewPos} history State.pos|State.history}
end
end
......@@ -242,7 +242,7 @@ define
case Enemies of nil then State
[] Enemy|T andthen Enemy.idNum==MovedID.id then UpdatedEnemy PossiblePos in
UpdatedEnemy={NewRec Enemy history MovedDir|Enemy.history}
PossiblePos ={EnemyPossiblePositions 1 1 Enemy.history nil}
PossiblePos ={EnemyPossiblePositions 1 1 UpdatedEnemy.history nil}
if {List.length PossiblePos}==1 then Temp in
Temp={NewRec State enemies {List.append UpdatedEnemy|Acc T}}
{NewRec Temp targets {List.nth PossiblePos 1}|State.targets}
......@@ -256,7 +256,8 @@ define
proc{DeadTreatStream Stream State}
case Stream
of initPosition(ID Pos)|T then
of nil|T then {System.show 'Hunter down'} skip
[] initPosition(ID Pos)|T then
ID=null
{DeadTreatStream T State}
[] move(ID Pos Direction)|T then
......@@ -312,7 +313,8 @@ define
proc{AliveTreatStream Stream State}
case Stream
of initPosition(ID Pos)|T then NewState in
of nil|T then {System.show 'Hunter down'} skip
[] initPosition(ID Pos)|T then NewState in
{System.show 'Player'#State.id.id#'received'#initPosition(ID Pos)}
NewState={HandleInitPosition State initPosition(ID Pos)}
{System.show 'Player'#State.id.id#'replied'#initPosition(ID Pos)}
......@@ -371,7 +373,7 @@ define
else {DeadTreatStream T NewState} end
[] sayPassingDrone(drone(row X) ID Answer)|T then
{System.show 'Player'#State.id.id#'received'#sayPassingDrone(drone(row X) ID Answer)}
ID=State.id.id
ID=State.id
Answer=State.pos.x==X
{System.show 'Player'#State.id.id#'replied'#sayPassingDrone(drone(row X) ID Answer)}
{AliveTreatStream T State}
......
......@@ -97,7 +97,7 @@ define
of surface then
{NewRec {NewRec State pos NewPos} history nil}
else
{NewRec {NewRec State pos NewPos} history Pos|State.history}
{NewRec {NewRec State pos NewPos} history State.pos|State.history}
end
end
......@@ -202,7 +202,8 @@ define
proc{DeadTreatStream Stream State}
case Stream
of initPosition(ID Pos)|T then
of nil|T then {System.show 'Random down'} skip
[] initPosition(ID Pos)|T then
ID=null
{DeadTreatStream T State}
[] move(ID Pos Direction)|T then
......@@ -258,7 +259,8 @@ define
proc{AliveTreatStream Stream State}
case Stream
of initPosition(ID Pos)|T then NewState in
of nil then {System.show 'Random down'} skip skip
[] initPosition(ID Pos)|T then NewState in
{System.show 'Player'#State.id.id#'received'#initPosition(ID Pos)}
NewState={HandleInitPosition State initPosition(ID Pos)}
{System.show 'Player'#State.id.id#'replied'#initPosition(ID Pos)}
......@@ -315,7 +317,7 @@ define
else {DeadTreatStream T NewState} end
[] sayPassingDrone(drone(row X) ID Answer)|T then
{System.show 'Player'#State.id.id#'received'#sayPassingDrone(drone(row X) ID Answer)}
ID=State.id.id
ID=State.id
Answer=State.pos.x==X
{System.show 'Player'#State.id.id#'replied'#sayPassingDrone(drone(row X) ID Answer)}
{AliveTreatStream T State}
......
functor
import
Player020Random
Player020OneAfterOne
Player020HiderAndSeeker
Player020Hunter
Player020Random
export
playerGenerator:PlayerGenerator
define
......@@ -12,8 +12,8 @@ in
case Kind
of player020random then
{Player020Random.portPlayer Color ID}
[] player020oneafterone then
{Player020OneAfterOne.portPlayer Color ID}
[] player020hiderandseeker then
{Player020HiderAndSeeker.portPlayer Color ID}
[] player020hunter then
{Player020Hunter.portPlayer Color ID}
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter