来源:http://aosgrp.com/

Exercise 6

Provide the robot agent with a Painting capability.

Introduction

The capability concept is a means of structuring reasoning elements of agents into 'clusters' that implement selected reasoning capabilities. This technique simplifies agent system design and allows code reuse and encapsulation of agent functionality. In this example, we encapsulate both the set of plans you have written so far and the Paint event into a Painting capability.

Capabilities are described in the Introduction to JACK notes. If necessary, read through the notes before beginning the exercise.

Instructions

1. Add a new design diagram called Painting_DEP. This will be the DEP diagram for a new Painting capability. Then

  • Drag a new capability from the design palette onto the new canvas. Call this new capability Painting and add it to the robot package.
  • Drag the three painting plans from the browser onto the Painting_DEP design diagram.
  • Drag the Paint event from the browser onto the Painting_DEP design diagram.
  • Create links from the Painting capability icon to each of the plans.
  • Create a handles link from the Paint event to the Painting capability.
  • The diagram becomes quite cluttered if we keep the capability on its DEP diagram. It is useful to have it on the diagram to make the links and to check the links. However, when this task is complete, the capability icon can be removed from the diagram without changing the links. This is achieved by using the design tool in Selection mode, selecting the capability icon on the canvas and then selecting the Remove selected objects from diagram button. Use this procedure to remove the capability from the Painting_DEP design diagram. Your Painting_DEP diagram should be similar to the following diagram.

Figure 6: The Painting_DEP design diagram with the PaintSpecifiedCurrentColour, PaintAnyColour and PaintSpecifiedNewColour plans

2. Now that the plans and event are encapsulated in the new capability, we should remove the links from the agent to the plans and declare that the Robot agent has the Painting capability. This can be achieved by:

  • deleting the uses links between the Robot agent and each of the painting plans on the Robot_AD design diagram. Take care that you do not delete the link that corresponds to the #uses interface Robot self declaration in each of the plans. An alternative mechanism for removing the links from the Robot to the plans is to edit the Robot type definition using the Edit as JACK File option.
  • deleting the handles link between the Paint event and the Robot agent on the Robot_AD design diagram.
  • removing the components no longer required on the Robot_AD design diagram (i.e. remove the three painting plans from the design diagram). Your Robot_AD diagram should be similar to the following diagram:

Figure 7: The Robot_AD design diagram with the Robot agent and Paint event

  • creating a new design canvas called Robot_cap_hier, dragging the Robot agent and Painting capability onto the new design diagram, then creating a has link from the Robot agent to the Painting capability. The Robot_cap_hier should appear similar to the following diagram:

Figure 8: The Robot_cap_hier design diagram with the Robot agent and Painting capability

3. Edit the Painting capability and check that the #uses plan declarations are declared in the the following order:

#uses plan PaintSpecifiedCurrentColour;

#uses plan PaintSpecifiedNewColour;

#uses plan PaintAnyColour;

This is the same order as they were previously declared in the agent declaration. If editing the file as a JACK file, save and close the file before continuing.

4. Save the project.

5. Compile and run the application. Check that the output is correct. It should be similar to the following:

test with red

Painting part the requested colour: red

PaintSpecifiedNewColour plan failed

painting the part the current colour: red

test with no specified colour

No specified colour. Painting the part red

test with green

Painting part the requested colour (1st coat) green

PaintSpecifiedNewColour plan failed

painting the part the current colour: green

test with green again

painting the part the current colour: green

示例程序

运行结果:

(1) test with red

(2) Painting part the requested colour (1st coat) red

(3) PaintSpecifiedNewColour plan failed

(4) Painting the part the requested colour: red

(5) test with no specified colour (null)

(6) No specified colour. Painting the part: red

(7) test with green

(8) Painting part the requested colour (1st coat) green

(9) PaintSpecifiedNewColour plan failed

(10) Painting the part the requested colour: green

(11) test with green again

(12) Painting the part the requested colour: green

转载于:https://www.cnblogs.com/6DAN_HUST/archive/2011/06/10/2077412.html

