1 回答
TA贡献1818条经验 获得超3个赞
我在代码中看到的一个问题是 for 循环条件,如果实际成本不是最小成本,则会停止循环。因此,如果在第一次迭代中实际成本不等于最小成本,则永远不会迭代 for 循环。我没有试图找出你在 for 循环中做了什么。可能还有更多错误。
for( int i = 0; i < acts.length -1; i++ )
{
if ( acts[i].getActionCost( ) == getMinValue( costs ) )
{
System.out.println( "PRE The first parameter is : " +
acts[i].getActParameter1() + acts[i].name );
if ( acts[i].getActParameter1() == "plane" )
{
System.out.println( "POST The first parameter is : " +
acts[i].getActParameter1() );
System.out.println( "Precondition satysfied with action name: " +
acts[i].name );
if ( acts[i].getActParameter1() != state.getStateParameter1() )
{
state.setStateParameter1( acts[i].getActParameter1() );
}
if(acts[i].getActParameter2() != state.getStateParameter2())
{
state.setStateParameter2( acts[i].getActParameter2() );
}
if( acts[i].getActParameter3() != state.getStateParameter3() )
{
state.setStateParameter3( acts[i].getActParameter3() );
}
if( acts[i].getActParameter4() != state.getStateParameter4() )
{
state.setStateParameter4( acts[i].getActParameter4() );
}
if( acts[i].getActParameter5() != state.getStateParameter5() )
{
state.setStateParameter5( acts[i].getActParameter5() );
}
}
Node child = new Node(state, startNode, acts[i].getActionCost());
System.out.println( "Costs array: "+ Arrays.toString( costs ) );
System.out.println( "ActionID" +" " + i );
System.out.println( "The action choosen is " + acts[i].name +
acts[i].actionCost + acts[i].getActParameter1() );
System.out.println( "State parameters updated are " + "pkg1Location: " +
state.getStateParameter1() + " pkg2Location: " +
state.getStateParameter2() + " truckLocation: "+
state.getStateParameter3() + " planeLocation: " +
state.getStateParameter4() + " cityLocation:"+
state.getStateParameter5());
}
}
添加回答
举报