X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=progcomp%2Fagents%2Fbasic_cpp%2Fbasic_cpp.cpp;h=4312489474fcac107c87533afce60655388b8864;hp=ab008264b8193a19b062f197b77ec4134335e448;hb=e8a611c553bd336550c50ed7491d5800a2ae7142;hpb=88fc5a96c424e9a451b98f3b680bc1980345320d diff --git a/progcomp/agents/basic_cpp/basic_cpp.cpp b/progcomp/agents/basic_cpp/basic_cpp.cpp index ab00826..4312489 100644 --- a/progcomp/agents/basic_cpp/basic_cpp.cpp +++ b/progcomp/agents/basic_cpp/basic_cpp.cpp @@ -333,9 +333,21 @@ bool BasicAI::InterpretResult() Direction dir = Helper::StrToDir(tokens[2]); - string & outcome = tokens[3]; - int x2 = x; int y2 = y; Helper::MoveInDirection(x2,y2,dir); + //We might want to actually check for the multiplier in the sample agents! 20/12/11 + unsigned int outIndex = 3; + int multiplier = atoi(tokens[outIndex].c_str()); + if (multiplier == 0) + multiplier = 1; + else + outIndex += 1; + + + + string & outcome = tokens[outIndex]; + + + int x2 = x; int y2 = y; Helper::MoveInDirection(x2,y2,dir, multiplier); Piece * attacker = board->Get(x,y); if (attacker == NULL) @@ -357,12 +369,14 @@ bool BasicAI::InterpretResult() //cerr << "No defender!\n"; return false; } + if (tokens.size() < outIndex+2) + return false; + board->Set(x2,y2, attacker); board->Set(x,y,NULL); attacker->x = x2; attacker->y = y2; - - attacker->rank = Piece::GetRank(tokens[4][0]); + attacker->rank = Piece::GetRank(tokens[outIndex+1][0]); ForgetUnit(defender); } else if (outcome == "DIES") @@ -372,10 +386,12 @@ bool BasicAI::InterpretResult() //cerr << "No defender!\n"; return false; } - + if (tokens.size() < outIndex+3) + return false; + board->Set(x,y,NULL); - defender->rank = Piece::GetRank(tokens[5][0]); + defender->rank = Piece::GetRank(tokens[outIndex+2][0]); ForgetUnit(attacker);