Skip to content

Can't run in local if the agent has an inner class in it #68

@Butanium

Description

@Butanium

Having this runner :

package Runners.tests;

import agents.moveDumb;
import com.codingame.gameengine.runner.MultiplayerGameRunner;

public class crashTestMove {
    public static void main(String[] args) {
        /* Multiplayer Game */
        MultiplayerGameRunner gameRunner = new MultiplayerGameRunner();
        gameRunner.addAgent(moveDumb.class);
        gameRunner.addAgent(moveDumb.class);
        gameRunner.setLeagueLevel(3);
        gameRunner.setSeed(3794553746263553451L);
        gameRunner.start();
  

    }
}

I get this erro :
image

java.lang.IllegalAccessError: tried to access class agents.moveDumb$Empty from class Agent41436
    at Agent41436.main(moveDumb.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.codingame.gameengine.runner.JavaPlayerAgent$JavaAgentThread.run(JavaPlayerAgent.java:191)

The agent that provok this is

package agents;

import java.util.Scanner;

/**
 * Control your bots in order to destroy the enemy team !
 **/
@SuppressWarnings("InfiniteLoopStatement")
public
class moveDumb {
    static class Empty {
        public int x;
        public int y;
        public Empty(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int botPerPlayer = in.nextInt(); // the amount of bot you control
        int mapSize = in.nextInt();
        // game loop
        while (true) {
            StringBuilder result = new StringBuilder();
            new Empty(1,2);
            int allyBotAlive = in.nextInt(); // the amount of your bot which are still alive
            int totalEntities = in.nextInt(); // the amount of entities in the arena
            System.err.printf("%d allybots, %d entities", allyBotAlive, totalEntities);
            in.nextLine();
            for (int i = 0; i < totalEntities; i++) {
               in.nextLine();
            }
            for (int i = 0; i < allyBotAlive; i++) {
                int accRank = totalEntities;
                int accId = 0;
                int accDist = 0;
                int selfId = 0;
                for (int j = 0; j < totalEntities; j++) {
                    int entId = in.nextInt(); // the unique entity id
                    String entType = in.next(); // the entity type in a string. It can be ON_AIR | ALLY | ENEMY
                    int distMe = in.nextInt(); // approximate distance between the target and the current bot. Can be 0 to 3 for short, medium, long and out of range
                    int distMeRank = in.nextInt(); // entities are sorted by ascending order based on their distance to the current bot
                    int shieldComp = in.nextInt(); // -1 if the entity has more shield than the current bot, 0 if it's equal, 1 if your bot as more shield
                    int healthComp = in.nextInt(); // same as shieldComp but for the health
                    int totComp = in.nextInt(); // same as shieldComp but based on the sum of health+shield
                    if(entType.equals("ENEMY") && distMeRank<accRank) {
                        accId = entId;
                        accRank = distMeRank;
                        accDist = distMe;
                    }
                    if (entType.equals("ON_AIR")) {
                        selfId = entId;
                    }
                }
                result.append(selfId).append(" MOVE ").append(accId).append(";");
            }
            System.out.println(result);
        }
    }
}

The cause is the use of the Empty class. However, online, this player works perfectly. How can I make it work locally ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions