codingame / codingame-game-engine Goto Github PK
View Code? Open in Web Editor NEWCodinGame Engine
Home Page: https://www.codingame.com
License: MIT License
CodinGame Engine
Home Page: https://www.codingame.com
License: MIT License
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).
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();
}
}
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 ?
It would be very useful to to use GameRunner#start without a web server. We can use/parse the game result directly.
At the moment it's impossible. Even if you override the start method, you can't use initialize
and run
(private methods).
I can make a pull request if you want.
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?
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
We already solved this issue for Code of Kutulu, see rankLetter and podium code.
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)
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.
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)
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)
Regarding the local test page http://localhost:8888/test.html:
on turn-based games (with only a single player getting executed each turn), the SDK always shows the output and error stream at the first player. This bug was introduced somewhere between v3.6 and v3.7, it's working properly on the older version.
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
If the referee process crash (because of an uncatched exception), the runner process stay in deadlock. Stuck in the RefereeAgent#getOutput method.
Using Tooltip Module 3.13.1
I get this error when importing toggle module http://prntscr.com/n02en9.
https://github.com/MultiStruct/Yavalath
File that gives error is attached, is the uncomented version
config.zip
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
I think the easiest solution would be to make the statement-example
background theme sensitive
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.
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:
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.
When you place objects inside a BufferedGroup
and set a scale less than 1, the part of the group that wouldn't be visible with a scale of 1 isn't shown.
See the following declaration:
https://github.com/eulerscheZahl/Sokoban/blob/570fde89ab672ea21f403d7d38a4b341dc7df2b7/src/main/java/Sokoban/Board.java#L43-L44
The readme at https://github.com/CodinGame/codingame-game-engine/tree/master/runner says you can do this
gameRunner.addJavaPlayer(Player.class);
gameRunner.addCommandLinePlayer("python3 /home/user/player2.py");
but it doesn't work. The following does work
gameRunner.addAgent(Player.class);
gameRunner.addAgent("python3 /home/user/player2.py");
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.
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.
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.
I'm having issue in dark mode only right now, and I'd like to see if it's fixed without uploading my export on CodinGame
Demo: https://www.codingame.com/contribute/view/534120f426f5a3134cc041564c33b80db11c
Set the toggle to OFF and you will still see the "RED" as a tooltip.
This is because the mouse is over the red area while it's hidden via toggle.
I saw in the spring challenge 2022 statement that it was possible to add a button to save the statement as pdf.
When I tried to use this in clash of bits, nothing appears in CodinGame.
Is this option reserved to contests ?
Is this code released under MIT license ?
The following screenshot shows the statement. Left: local testing environment, right: CodinGame website.
As you can see, the results differ: the distances between text and headlines gets missing and the table ignores the colspan="3"
completely (gets deleted on upload).
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.