JACK——PaintRobot Exercise6相关推荐

  1. JACK——PaintRobot Exercise9

    来源:http://aosgrp.com/ Exercise 9 Modify the behaviour of the robot agent so that painting takes a sp ...

  2. JACK——AgentManual5 Events

    来源:http://aosgrp.com/ 5 Events 5.1 What are Events? Events motivate an agent to take action. There a ...

  3. 【心情】期待 Mr. Jack In New York!

    在06版的Mr. Jack里面有八个人物,一个玩家代表Jack,同时也是这八个人之一,只有他自己才知道Jack的真正身份,他的目的是尽快逃出伦敦街区(或者在八个回合里没有被福尔摩斯抓到).另一个玩家代 ...

  4. android 关闭jack_Android7.0 配置JACK支持多用户同时编译

    # Android7.0 配置JACK支持多用户同时编译 reference: 背景 需要在一个Android7平台上进行有关的工作,但是编译的时候发现有问题.记录一下.因为和同事共用一台服务器,因为 ...

  5. html5与原生混合模式开发,HTML5与混合模式开发与Native的关系及其实现[张振华.Jack].pdf...

    H5 与 Native 交互的实现 抛砖引玉让大家有个大致的了解和方向不至于蒙圈 张振华.Jack QQ:494460705 Mail:zhangzhenhua846@126.com 2015年6月 ...

  6. 高性能计算专家Jack Dongarra获2021年图灵奖

    "我是一个数学家,对我来说,一切都是线性代数,但世界也正在看到这一点,"Jack Dongarra在采访中表示."这是我们用来建造其它东西的材料."他说,机器学 ...

  7. 2021年图灵奖,花落高性能计算先驱、田纳西大学教授Jack Dongarra

    来源:智源社区 "我是一个数学家,对我来说,一切都是线性代数,但世界也正在看到这一点,"Jack Dongarra在采访中表示."这是我们用来建造其它东西的材料.&quo ...

  8. 图灵奖公布:高性能计算先驱、为超算铺平道路的Jack Dongarra获奖

    3月30日,美国计算机协会(ACM)将2021年的图灵奖授予美国田纳西大学电气工程和计算机科学系特聘教授.现年71岁的Jack J.Dongarra,表彰他在数值算法和工具库方面的开创性贡献,使高性能 ...

  9. android jack log,Android:JACK编译错误汇总及解决

    jack server交互命令: jack-admin start-server jack-admin kill-server jack-admin list-server jack-admin un ...

  10. bestcoder #67 div2 1003 Black Jack 概率dp

    Black Jack  Accepts: 0  Submissions: 61  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536 ...

最新文章

  1. C# 汉字转拼音(全拼)
  2. 安徽计算机应用基础高考试题,安徽省对口高考试题(计算机应用基础部分)
  3. 定制Ocelot来满足需求
  4. 计算机图形学试题a卷,计算机图形学复习题及答案
  5. python对比两个文件找出不同并显示_python difflib模块实现两个文件差异对比,并输出html格式。...
  6. spark 提交至yarn异常超时 Client cannot authenticate via:[TOKEN, KERBEROS]
  7. 7-1 目录7-2 什么是主从复制
  8. 一行代码解决各种IE兼容问题,IE6,IE7,IE8,IE9,IE10 (转)
  9. 大数据处理系统关键层次架构
  10. python基础知识 01
  11. 基于 Retinex 的几种图像增强算法总结
  12. PHP+Swoole实现微信小程序客服即时通信聊天功能
  13. Java多线程编程模式实战指南(一):Active Object模式--转载
  14. C语言 getchar()原理及易错点解析
  15. windows使用备忘录
  16. 将淘宝客数据导入自己的数据库
  17. 200 件实物,从过往的平面设计窥视上海的变化
  18. 北理工python程序设计学习笔记——(三)turtle八边形绘制
  19. 油溶性InP/ZnS高亮绿光和红光PL490nm-750nm
  20. 什么是CAD的模型和布局?

热门文章

  1. Moss网站在不同服务器的迁移
  2. oracle用UNION-ALL 替换UNION ( 如果有可能的话)
  3. 使用 Selenium开展Web测试
  4. 微服务 第八章 SpringBoot多数据源的配置(通过Spring Data JPA 的方式)
  5. MySQL错误Another MySQL daemon already running with the same unix socket.
  6. 第二章、使用变量、操作符和表达式
  7. mydbtest文档
  8. havok之shape
  9. iPhone开发 No IB UITextField 设置圆角
  10. 3.2亿人每天都在刷抖音,而他们却看这几个公众号!