Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
C
CaptainSonOz
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Vany Ingenzi
CaptainSonOz
Validations
5de7f09b
Valider
5de7f09b
rédigé
3 years ago
par
Vany Ingenzi
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Working randomPlayers with some bigs yet to fix
parent
cdf83b01
Branches
revert-2ae6d755
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
Main.oz
+17
-13
17 ajouts, 13 suppressions
Main.oz
Player000Basic.oz
+226
-23
226 ajouts, 23 suppressions
Player000Basic.oz
Player001Basic.oz
+234
-17
234 ajouts, 17 suppressions
Player001Basic.oz
avec
477 ajouts
et
53 suppressions
Main.oz
+
17
−
13
Voir le fichier @
5de7f09b
...
@@ -32,7 +32,7 @@ define
...
@@ -32,7 +32,7 @@ define
end
end
fun {ModifyOnlyCurrent Players Current F}
fun {ModifyOnlyCurrent Players Current F}
{List.
M
ap Players fun{$ Player} if Player==Current then {F Player} else Player end end}
{List.
m
ap Players fun{$ Player} if Player==Current then {F Player} else Player end end}
end
end
%% NextPlayers : The next players to play
%% NextPlayers : The next players to play
...
@@ -72,6 +72,7 @@ define
...
@@ -72,6 +72,7 @@ define
case Players of nil then skip
case Players of nil then skip
[] Player|OtherPlayers then
[] Player|OtherPlayers then
{Send Player.port Msg}
{Send Player.port Msg}
{Broadcast OtherPlayers Msg}
end
end
end
end
...
@@ -94,7 +95,7 @@ define
...
@@ -94,7 +95,7 @@ define
{Send Player.port sayMissileExplode(Id Position Resp)}
{Send Player.port sayMissileExplode(Id Position Resp)}
case Resp of null then skip
case Resp of null then skip
[] sayDeath(ID) then
[] sayDeath(ID) then
{Send GUI_PORT
lifeUpdate
(ID
0
)}
{Send GUI_PORT
removePlayer
(ID)}
{Broadcast Players Resp}
{Broadcast Players Resp}
[] sayDamageTaken(ID Damage LifeLeft) then
[] sayDamageTaken(ID Damage LifeLeft) then
{Send GUI_PORT lifeUpdate(ID LifeLeft)}
{Send GUI_PORT lifeUpdate(ID LifeLeft)}
...
@@ -105,16 +106,17 @@ define
...
@@ -105,16 +106,17 @@ define
proc{ManagingDroneFiring Players SenderPlayer Drone}
proc{ManagingDroneFiring Players SenderPlayer Drone}
{List.forAll Players proc{$ Player} ID Resp in
{List.forAll Players
proc{$ Player} ID Resp in
{Send Player.port sayPassingDrone(Drone ID Resp)}
{Send Player.port sayPassingDrone(Drone ID Resp)}
{Send SenderPlayer.port Resp}
{Send SenderPlayer.port
sayAnswerDrone(Drone ID
Resp
)
}
end}
end}
end
end
proc{ManagingSonarFiring Players SenderPlayer}
proc{ManagingSonarFiring Players SenderPlayer}
{List.forAll Players proc{$ Player} ID Resp in
{List.forAll Players proc{$ Player} ID Resp in
{Send Player.port sayPassingSonar(ID Resp)}
{Send Player.port sayPassingSonar(ID Resp)}
{Send SenderPlayer.port Resp} end}
{Send SenderPlayer.port sayAnswerSonar(ID Resp)}
end}
end
end
fun {TurnByTurn345 Players CurrentIndex Next}
fun {TurnByTurn345 Players CurrentIndex Next}
...
@@ -127,33 +129,35 @@ define
...
@@ -127,33 +129,35 @@ define
of surface then
of surface then
NewPlayers={ModifyOnlyCurrent Players CurrentPlayer SetNbSurfaceOne}
NewPlayers={ModifyOnlyCurrent Players CurrentPlayer SetNbSurfaceOne}
{Broadcast NewPlayers saySurface(ID)} {Send GUI_PORT surface(ID)}
{Broadcast NewPlayers saySurface(ID)} {Send GUI_PORT surface(ID)}
Next=9 NewPlayers
Next=9
NewPlayers
else
else
{Broadcast Players sayMove(ID Direction)}
{Broadcast Players sayMove(ID Direction)}
{Send GUI_PORT movePlayer(ID Pos)}
{Send GUI_PORT movePlayer(ID Pos)}
Next=6 Players
Next=6
Players
end
end
end
end
proc {TurnByTurn6 Players CurrentIndex}
proc {TurnByTurn6 Players CurrentIndex}
CurrentPlayer=Players
.
CurrentIndex
CurrentPlayer=
{List.nth
Players
CurrentIndex
}
ID KindItem
ID KindItem
in
in
{Send CurrentPlayer.port chargeItem(ID KindItem)}
{Send CurrentPlayer.port chargeItem(ID KindItem)}
case KindItem of null then skip
case KindItem of null then skip
else
else
{Broadcast Players sayCharge
d
(ID KindItem)}
{Broadcast Players sayCharge(ID KindItem)}
end
end
end
end
proc {TurnByTurn78 Players CurrentIndex}
proc {TurnByTurn78 Players CurrentIndex}
CurrentPlayer=Players
.
CurrentIndex
CurrentPlayer=
{List.nth
Players
CurrentIndex
}
ID KindFire
ID KindFire
in
in
{Send CurrentPlayer.port fireItem(ID KindFire)}
{Send CurrentPlayer.port fireItem(ID KindFire)}
case KindFire of null then skip
case KindFire of null then skip
[] mine(Position) then Id Mine in
[] mine(Position) then Id Mine in
{Send GUI_PORT put
Item
(ID Position)} {Broadcast Players sayMinePlace(ID)}
{Send GUI_PORT put
Mine
(ID Position)} {Broadcast Players sayMinePlace
d
(ID)}
{Send CurrentPlayer.port fireMine(Id Mine)}
{Send CurrentPlayer.port fireMine(Id Mine)}
case Mine of null then skip %% To Be Studied
case Mine of null then skip %% To Be Studied
else
else
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Player000Basic.oz
+
226
−
23
Voir le fichier @
5de7f09b
...
@@ -106,56 +106,259 @@ define
...
@@ -106,56 +106,259 @@ define
end
end
end
end
fun {GetNewFireItem Item}
fun {GetNew
Charge
FireItem Item}
case Item
case Item
of mine then UndefinedX UndefinedY in Mine({})
of mine then '#'(fireItem:mine({GetRandomPosInWater nil}) charge:0)
[] missile then '#'(fireItem:missile({GetRandomPosInWater nil}) charge:0)
[] drone then Rdm={GetRandomPosInWater nil} in
if {OS.rand} mod 2 == 0 then '#'(fireItem:drone(row Rdm.x) charge:0)
else '#'(fireItem:drone(column Rdm.y) charge:0) end
[] sonar then '#'(fireItem:sonar charge:0)
end
end
fun {CheckFireItemReady '#'(fireItem:FireItem charge:NbCharge)}
Input.{Record.label FireItem}==NbCharge
end
end
fun{HandleChargeItem State chargeItem(ID Item)}
fun{HandleChargeItem State chargeItem(ID Item)}
ToCharge={GetRandomElement State.chargingItems}
AfterCharge={NewRec ToCharge charge ToCharge.charge+1}
NewChargingItems
in
if {CheckFireItemReady AfterCharge} then NewChargingItem={GetNewChargeFireItem {Record.label AfterCharge.fireItem}} in
ID=State.id Item={Record.label AfterCharge.fireItem}
NewChargingItems={List.map State.chargingItems fun{$ Item}
if Item==ToCharge then NewChargingItem
else Item end
end}
{NewRec {NewRec State chargingItems NewChargingItems} chargedItems AfterCharge.fireItem|State.chargedItems}
else
NewChargingItems={List.map State.chargingItems fun{$ Item}
if Item==ToCharge then AfterCharge
else Item end
end}
ID=State.id Item=null
{NewRec State chargingItems NewChargingItems}
end
end
fun {HandleFireItem State fireItem(ID KindFire)}
case State.chargedItems
case State.chargedItems
of nil then FireItem={GetNewFireItem {GetRandomElement AllWeapons}}
of nil then
{NewRec State chargeItems }
ID=State.id KindFire=null
State
elseif {OS.rand} mod 2 == 0 then ToFire={GetRandomElement State.chargedItems} in
ID=State.id KindFire=ToFire
case {Record.label KindFire} of mine then
{NewRec {NewRec State chargedItems {List.subtract State.chargedItems ToFire}} placedMines KindFire|State.placedMines}
else
{NewRec State chargedItems {List.subtract State.chargedItems ToFire}}
end
else
ID=State.id KindFire=null
State
end
end
end
fun{StartPlayer Color ID}
fun{HandleFireMine State fireMine(ID Mine)}
Stream
case State.placedMines
Port
of nil then
ID=State.id Mine=null
State
elseif {OS.rand} mod 2 == 0 then MineToExplode={GetRandomElement State.placedMines} in
ID=State.id Mine=MineToExplode
{NewRec State placedMines {List.subtract State.placedMines MineToExplode}}
else
ID=State.id Mine=null
State
end
end
fun {ManhattanDistance Pos1 Pos2}
{Abs Pos1.x-Pos2.x}+{Abs Pos1.y-Pos2.y}
end
fun {DamageFromMissile MyPos MissilePos}
case {ManhattanDistance MyPos MissilePos}
of 0 then 2
[] 1 then 1
else 0 end
end
fun{HandleExplosion State ID Pos Msg}
Damage={DamageFromMissile State.pos Pos}
in
in
{NewPort Stream Port}
case Damage
thread
of 0 then
{TreatStream Stream '#'(id:id(id:ID color:Color name:name)
Msg=null
pos:pt(x:0 y:0)
State
chargedItems:nil %%[ ... '#'(fireItem:<fireItem> charge:<int>) ... ]
else NewLife={Max 0 State.life-Damage} in
history:nil)}
case NewLife
of 0 then
Msg=sayDeath(State.id.id)
{NewRec State life 0}
else
Msg=sayDamageTaken(State.id.id Damage NewLife)
{NewRec State life NewLife}
end
end
end
proc{DeadTreatStream Stream State}
case Stream
of initPosition(ID Pos)|T then
ID=null
{DeadTreatStream T State}
[] move(ID Pos Direction)|T then
ID=null
{DeadTreatStream T State}
[] dive|T then %% Ignored
{DeadTreatStream T State}
[] saySurface(ID)|T then %% Ignored
{DeadTreatStream T State}
[] sayMove(ID Direct)|T then %% Ignored
ID=null
{DeadTreatStream T State}
[] chargeItem(ID Item)|T then
ID=null
{DeadTreatStream T State}
[] fireItem(ID KindFire)|T then
ID=null
{DeadTreatStream T State}
[] fireMine(ID Mine)|T then
ID=null
{DeadTreatStream T State}
[] sayCharge(ID KindItem)|T then %% Ignored
{DeadTreatStream T State}
[] sayMinePlaced(ID)|T then %% Ignored
{DeadTreatStream T State}
[] sayMissileExplode(ID Pos Msg)|T then
Msg=null
{DeadTreatStream T State}
[] sayMineExplode(ID Pos Msg)|T then
Msg=null
{DeadTreatStream T State}
[] sayPassingDrone(drone(row X) ID Answer)|T then
ID=null
{DeadTreatStream T State}
[] sayPassingDrone(drone(column Y) ID Answer)|T then
ID=null
{DeadTreatStream T State}
[] sayAnswerDrone(Drone ID Answer)|T then %% Ignore
ID=null
{DeadTreatStream T State}
[] sayPassingSonar(ID Resp)|T then
ID=null
{DeadTreatStream T State}
[] sayAnswerSonar(ID Answer)|T then %% Ignore
ID=null
{DeadTreatStream T State}
else
{AliveTreatStream Stream State}
end
end
Port
end
end
proc{TreatStream Stream State}
proc{
Alive
TreatStream Stream State}
case Stream
case Stream
of initPosition(ID Pos)|T then NewState in
of initPosition(ID Pos)|T then NewState in
{System.show 'Player'#State.id.id#'received'#initPosition(ID Pos)}
{System.show 'Player'#State.id.id#'received'#initPosition(ID Pos)}
NewState={HandleInitPosition State initPosition(ID Pos)}
NewState={HandleInitPosition State initPosition(ID Pos)}
{System.show 'Player'#State.id.id#'replied'#initPosition(ID Pos)}
{System.show 'Player'#State.id.id#'replied'#initPosition(ID Pos)}
{TreatStream T NewState}
{
Alive
TreatStream T NewState}
[] move(ID Pos Direction)|T then NewState in
[] move(ID Pos Direction)|T then NewState in
{System.show 'Player'#State.id.id#'received'#move(ID Pos Direction)}
{System.show 'Player'#State.id.id#'received'#move(ID Pos Direction)}
NewState={HandleMove State move(ID Pos Direction)}
NewState={HandleMove State move(ID Pos Direction)}
{System.show 'Player'#State.id.id#'replied'#move(ID Pos Direction)}
{System.show 'Player'#State.id.id#'replied'#move(ID Pos Direction)}
{TreatStream T NewState}
{
Alive
TreatStream T NewState}
[] dive|T then %% Ignored
[] dive|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#dive}
{System.show 'Player'#State.id.id#'received'#dive}
{TreatStream T State}
{
Alive
TreatStream T State}
[] saySurface(ID)|T then %% Ignored
[] saySurface(ID)|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#saySurface(ID)}
{System.show 'Player'#State.id.id#'received'#saySurface(ID)}
{TreatStream T State}
{
Alive
TreatStream T State}
[] sayMove(ID Direct)|T then %% Ignored
[] sayMove(ID Direct)|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#sayMove(ID Direct)}
{System.show 'Player'#State.id.id#'received'#sayMove(ID Direct)}
{TreatStream T State}
{AliveTreatStream T State}
[] chargeItem(ID Item) then
[] chargeItem(ID Item)|T then NewState in
...
{System.show 'Player'#State.id.id#'received'#chargeItem(ID Item)}
NewState={HandleChargeItem State chargeItem(ID Item)}
{System.show 'Player'#State.id.id#'replied'#chargeItem(ID Item)}
{AliveTreatStream T NewState}
[] fireItem(ID KindFire)|T then NewState in
{System.show 'Player'#State.id.id#'received'#fireItem(ID KindFire)}
NewState={HandleFireItem State fireItem(ID KindFire)}
{System.show 'Player'#State.id.id#'replied'#fireItem(ID KindFire)}
{AliveTreatStream T NewState}
[] fireMine(ID Mine)|T then NewState in
{System.show 'Player'#State.id.id#'received'#fireMine(ID Mine)}
NewState={HandleFireMine State fireMine(ID Mine)}
{System.show 'Player'#State.id.id#'replied'#fireMine(ID Mine)}
{AliveTreatStream T NewState}
[] sayCharge(ID KindItem)|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#sayCharge(ID KindItem)}
{AliveTreatStream T State}
[] sayMinePlaced(ID)|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#sayMinePlaced(ID)}
{AliveTreatStream T State}
[] sayMissileExplode(ID Pos Msg)|T then NewState in
{System.show 'Player'#State.id.id#'received'#sayMissileExplode(ID Pos Msg)}
NewState={HandleExplosion State ID Pos Msg}
{System.show 'Player'#State.id.id#'replied'#sayMissileExplode(ID Pos Msg)}
if NewState.life > 0 then {AliveTreatStream T NewState}
else {DeadTreatStream T NewState} end
[] sayMineExplode(ID Pos Msg)|T then NewState in
{System.show 'Player'#State.id.id#'received'#sayMineExplode(ID Pos Msg)}
NewState={HandleExplosion State ID Pos Msg}
{System.show 'Player'#State.id.id#'replied'#sayMineExplode(ID Pos Msg)}
if NewState.life > 0 then {AliveTreatStream T NewState}
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
Answer=State.pos.x==X
{System.show 'Player'#State.id.id#'replied'#sayPassingDrone(drone(row X) ID Answer)}
{AliveTreatStream T State}
[] sayPassingDrone(drone(column Y) ID Answer)|T then
{System.show 'Player'#State.id.id#'received'#sayPassingDrone(drone(column Y) ID Answer)}
ID=State.id.id
Answer=State.pos.y==Y
{System.show 'Player'#State.id.id#'replied'#sayPassingDrone(drone(column Y) ID Answer)}
{AliveTreatStream T State}
[] sayAnswerDrone(Drone ID Answer)|T then %% Ignore
{System.show 'Player'#State.id.id#'received'#sayAnswerDrone(Drone ID Answer)}
{AliveTreatStream T State}
[] sayPassingSonar(ID Resp)|T then
ID=State.id.id Resp=pt(x:State.pos.x y:{Max 0 State.pos.y})
{System.show 'Player'#State.id.id#'received'#sayPassingSonar(ID Resp)}
{AliveTreatStream T State}
[] sayAnswerSonar(ID Answer)|T then %% Ignore
{System.show 'Player'#State.id.id#'received'#sayAnswerSonar(ID Answer)}
{AliveTreatStream T State}
[] sayDamageTaken(ID Damage LifeLeft)|T then %% Ignore
{System.show 'Player'#State.id.id#'received'#sayDamageTaken(ID Damage LifeLeft)}
{AliveTreatStream T State}
else
else
{TreatStream Stream State}
{AliveTreatStream Stream State}
end
end
fun{StartPlayer Color ID}
Stream
Port
in
{NewPort Stream Port}
thread
{AliveTreatStream Stream '#'(id:id(id:ID color:Color name:name)
life:Input.maxDamage
pos:pt(x:0 y:0)
chargingItems:[ {GetNewChargeFireItem mine} {GetNewChargeFireItem missile}
{GetNewChargeFireItem sonar} {GetNewChargeFireItem drone} ]
chargedItems:nil
placedMines:nil
history:nil)}
end
end
Port
end
end
end
end
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
Player001Basic.oz
+
234
−
17
Voir le fichier @
5de7f09b
...
@@ -9,6 +9,7 @@ define
...
@@ -9,6 +9,7 @@ define
StartPlayer
StartPlayer
TreatStream
TreatStream
AllDirections = [east west north south surface]
AllDirections = [east west north south surface]
AllWeapons = [missile sonar drone mine]
fun{NewRec Rec Feature Value}
fun{NewRec Rec Feature Value}
NewRecord={Record.clone Rec}
NewRecord={Record.clone Rec}
...
@@ -105,43 +106,259 @@ define
...
@@ -105,43 +106,259 @@ define
end
end
end
end
fun{StartPlayer Color ID}
fun {GetNewChargeFireItem Item}
Stream
case Item
Port
of mine then '#'(fireItem:mine({GetRandomPosInWater nil}) charge:0)
[] missile then '#'(fireItem:missile({GetRandomPosInWater nil}) charge:0)
[] drone then Rdm={GetRandomPosInWater nil} in
if {OS.rand} mod 2 == 0 then '#'(fireItem:drone(row Rdm.x) charge:0)
else '#'(fireItem:drone(column Rdm.y) charge:0) end
[] sonar then '#'(fireItem:sonar charge:0)
end
end
fun {CheckFireItemReady '#'(fireItem:FireItem charge:NbCharge)}
Input.{Record.label FireItem}==NbCharge
end
fun{HandleChargeItem State chargeItem(ID Item)}
ToCharge={GetRandomElement State.chargingItems}
AfterCharge={NewRec ToCharge charge ToCharge.charge+1}
NewChargingItems
in
if {CheckFireItemReady AfterCharge} then NewChargingItem={GetNewChargeFireItem {Record.label AfterCharge.fireItem}} in
ID=State.id Item={Record.label AfterCharge.fireItem}
NewChargingItems={List.map State.chargingItems fun{$ Item}
if Item==ToCharge then NewChargingItem
else Item end
end}
{NewRec {NewRec State chargingItems NewChargingItems} chargedItems AfterCharge.fireItem|State.chargedItems}
else
NewChargingItems={List.map State.chargingItems fun{$ Item}
if Item==ToCharge then AfterCharge
else Item end
end}
ID=State.id Item=null
{NewRec State chargingItems NewChargingItems}
end
end
fun {HandleFireItem State fireItem(ID KindFire)}
case State.chargedItems
of nil then
ID=State.id KindFire=null
State
elseif {OS.rand} mod 2 == 0 then ToFire={GetRandomElement State.chargedItems} in
ID=State.id KindFire=ToFire
case {Record.label KindFire} of mine then
{NewRec {NewRec State chargedItems {List.subtract State.chargedItems ToFire}} placedMines KindFire|State.placedMines}
else
{NewRec State chargedItems {List.subtract State.chargedItems ToFire}}
end
else
ID=State.id KindFire=null
State
end
end
fun{HandleFireMine State fireMine(ID Mine)}
case State.placedMines
of nil then
ID=State.id Mine=null
State
elseif {OS.rand} mod 2 == 0 then MineToExplode={GetRandomElement State.placedMines} in
ID=State.id Mine=MineToExplode
{NewRec State placedMines {List.subtract State.placedMines MineToExplode}}
else
ID=State.id Mine=null
State
end
end
fun {ManhattanDistance Pos1 Pos2}
{Abs Pos1.x-Pos2.x}+{Abs Pos1.y-Pos2.y}
end
fun {DamageFromMissile MyPos MissilePos}
case {ManhattanDistance MyPos MissilePos}
of 0 then 2
[] 1 then 1
else 0 end
end
fun{HandleExplosion State ID Pos Msg}
Damage={DamageFromMissile State.pos Pos}
in
in
{NewPort Stream Port}
case Damage
thread
of 0 then
{TreatStream Stream '#'(id:id(id:ID color:Color name:name)
Msg=null
pos:pt(x:0 y:0)
State
items:'#'(missile:0 sonar:0 drone:0 mine:0)
else NewLife={Max 0 State.life-Damage} in
history:nil)}
case NewLife
of 0 then
Msg=sayDeath(State.id.id)
{NewRec State life 0}
else
Msg=sayDamageTaken(State.id.id Damage NewLife)
{NewRec State life NewLife}
end
end
end
proc{DeadTreatStream Stream State}
case Stream
of initPosition(ID Pos)|T then
ID=null
{DeadTreatStream T State}
[] move(ID Pos Direction)|T then
ID=null
{DeadTreatStream T State}
[] dive|T then %% Ignored
{DeadTreatStream T State}
[] saySurface(ID)|T then %% Ignored
{DeadTreatStream T State}
[] sayMove(ID Direct)|T then %% Ignored
ID=null
{DeadTreatStream T State}
[] chargeItem(ID Item)|T then
ID=null
{DeadTreatStream T State}
[] fireItem(ID KindFire)|T then
ID=null
{DeadTreatStream T State}
[] fireMine(ID Mine)|T then
ID=null
{DeadTreatStream T State}
[] sayCharge(ID KindItem)|T then %% Ignored
{DeadTreatStream T State}
[] sayMinePlaced(ID)|T then %% Ignored
{DeadTreatStream T State}
[] sayMissileExplode(ID Pos Msg)|T then
Msg=null
{DeadTreatStream T State}
[] sayMineExplode(ID Pos Msg)|T then
Msg=null
{DeadTreatStream T State}
[] sayPassingDrone(drone(row X) ID Answer)|T then
ID=null
{DeadTreatStream T State}
[] sayPassingDrone(drone(column Y) ID Answer)|T then
ID=null
{DeadTreatStream T State}
[] sayAnswerDrone(Drone ID Answer)|T then %% Ignore
ID=null
{DeadTreatStream T State}
[] sayPassingSonar(ID Resp)|T then
ID=null
{DeadTreatStream T State}
[] sayAnswerSonar(ID Answer)|T then %% Ignore
ID=null
{DeadTreatStream T State}
else
{AliveTreatStream Stream State}
end
end
Port
end
end
proc{TreatStream Stream State}
proc{
Alive
TreatStream Stream State}
case Stream
case Stream
of initPosition(ID Pos)|T then NewState in
of initPosition(ID Pos)|T then NewState in
{System.show 'Player'#State.id.id#'received'#initPosition(ID Pos)}
{System.show 'Player'#State.id.id#'received'#initPosition(ID Pos)}
NewState={HandleInitPosition State initPosition(ID Pos)}
NewState={HandleInitPosition State initPosition(ID Pos)}
{System.show 'Player'#State.id.id#'replied'#initPosition(ID Pos)}
{System.show 'Player'#State.id.id#'replied'#initPosition(ID Pos)}
{TreatStream T NewState}
{
Alive
TreatStream T NewState}
[] move(ID Pos Direction)|T then NewState in
[] move(ID Pos Direction)|T then NewState in
{System.show 'Player'#State.id.id#'received'#move(ID Pos Direction)}
{System.show 'Player'#State.id.id#'received'#move(ID Pos Direction)}
NewState={HandleMove State move(ID Pos Direction)}
NewState={HandleMove State move(ID Pos Direction)}
{System.show 'Player'#State.id.id#'replied'#move(ID Pos Direction)}
{System.show 'Player'#State.id.id#'replied'#move(ID Pos Direction)}
{TreatStream T NewState}
{
Alive
TreatStream T NewState}
[] dive|T then %% Ignored
[] dive|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#dive}
{System.show 'Player'#State.id.id#'received'#dive}
{TreatStream T State}
{
Alive
TreatStream T State}
[] saySurface(ID)|T then %% Ignored
[] saySurface(ID)|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#saySurface(ID)}
{System.show 'Player'#State.id.id#'received'#saySurface(ID)}
{TreatStream T State}
{
Alive
TreatStream T State}
[] sayMove(ID Direct)|T then %% Ignored
[] sayMove(ID Direct)|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#sayMove(ID Direct)}
{System.show 'Player'#State.id.id#'received'#sayMove(ID Direct)}
{TreatStream T State}
{AliveTreatStream T State}
[] chargeItem(ID Item)|T then NewState in
{System.show 'Player'#State.id.id#'received'#chargeItem(ID Item)}
NewState={HandleChargeItem State chargeItem(ID Item)}
{System.show 'Player'#State.id.id#'replied'#chargeItem(ID Item)}
{AliveTreatStream T NewState}
[] fireItem(ID KindFire)|T then NewState in
{System.show 'Player'#State.id.id#'received'#fireItem(ID KindFire)}
NewState={HandleFireItem State fireItem(ID KindFire)}
{System.show 'Player'#State.id.id#'replied'#fireItem(ID KindFire)}
{AliveTreatStream T NewState}
[] fireMine(ID Mine)|T then NewState in
{System.show 'Player'#State.id.id#'received'#fireMine(ID Mine)}
NewState={HandleFireMine State fireMine(ID Mine)}
{System.show 'Player'#State.id.id#'replied'#fireMine(ID Mine)}
{AliveTreatStream T NewState}
[] sayCharge(ID KindItem)|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#sayCharge(ID KindItem)}
{AliveTreatStream T State}
[] sayMinePlaced(ID)|T then %% Ignored
{System.show 'Player'#State.id.id#'received'#sayMinePlaced(ID)}
{AliveTreatStream T State}
[] sayMissileExplode(ID Pos Msg)|T then NewState in
{System.show 'Player'#State.id.id#'received'#sayMissileExplode(ID Pos Msg)}
NewState={HandleExplosion State ID Pos Msg}
{System.show 'Player'#State.id.id#'replied'#sayMissileExplode(ID Pos Msg)}
if NewState.life > 0 then {AliveTreatStream T NewState}
else {DeadTreatStream T NewState} end
[] sayMineExplode(ID Pos Msg)|T then NewState in
{System.show 'Player'#State.id.id#'received'#sayMineExplode(ID Pos Msg)}
NewState={HandleExplosion State ID Pos Msg}
{System.show 'Player'#State.id.id#'replied'#sayMineExplode(ID Pos Msg)}
if NewState.life > 0 then {AliveTreatStream T NewState}
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
Answer=State.pos.x==X
{System.show 'Player'#State.id.id#'replied'#sayPassingDrone(drone(row X) ID Answer)}
{AliveTreatStream T State}
[] sayPassingDrone(drone(column Y) ID Answer)|T then
{System.show 'Player'#State.id.id#'received'#sayPassingDrone(drone(column Y) ID Answer)}
ID=State.id.id
Answer=State.pos.y==Y
{System.show 'Player'#State.id.id#'replied'#sayPassingDrone(drone(column Y) ID Answer)}
{AliveTreatStream T State}
[] sayAnswerDrone(Drone ID Answer)|T then %% Ignore
{System.show 'Player'#State.id.id#'received'#sayAnswerDrone(Drone ID Answer)}
{AliveTreatStream T State}
[] sayPassingSonar(ID Resp)|T then
ID=State.id.id Resp=pt(x:State.pos.x y:{Max 0 State.pos.y})
{System.show 'Player'#State.id.id#'received'#sayPassingSonar(ID Resp)}
{AliveTreatStream T State}
[] sayAnswerSonar(ID Answer)|T then %% Ignore
{System.show 'Player'#State.id.id#'received'#sayAnswerSonar(ID Answer)}
{AliveTreatStream T State}
[] sayDamageTaken(ID Damage LifeLeft)|T then %% Ignore
{System.show 'Player'#State.id.id#'received'#sayDamageTaken(ID Damage LifeLeft)}
{AliveTreatStream T State}
else
else
{TreatStream Stream State}
{
Alive
TreatStream Stream State}
end
end
end
end
fun{StartPlayer Color ID}
Stream
Port
in
{NewPort Stream Port}
thread
{AliveTreatStream Stream '#'(id:id(id:ID color:Color name:name)
life:Input.maxDamage
pos:pt(x:0 y:0)
chargingItems:[ {GetNewChargeFireItem mine} {GetNewChargeFireItem missile}
{GetNewChargeFireItem sonar} {GetNewChargeFireItem drone} ]
chargedItems:nil
placedMines:nil
history:nil)}
end
Port
end
end
end
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter