CodeBusters (aka Soul Snatchers) - Puzzle Discussion

:ghost: Feel free to send your feedback or ask some help here! :ghost:

Related Post :
https://forum.codingame.com/t/codebuster-feedback-strategy/1759

Update 2016/07/28 15:00PM:
FIX Bug: It’s now impossible to release a ghost and grab him with another buster IN THE SAME TURN.

Does this apply to EJECT as well? I.E. can you EJECT and BUST the same ghost in the same turn?

  • danBhentschel

Yup, Same for EJECT/STUN as well.

I’m not sure what’s wrong with my code… I checked it thoroughly but I’m pretty sure I got the ghost coordinates right, so why do my busters merely stay in place?

` #include
#include
#include
#include

using namespace std;

/**
 * Send your busters out into the fog to trap ghosts and bring them home!
 **/
int main()
{
    int bustersPerPlayer; // the amount of busters you control
    cin >> bustersPerPlayer; cin.ignore();
    int ghostCount; // the amount of ghosts on the map
    cin >> ghostCount; cin.ignore();
    int myTeamId; // if this is 0, your base is on the top left of the map, if it is one, on the bottom right
    cin >> myTeamId; cin.ignore();

    // game loop
    while (1) {
        int count=0; int count1=0;
        int entities; // the number of busters and ghosts visible to you
        cin >> entities; cin.ignore();
        int myteam [bustersPerPlayer];
        int ghosts= entities-(2*bustersPerPlayer);
        int ghostteam [ghosts];
        int ghostx [ghosts]; int ghosty [ghosts];
        int myx [bustersPerPlayer]; int myy [bustersPerPlayer];
        int mystate[bustersPerPlayer];
        for (int i = 0; i < entities; i++) {
            int entityId; // buster id or ghost id
            int x;
            int y; // position of this buster / ghost
            int entityType; // the team id if it is a buster, -1 if it is a ghost.
            int state; // For busters: 0=idle, 1=carrying a ghost.
            int value; // For busters: Ghost id being carried. For ghosts: number of busters attempting to trap this ghost.
            cin >> entityId >> x >> y >> entityType >> state >> value; cin.ignore();
            if (entityType==myTeamId)
            {myteam[count]=entityId;
            myx[count]=x;
            myy[count]=y;
            count++;
            mystate[count]=state;}
            if (entityType==-1)
            {ghostteam [count1]=entityId;
            ghostx [count1] =x;
            ghosty [count1] =y;
            count1++;
            }
        }
        
        for (int i = 0; i < bustersPerPlayer; i++) {

            // Write an action using cout. DON'T FORGET THE "<< endl"
            // To debug: cerr << "Debug messages..." << endl;
            int ghostex=ghostx [i];
            int ghostey=ghosty [i];
            int teamx = myx[i];
            int teamy= myy[i];
            int getworking = mystate[i];
           { cout << "MOVE " + to_string(ghostex) +" " + to_string(ghostey)<< endl;} // MOVE x y | BUST id | RELEASE
           
           if (myteam[i]==myTeamId && getworking==1)
              { if (myTeamId==0)
               {
                   if (teamx<1350 || teamy<750)
                   cout<<"MOVE 1350 750"<<endl; //to release the ghost
                   else
                   cout<<"RELEASE"<<endl;
               }
               else
               {   if (teamx>14650 || teamy>8220)
                   cout<<"MOVE 14650 8220"<<endl;
                   else
                   cout<<"RELEASE"<<endl;
               }
           }
           if(ghostteam[i]==-1)
               {if (sqrt( (teamx-ghostex )^2 + (teamy-ghostey)^2) <=1760 ||(sqrt( (teamx-ghostex )^2 + (teamy-ghostey)^2) >=900))
            {cout<<"BUST "+ghostteam[i]<<endl;}
               }
         } 
    }
    }`

Any help?

I didn’t test it, but it looks as if you produce too many lines of output (more than one per buster). This will result in the rest of your output for this round being interpreted as the output for the next round.

But please don’t post code here, as it is a spoiler for other players.

1 Like

This is my code snippet in java to release the ghosts:

if (state == 1) { // if ghost is captured
    System.out.println("MOVE 0 0");
    System.out.println("RELEASE");
}

But the ghosts are released at the same place that they are captured.
What am I doing wrong?

The moves are not immediate. “MOVE 0 0”, will initiate a move to this coordinates, but you will not be on this position until the next turn, or more, depending of the distance.

2 Likes

Thanks for the reply.
So how do I release the ghosts at the destination?

You know your buster’s coordinates, so just test if he is at your base and then use “RELEASE”.

1 Like

How would I command a specific buster to MOVE, BUST or RELEASE as there is no buster id involved in the command?
In other words, how would I know which buster will follow which command?

I’m pretty sure it follows the buster id, so the first command goes to your first buster etc

1 Like