`
turingfellow
  • 浏览: 135369 次
  • 性别: Icon_minigender_1
  • 来自: 福建省莆田市
社区版块
存档分类
最新评论

Dealer.agent.xml

    博客分类:
  • jade
阅读更多
<!--
<H3>The blackjack dealer controls the game.</H3>

The dealer registers itself at the DirectoryFacilitator
and waits for player agents to join the table.
-->
<agent xmlns="http://jadex.sourceforge.net/jadex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jadex.sourceforge.net/jadex
                    http://jadex.sourceforge.net/jadex-0.96.xsd"
name="Dealer"
package="jadex.examples.blackjack.dealer">

<imports>
<import>jadex.examples.blackjack.*</import>
<import>jadex.examples.blackjack.gui.*</import>
<import>jadex.runtime.*</import>
<import>jadex.planlib.*</import>
<import>jadex.util.*</import>
<import>jadex.adapter.fipa.*</import>
<import>java.util.logging.*</import>
<import>java.util.*</import>
</imports>

<capabilities>
<!-- this capability provides easy access to "out-of-the-box"-plans
allowing - for example - to register at the DF. -->
<capability name="dfcap" file="jadex.planlib.DF"/>
</capabilities>

<!--
     These are the dealers beliefs. None of these beliefs should be edited in the ADF
     because all beliefs are initialised by the plans during the game or have
     expedient start-up values (like the three beliefs below).
-->
<beliefs>
<!-- The card set used to play the game. -->
<belief name="cardset" class="CardSet" />

<!-- The number of seconds to wait for answers from players. -->
<belief name="playerwaitmillis" class="long">
<fact>(Integer)$propertybase.getProperty("standard.timeout")</fact>
</belief>

<!-- The number of seconds to wait before drawing a card.
Can be adjusted in the GUI. -->
<belief name="stepdelay" class="int">
<fact>1</fact>
</belief>

<!-- When set to true, each step in the game must be manually
issued in the GUI. -->
<belief name="singleStepMode" class="boolean">
<fact>false</fact>
</belief>

<!-- The self representation of the dealer. -->
<belief name="myself" class="Dealer">
<fact>new Dealer()</fact>
</belief>

<!-- The players. -->
<beliefset name="players" class="Player"/>

<!-- The history of played games. -->
<belief name="statistics" class="GameStatistics">
<fact>new GameStatistics()</fact>
</belief>

<belief name="gamestate" class="GameState">
<fact>new GameState($beliefbase.myself, null)</fact>
</belief>

<belief name="gui" class="DealerFrame"/>

<!--
It's possible that a few different manager (possibly from remote Players)
want to track their players during the game, therefor a beliefset containing
all manager-AIDs is needed.
-->
<beliefset name="tracker" class="AgentIdentifier"/>

</beliefs>

<!--
     The dealer has only one initial goal: registering a
     dealing-service at the DF and renew this registration
     every 10 seconds.
-->
<goals>
<!-- Main goal to play a game. -->
<performgoal name="play_game" exclude="never" retrydelay="3000">
<contextcondition>
$beliefbase.players.length > 0
</contextcondition>
</performgoal>

<!-- Goal to play with a single player (in the context of a larger game). -->
<performgoal name="play_with_player">
<parameter name="player" class="Player"/>
</performgoal>

<!-- Used for registering the dealer at the df. -->
<achievegoalref name="df_register">
<concrete ref="dfcap.df_register"/>
</achievegoalref>
<!-- Used for deregistering the dealer at the df. -->
<achievegoalref name="df_deregister">
<concrete ref="dfcap.df_deregister"/>
</achievegoalref>
</goals>

<!--
     These are all the plans, the dealer will execute during a game.
     There is one plan for every major task. Have a look into the
     plan-classes to get a detailed insight in whats going on there.
-->
<plans>
<!-- Register a player. -->
<plan name="register_plan">
<body class="DealerRegisterPlayerPlan" />
<!-- <body>new DealerRegisterPlayerPlan()</body>-->
<trigger>
<messageevent ref="request_join" />
</trigger>
</plan>

<!-- Play a game. -->
<plan name="play_game_plan">
<body class="DealerGameRoundMasterPlan" />
<!-- <body>new DealerGameRoundMasterPlan()</body> -->
<trigger>
<goal ref="play_game"/>
</trigger>
</plan>

<!-- Play a game with a single player. -->
<plan name="play_with_player_plan">
<parameter name="player" class="Player">
<goalmapping ref="play_with_player.player"/>
</parameter>
<body class="DealerGameRoundPlayerPlan" />
<!-- <body>new DealerGameRoundPlayerPlan()</body>-->
<trigger>
<goal ref="play_with_player"/>
</trigger>
<!-- <contextcondition>
$beliefbase.getBeliefSet("players").containsFact($plan.player)
&amp;&amp; !$plan.player.getState().equals(Player.STATE_IDLE)
</contextcondition>-->
<contextcondition>
$beliefbase.getBeliefSet("players").containsFact($plan.player)
&amp;&amp; !$plan.player.getState().equals(Player.STATE_IDLE)
</contextcondition>
</plan>

<plan name="propagate_game_state_plan">
<body class="PropagateGameStatePlan" />
<!-- <body>new PropagateGameStatePlan()</body> -->
<trigger>
<beliefchange ref="myself"/>
<beliefsetchange ref="players"/>
</trigger>
<!-- not possible because game must always be updated. -->
<!--<precondition>$beliefbase.players.length>0</precondition>-->
</plan>
</plans>

<!-- events -->
<events>

<!-- Event to trigger a step. -->
<internalevent name="step"/>

<!-- player messages -->
<!-- Player request to join the game. -->
<messageevent name="request_join" direction="receive" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.REQUEST</value>
</parameter>
<parameter name="language" class="String" direction="fixed">
<value>SFipa.NUGGETS_XML</value>
</parameter>
<parameter name="ontology" class="String" direction="fixed">
<value>BlackjackOntology.ONTOLOGY_NAME</value>
</parameter>
<parameter name="content-class" class="Class" direction="fixed">
<value>RequestJoin.class</value>
</parameter>
</messageevent>

<!-- A player wants to draw another card. -->
<messageevent name="request_draw" direction="receive" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.REQUEST</value>
</parameter>
<parameter name="language" class="String" direction="fixed">
<value>SFipa.NUGGETS_XML</value>
</parameter>
<parameter name="ontology" class="String" direction="fixed">
<value>BlackjackOntology.ONTOLOGY_NAME</value>
</parameter>
<parameter name="content-class" class="Class" direction="fixed">
<value>RequestDraw.class</value>
</parameter>
</messageevent>

<!-- A player makes a bet. -->
<messageevent name="request_bet" direction="send" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.REQUEST</value>
</parameter>
<parameter name="language" class="String" direction="fixed">
<value>SFipa.NUGGETS_XML</value>
</parameter>
<parameter name="ontology" class="String" direction="fixed">
<value>BlackjackOntology.ONTOLOGY_NAME</value>
</parameter>
<!--<parameter name="reply-with" class="String" direction="inout">
<value>SFipa.createUniqueId($scope.getAgentName())</value>
</parameter>-->
<parameter name="conversation-id" class="String" direction="inout">
<value>SFipa.createUniqueId($scope.getAgentName())</value>
</parameter>
<parameter name="content-class" class="Class" direction="fixed">
<value>RequestBet.class</value>
</parameter>
</messageevent>


<messageevent name="refuse_bet" direction="receive" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.REFUSE</value>
</parameter>
<parameter name="language" class="String" direction="fixed">
<value>SFipa.NUGGETS_XML</value>
</parameter>
<parameter name="ontology" class="String" direction="fixed">
<value>BlackjackOntology.ONTOLOGY_NAME</value>
</parameter>
<parameter name="content-class" class="Class" direction="fixed">
<value>RequestBet.class</value>
</parameter>
</messageevent>

<!-- A player has finished its game (i.e. doesn't want to draw any more cards). -->
<messageevent name="request_finished" direction="receive" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.REQUEST</value>
</parameter>
<parameter name="language" class="String" direction="fixed">
<value>SFipa.NUGGETS_XML</value>
</parameter>
<parameter name="ontology" class="String" direction="fixed">
<value>BlackjackOntology.ONTOLOGY_NAME</value>
</parameter>
<parameter name="content-class" class="Class" direction="fixed">
<value>RequestFinished.class</value>
</parameter>
</messageevent>

<!-- todo: manager messages -->

<!-- The manager is shutting down the BlackJack application. -->
<messageevent name="inform_shutdown" direction="receive" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.INFORM</value>
</parameter>
<parameter name="content-start" class="String" direction="fixed">
<value>"manager:shutDown"</value>
</parameter>
</messageevent>
<!-- The manager registers as tracker on game settings. -->
<messageevent name="query_tracking" direction="receive" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.QUERY_REF</value>
</parameter>
<parameter name="content-start" class="String" direction="fixed">
<value>"manager:registerAsTracker"</value>
</parameter>
</messageevent>

<!-- sent messages -->

<!-- inform a player about a the game result -->
<messageevent name="inform_action_done" direction="send_receive" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.INFORM</value>
</parameter>
<parameter name="language" class="String" direction="fixed">
<value>SFipa.NUGGETS_XML</value>
</parameter>
<parameter name="ontology" class="String" direction="fixed">
<value>BlackjackOntology.ONTOLOGY_NAME</value>
</parameter>
<parameter name="content-class" class="Class" direction="fixed">
<value>Done.class</value>
</parameter>
</messageevent>

<!-- inform a player about a the game result -->
<messageevent name="refuse_action" direction="send" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.REFUSE</value>
</parameter>
<parameter name="language" class="String" direction="fixed">
<value>SFipa.NUGGETS_XML</value>
</parameter>
<parameter name="ontology" class="String" direction="fixed">
<value>BlackjackOntology.ONTOLOGY_NAME</value>
</parameter>
</messageevent>

<!-- inform tracker about playing players -->
<messageevent name="inform_tracker" direction="send" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.INFORM</value>
</parameter>
<parameter name="content" class="String" direction="in" />
</messageevent>

<messageevent name="inform_game_state" direction="send" type="fipa">
<parameter name="performative" class="String" direction="fixed">
<value>SFipa.INFORM</value>
</parameter>
<parameter name="language" class="String" direction="fixed">
<value>SFipa.NUGGETS_XML</value>
</parameter>
<parameter name="ontology" class="String" direction="fixed">
<value>BlackjackOntology.ONTOLOGY_NAME</value>
</parameter>
<parameter name="conversation-id" class="String" direction="inout">
<value>SFipa.createUniqueId($scope.getAgentName())</value>
</parameter>
<parameter name="content-class" class="Class" direction="fixed">
<value>GameState.class</value>
</parameter>
</messageevent>

</events>

<expressions>

<!-- The player that gets the next card (if any). -->
<expression name="turnplayer">
select one Player $p from $beliefbase.players
where $p.getState().equals(Player.STATE_PLAYING)
order by $p.getCards().length
</expression>

<!-- Check if it is the dealer's turn. -->
<condition name="dealers_turn">
// The dealer may draw its initial card when all players have two cards.
$beliefbase.myself.getCards().length==0 &amp;&amp;
(select one Player $p from $beliefbase.players
where !$p.getState().equals(Player.STATE_IDLE) &amp;&amp; $p.getCards().length!=2)
== null

// The dealer may draw more cards, when all players are either idle or finished.
|| (select one Player $p from $beliefbase.players
where !$p.getState().equals(Player.STATE_IDLE) &amp;&amp; !$p.getState().equals(Player.STATE_FINISHED))
== null
</condition>

<!-- Check if it is the $player's turn. -->
<condition name="players_turn">
// All players must be idle, playing, or finished.
(select one Player $p from $beliefbase.players
where !$p.getState().equals(Player.STATE_IDLE)
&amp;&amp; !$p.getState().equals(Player.STATE_PLAYING)
&amp;&amp; !$p.getState().equals(Player.STATE_FINISHED))
== null

// And this player must be the first with the least number of cards.
// Hack !!! Assume "any" selects players in order.
&amp;&amp; (select one Player $p from $beliefbase.players
where $p.getState().equals(Player.STATE_PLAYING)
&amp;&amp; $p.getCards().length&lt;=$player.getCards().length
order by $p.getCards().length)
== $player
<parameter name="$player" class="Player"/>
</condition>

<!-- Check if the dealer has drawn its first card. -->
<condition name="dealer_card">
$beliefbase.myself.getCards().length==1
</condition>

<!-- Check if the dealer has finished drawing cards. -->
<condition name="dealer_finished">
$beliefbase.myself.getState().equals(Player.STATE_FINISHED)
|| $beliefbase.myself.getState().equals(Player.STATE_IDLE)
</condition>

</expressions>

<properties>
<!--  logging-properties, needed to debug the application.
     Start the Jadex-Logging-Agent to see whats going on behind the scenes -->
<!--<property name="logging.level">Level.INFO</property>-->
</properties>

<configurations>
<configuration name="default">
<beliefs>
<initialbelief ref="gui">
<fact>new DealerFrame($beliefbase.myself, $agent.getExternalAccess())</fact>
</initialbelief>
</beliefs>
<goals>
<!-- Register the dealer at the df on startup. -->
<initialgoal ref="df_register">
<!-- The services to register. -->
<parameter ref="description">
<value>
<!-- This is the agent-description for the dealer. With this description
     the dealers is registered at the directory facilitator.
     Note, that the dealer only offers one service, that is 'dealing'
     (see service description below). -->
SFipa.createAgentDescription(null,
SFipa.createServiceDescription("dealing", "blackjack", "University of Hamburg"))
</value>
</parameter>
</initialgoal>
<initialgoal ref="play_game"/>
<endgoal ref="df_deregister"/>
</goals>
</configuration>
</configurations>

</agent>

分享到:
评论

相关推荐

    Linux环境安装FastDFS及整合Nginx遇到的bug及解决方法

    问题1: ERROR – file: storage_ip_changed_dealer.c, line: 163, connect to tracker server xx.xx.xx.xx:22122 fail, errno: 4, error info: Interrupted system call 或ERROR – file: storage_ip_changed_...

    iLabelChina(Dealer).rar

    《iLabelChina(Dealer)——打造专业电子秤标签设计与打印解决方案》 iLabelChina(Dealer)是一款专为经销商设计的电子秤标签格式设置软件,它集成了丰富的模板和强大的编辑功能,旨在帮助用户轻松创建符合业务需求的...

    soap-proxy:gRPC-Go中的SOAP代理,以及从.proto文件生成WSDL的protoc-gen-wsdl

    将创建myproxy/dealer.wsdl和myproxy/dealer.wsdl.go 。 2.生成客户端代码 使用 : protoc --grpcer_out=myproxy -I $GOPATH/src $GOPATH/src/unosoft.hu/ws/bruno/pb/dealer/dealer.proto 将创建myproxy/dealer....

    zeromq中负载均衡模式的jave实现

    dealer.connect("tcp://localhost:5555"); // 发送消息 for (int i = 0; i ; i++) { dealer.sendMore("Task"); // 额外的前缀,用于标识消息类型 dealer.send(String.valueOf(i)); } context.close(); ...

    FastDFS Storage端配置文件详解及启动注意事项

    《FastDFS Storage端配置文件详解及启动注意事项》 FastDFS是一款开源的高性能、轻量级的分布式文件系统,主要用于解决大容量存储和负载均衡的问题。本文将深入解析FastDFS的Storage端配置文件`storage.conf`,并...

    fastdfs-6.9.5.tar.gz

    git官网版,供无法用git下载的使用,liunx使用。 FastDFS(Fast Distributed File System)是一个开源的轻量级分布式文件系统,主要用于文件存储和访问。它以高性能和高可靠性为目标,特别适用于一些需要大规模文件...

    dealer_12864_

    据此可以推测,“dealer.info”文件很可能包含有关编号12864的经销商详细资料,诸如联系信息、服务条款、产品目录、系统要求,以及与该经销商相关的业务操作说明等。 综合以上信息,虽然无法从描述中直接获取具体的...

    dwr实战

    以下是`Dealer.java`和`Monitor.java`的简要示例: **Dealer.java** ```java package com.vstsoft.dataimport.dto; public class Dealer { // 属性与方法... } ``` **Monitor.java** ```java package ...

    施乐DocuPrint P M105 205 158 维修手册(Dealer).pdf

    施乐DocuPrint P M105、M205b、M158ab、M158b、M158f、P105b、P158b、P205b系列打印机是施乐公司生产的一系列产品,该系列设备以其高效率和多功能性而闻名。从提供的文件内容中,我们可以了解到这些设备的维护和修理...

    zeromq-4.1.5.zip

     Ø  Smart patterns like pub-sub, push-pull, and router-dealer.  Ø  High-speed asynchronous I/O engines, in a tiny library.  Ø  Backed by a large and active open source community.  Ø  ...

    大泉州汽车网整站程序PHP生成html开源版 V2018.1.1

    车行:dealer.html 车商:带shop_ V2018.1.1 此版是根据网上某二手车修改而成,已经原版修正很多错误,增加了新车等栏目.并增加安全性,请放心使用. 官方: 大泉州汽车网:http://www.xqzqc.com/ 南安汽车网:...

    毕博咨询报告-Driving Change in the dealer IT Enviorment.zip

    【标题】"毕博咨询报告-Driving Change in the dealer IT Enviorment.zip" 提供的是一份关于汽车经销商IT环境变革的专业报告。这份报告聚焦于如何推动汽车销售行业的经销商在信息技术(IT)环境中进行有效变革,以...

    SPSx81 User Guide

    your local Trimble dealer. Bluetooth and 900 MHz radio-modems operate in license-free bands. Before operating an SPSx81 Smart GPS antenna, determine if authorization or a license to operate the unit ...

    zeromq-4.2.1

     Ø  Smart patterns like pub-sub, push-pull, and router-dealer.  Ø  High-speed asynchronous I/O engines, in a tiny library.  Ø  Backed by a large and active open source community.  Ø  ...

    dwr入门例子 包含类型转换

    `Dealer`类的实例可以通过`bean`转换器自动映射到JavaScript对象,而`Monitor`类的方法如`setDealers`和`setDealersMap`允许接收`List&lt;Dealer&gt;`和`Map, Dealer&gt;`类型的参数。 接下来,让我们看看具体的Java类。`...

    二十一点

    console.log(`${this.dealer.name}'s hand: ${this.dealer.hand.map(card =&gt; `${card.value}${card.suit}`).join(', ')} (${this.dealer.score})`); if (this.dealer.score &gt; 21) { console.log(`${this.dealer....

    C# 21点扑克牌游戏【发牌、要牌、玩家停牌】

    dealer.Hand.Add(deck.Draw()); } } // 省略WantsToHit方法和显示结果的代码 } ``` 至此,我们已经构建了一个基本的21点游戏框架。玩家可以通过选择是否要牌来控制其手牌的点数,直到达到满意的结果或超过21点...

Global site tag (gtag.js) - Google Analytics