ITeye博客

blocksworld.java

turingfellow · 2010-08-02 22:53 · jade · 编程语言 · Markdown

<imports>
	<import>jadex.runtime.*</import>
	<import>jadex.runtime.impl.*</import>
	<import>jadex.*</import>
	<import>java.awt.Color</import>
</imports>

<beliefs>
	<!-- The stack mode, can be normal, step or slow. -->
	<belief name="mode" class="String">
		<fact>StackBlocksPlan.MODE_NORMAL</fact>
	</belief>
	<!-- The flag for turning on/off output. -->
	<belief name="quiet" class="boolean" />
	<!-- The table for the blocks.-->
	<belief name="table" class="Table">
		<fact>new Table()</fact>
	</belief>
	<!-- The bucket for currently unused blocks. -->
	<belief name="bucket" class="Table">
		<fact>new Table("Bucket", Color.lightGray)</fact>
	</belief>
	<!-- The currently existing blocks. -->
	<beliefset name="blocks" class="Block">
		<fact>new Block(new Color(240, 16, 16), (Table)$beliefbase.table)</fact>
		<fact>new Block(new Color(16, 16, 240), (Table)$beliefbase.table)</fact>
		<fact>new Block(new Color(240, 240, 16), ((Table)$beliefbase.table).getAllBlocks())</fact>
		<fact>new Block(new Color(16, 240, 16), ((Table)$beliefbase.table).getAllBlocks())</fact>
		<fact>new Block(new Color(240, 16, 240), (Table)$beliefbase.bucket)</fact>
		<fact>new Block(new Color(16, 240, 240), (Table)$beliefbase.bucket)</fact>
		<fact>new Block(new Color(240, 240, 240), (Table)$beliefbase.bucket)</fact>
	</beliefset>
	
	<!-- The gui (if any). -->
	<belief name="gui" class="BlocksworldGui"/>
</beliefs>

<goals>
	<!-- Clear one block. -->
	<achievegoal name="clear">
		<parameter name="block" class="Block" />
		<targetcondition>$goal.block.isClear()</targetcondition>
	</achievegoal>
	<!-- Achieve that one block is on a some target block or the table. -->
	<achievegoal name="stack">
		<parameter name="block" class="Block" />
		<parameter name="target" class="Block" />
		<targetcondition>$goal.block.getLower()==$goal.target</targetcondition>-->
	</achievegoal>
	<!-- Achieve a certain configuration of blocks. -->
	<achievegoal name="configure">
		<parameter name="configuration" class="Table" />
		<targetcondition>
			$beliefbase.table.configurationEquals($goal.configuration)
			<relevantbeliefset ref="blocks"/>
		</targetcondition>
	</achievegoal>
</goals>

<plans>
	<!-- plan to clear a block, by moving to the table whats on top of it. -->
	<plan name="clear">
		<parameter name="block" class="Block">
			<bindingoptions>
				select Block $block from $beliefbase.blocks
				where $block.getLower()==$goal.block
			</bindingoptions>
		</parameter>
		<parameter name="target" class="Block">
			<value>$beliefbase.table</value>
		</parameter>
		<body>new StackBlocksPlan($beliefbase.mode, $beliefbase.quiet)</body>
		<trigger>
			<goal ref="clear"/>
		</trigger>
	</plan>
	<!-- Stack one block on another one. -->
	<plan name="stack">
		<parameter name="block" class="Block">
			<goalmapping ref="stack.block"/>
		</parameter>
		<parameter name="target" class="Block">
			<goalmapping ref="stack.target"/>
		</parameter>
		<body>new StackBlocksPlan($beliefbase.mode, $beliefbase.quiet)</body>
		<trigger>
			<goal ref="stack"/>
		</trigger>
	</plan>
	<!-- Plan for stacking towards a certain configuration. -->
	<plan name="configure">
		<parameter name="configuration" class="Table">
			<goalmapping ref="configure.configuration"/>
		</parameter>
		<body class="ConfigureBlocksPlan" />
		<!-- <body>new ConfigureBlocksPlan()</body>-->
		<trigger>
			<goal ref="configure"/>
		</trigger>
	</plan>
	<!-- Plan for running test benchmarks. -->
	<plan name="benchmark">
		<parameter name="runs" class="int">
			<value>10</value>
		</parameter>
		<parameter name="goals" class="int">
			<value>10</value>
		</parameter>
		<body class="BenchmarkPlan" />
		<!-- <body>new BenchmarkPlan()</body> -->
	</plan>
</plans>

<events>
	<!-- Event that indicates an execution step can be done. -->
	<internalevent name="step"/>
</events>

<configurations>
	<!-- GUI configuration. Uses gui plan to show frame, and verbose stack plans. -->
	<configuration name="gui">
		<beliefs>
			<initialbelief ref="quiet">
				<fact>false</fact>
			</initialbelief>
			<initialbelief ref="gui">
				<fact>new BlocksworldGui($agent.getExternalAccess())</fact>
			</initialbelief>
		</beliefs>
	</configuration>

	<!-- Benchmark configuration. Uses benchmark plan to perform runs, and quiet stack plans. -->
	<configuration name="benchmark(runs=10, goals=10)">
		<beliefs>
			<initialbelief ref="quiet">
				<fact>true</fact>
			</initialbelief>
		</beliefs>
		<plans>
			<initialplan ref="benchmark" />
		</plans>
	</configuration>

	<!-- Benchmark configuration. Uses benchmark plan to perform runs, and quiet stack plans. -->
	<configuration name="benchmark(runs=10, goals=50)">
		<beliefs>
			<initialbelief ref="quiet">
				<fact>true</fact>
			</initialbelief>
		</beliefs>
		<plans>
			<initialplan ref="benchmark">
				<parameter ref="goals">
					 <value>50</value>
				</parameter>
			</initialplan>
		</plans>
	</configuration>

	<!-- Benchmark configuration. Uses benchmark plan to perform runs, and quiet stack plans. -->
	<configuration name="benchmark(runs=10, goals=500)">
		<beliefs>
			<initialbelief ref="quiet">
				<fact>true</fact>
			</initialbelief>
		</beliefs>
		<plans>
			<initialplan ref="benchmark">
				<parameter ref="goals">
					 <value>500</value>
				</parameter>
			</initialplan>
		</plans>
	</configuration>
</configurations>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。