Git Product home page Git Product logo

codingame-game-engine's People

Contributors

2stepsfr0mhell avatar a4vision avatar bullle avatar butanium avatar cg-kimi avatar cghbouvet avatar cgjupoulton avatar chickentuna avatar codingamecommunity avatar dependabot[bot] avatar dominisz avatar empheon avatar eulerschezahl avatar fdscg avatar maximecg avatar naejdoree avatar nantoniazzi avatar radekmie avatar s0 avatar visualdev-fr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codingame-game-engine's Issues

"Directory src/main/resources/view/assets not found."

I had some trouble on windows to execute an example (https://github.com/Azkellas/a-code-of-ice-and-fire) through maven with the commandline:

mvn -e exec:java -DaddResourcesToClasspath=true -Dexec.mainClass="SkeletonMain" -Dexec.classpathScope="test"

Everytime i get the error "Directory src/main/resources/view/assets not found."
Somehow maven uses a different SystemClassloader, making it impossible to find the right files by using it.

Just changed one line and now it seems to work.
https://github.com/TheCrazyT/codingame-game-engine/blob/master/runner/src/main/java/com/codingame/gameengine/runner/Renderer.java#L124
But I'm not shure if it causes trouble on other platforms.

Maybe i'm just running it wrong, but do not know of another way to execute it from commandline.
I know that running from eclipse or other IDE would also be an option ...
But not everybody wants to do that (for example the language you code the AI might need a different IDE and you do not want to waste resources).

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

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 ?

Running games back to back with game runner

If I try

loop {
    Properties props = new Properties();
    props.put("seed", "1234");
    GameRunner gameRunner = new GameRunner(props);
    gameRunner.addJavaPlayer(Player.class);
    gameRunner.addJavaPlayer(Player.class);
    gameRunner.start();
}

then the game doesn't run the same on the second run.

Any ideas?

Why don't you check if an attribute changed before updating an entity

Hello,
I was wondering why you don't check if an attribute is actually the same before changing it.

For example if myEntity is already in x = 10 why does myEntity.setX(10) update the entity state in the game.json ?
A simple

if (this.x = x) {return this} 

Would save some space in game.json or line of code for those who have big games and have to be careful about what they add in game.json

Endscreen for > 2 players

var rankLetter = this.generateText(finisher.rank === 1 ? 'ST' : 'ND'.toString(), 34, 'left', finisher.player.color)

There is no 3rd and 4th, only 1st and 2nd

if (i > 0 && podium[i - 1].score !== podium[i].score) {
curRank++

If two players are 1st with the same score, the 3rd will be shows as 2nd

We already solved this issue for Code of Kutulu, see rankLetter and podium code.

Unable to run code concurrently.

Hi, I'm trying to run some different games concurrently.

for (int t = 0; t < 50; t++) {
            Thread thread = new Thread(() -> {
                  MultiplayerGameRunner gameRunner = new MultiplayerGameRunner();
                  gameRunner.addAgent(Player.class);
                  gameRunner.addAgent(Player.class);
                  gameRunner.simulate();
            }
}

It gives this stacktrace.
Exception in thread "Thread-396" java.util.ConcurrentModificationException
at java.base/java.util.HashMap.forEach(HashMap.java:1339)
at com.codingame.gameengine.module.entities.WorldState.diffFromOtherWorldState(WorldState.java:83)
at com.codingame.gameengine.module.entities.GraphicEntityModule.sendFrameData(GraphicEntityModule.java:187)
at com.codingame.gameengine.module.entities.GraphicEntityModule.onGameInit(GraphicEntityModule.java:326)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at com.codingame.gameengine.core.GameManager.start(GameManager.java:99)
at com.codingame.gameengine.core.RefereeMain.start(RefereeMain.java:49)
at com.codingame.gameengine.runner.RefereeAgent$1.run(RefereeAgent.java:58)

Make the latest added entity automatically above the previous one

Since one of the last patch, the latest entity is no more above the previous added one. Now it's random and change if you run the same simulation twice. I guess it comes from a set architecture instead of a previously used list.

If you have a class of entities (for example explosion) that you spawn an arbitrary amount of time and that you want the last explosion to be above the other, you now need to dynamically manage the Zindex of all current entities that you want to be above the explosion : every time you spawn a new one, move up all the current entities :

imagine you have this :

e_1 : z = 1
e_2 : z = 2
robots at z = 3

if you want to add e_3, you need to change all the Zindex of robots...

Is this a change you made, or does it come from the pixy side ? Because it was better before.

Internal error

I have an error when I try to run the multiplayer game I'm working on, it's working at the start, but now it shows an internal server error.
Error screenshot

Also, another problem, the web server doesn't show anything, only a black screen without gameplay (although it still works when I export it and upload to Codingame)

miss clicked on the issue button, sorry...

Indeed. I have whitelisted everything the sanitzation library permits. I'm unsure why it doesn't allow overflow-x... the library isn't up to date on recent CSS properties either so the next step is probably to find a different library. Might take a while.

Originally posted by @CGjupoulton in #42 (comment)

AI process not killed on windows

On windows, when i play a game, the process of the players AI are not killed. And i end up with zombies. I use C++ AI so the command line to start my AI is just ./myAI.exe

Legend class in "statement-example" doesn't allow resize

Wide format : color issue in dark mode only

Tight format : text issue even in light mode

The problem comes from this piece of code. Replacing class=legend by style="padding: 10px" fix the text problem, but in dark modes it becomes unreadable

image

I think the easiest solution would be to make the statement-example background theme sensitive

SpriteAnimation not playing

The animation of the SpriteAnimation isn't playing anymore. The same code used to work in v3.4.3
You can see a minimum working example here. The code was taken directly from the documentation.

Note, that the animation is playing, when you move the sprite each turn (or change anything else, e.g. the alpha value). Animations without updates of the sprite don't play.

Contribution update doesn't replace testcases

There seems to be some caching for testcases going on at my Sokoban contribution at https://www.codingame.com/ide/demo/85365227d8ba216a6206b5fd692961a51fe1d8

I modified the testcase input format (testXX.json). It seems that it still tries to read the old testcase file which I've replaced. I double-checked this.

When I upload the contribution via Edit button and then test it, it's working fine. When I hit Save and Preview, I get nonsense maps like this:
image

That's a behavior I could reproduce by using the old testcase files with the new level parser

edit:
another, similar problem:
https://www.codingame.com/multiplayer/optimization/2048
There are 30 testcases with test=true and validator=true. And one (test1.json "random") that is only a test but not a validator.
Submit seems to run the correct testcases (I get the same score when submitting the same code). But it displays the random test in the report.

Please consider fixing ViewPort module.

Right now its behavior is not quite accustomed for many users. In particular, zooming is happening at the center of view, rather than under the mouse and dragging process is canceled when the mouse leaves the view area.
I believe the first one can be done by setting the .interaction and the last one by setting .moveWhenInside = False.

Toogle module does not work if loaded before the GraphicEntityModule

The doc about the tooltip module says :

โš  This module requires the GraphicEntityModule to work.

But, the module needs more than that, it needs to be loaded after the graphicEntityModule (so needs an higher index in modules from the config.js).
If you load it before the GraphicEntityModule, you get this error :

Drawer.js:86 TypeError: Cannot set properties of undefined (setting 'interactive')
    at TooltipModule.js:181:46
    at Map.forEach (<anonymous>)
    at TooltipModule.reinitScene (TooltipModule.js:179:31)
    at Drawer.initScene (Drawer.js:439:16)
    at Drawer.reinitScene (Drawer.js:625:12)
    at Drawer.reinit (Drawer.js:653:14)
    at Drawer.animate (Drawer.js:686:18)

Because the containers are not created.

I don't know if you noticed that and if we should change the doc.

[Statement Sheet] [Security] [XSS] [Info]

hello, I have been using the codingame SDK for a short time, wanting to write my first page statement_fr.html locally I wanted to add features to the static page I tried to open a script tag and started writing inside,
I follow myself realized that the code in the script tag does not execute after reflection it seems logical since after the publication of the game the code would run on the player's browser and would not be controlled by codingame.com this which can be nasty with malicious code.
Then continuing to write my page statement_en.html
by wanting to load an image from a remote url (I was mistaken in the source of the image) and by reflex I added an onerror attribute on the img tag to verify that the source of the image was valid and I got myself realized that the javascript is executed when it is written in inline in the HTML attributes (on the local environment anyway). This behavior seems a bit strange, I have not found another issues that speaks about it elsewhere I would like to know if this and blocked after publication of the game? If this a feature that and intentionally added?
Where if these a real bugs and possibly an XSS flaw.

I am French sorry for my approximate English.

Cannot integrate responsive table in the statement.

Hello I'm making a game and some information about bot class are shown in a table to the player in the statement.
Unfortunately, there is too many data in it :
GIwVWHz61l
Why is the auto overflow-x not allowed in statements ? It would be really useful.

About internationalization

Hey, how are you, I just found codingame, it was really cool, I only know codecombat before, until met codingame, was a brief encounter, but one thing I am sad, codingame only two languages, English and French was not very friendly to users of other languages, have you got any plans to launch more national language, if have to contribute, how can I translate Chinese there are very very very many potential users, Sincerely hope to have Chinese, please let me contribute to it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.