gaigresearch / tribes Goto Github PK
View Code? Open in Web Editor NEWTribes is an open source implementation for AI research of the game The Battle of Polytopia
Tribes is an open source implementation for AI research of the game The Battle of Polytopia
Converge to Vector2d
Creation of units requieres several calls now. Need to find an easier way.
Move from objects to unit ids
Also another name for the variable. It contains converted units, but also those derived from unit shifts.
Tribes should manage monuments counters. Actions should be created accordingly.
but they're added to the available array
All actions should be checking bounds on any positions (e.g. neighbours) they're considering and querying the grid for (>=0 and <gridSize). Currently some crash if units move to the edges.
E.g. AttackFactory.computeActionVariants() method has a loop that checks neighbouring cells, but those coordinates are not validated to be within the grid. Likely to be the case in others as well.
// Loop through unit range, check if tile observable and action feasible, if so add action
for(int i = position.x - unit.RANGE; i <= position.x + unit.RANGE; i++) {
for (int j = position.y - unit.RANGE; j <= position.y + unit.RANGE; j++) {
//Not attacking itself
if(i != position.x || j != position.y) {
Attack a = new Attack(unit.getActorId());
Unit other = b.getUnitAt(i, j);
if (other != null) { // Check if there is actually a unit there
a.setTargetId(other.getActorId());
if (a.isFeasible(gs)) {
attacks.add(a);
}
}
}
}
}
Units that join a tribe via the Convert action do not count as population for any city. That also means that we're not adding them to any city, so they're lost in time and space - we can't access them from a Tribe. We need to hold those unit ids somewhere (maybe Tribe)?
Different units can do different combinations of actions, depending on the attack results. This is not implemented now (manage it using Types.TURN_STATUS).
See the possibilities here: https://github.com/GAIGResearch/Tribes/wiki/Actions
Meeting a tribe for the first time grants knowledge of a technology. I'm not sure if the fandom says how does this happen...
Actions should describe effects & requirements.
After every action, in GameState.next(), check of the game is over
Star generation at the beginning of each turn needs to be computed.
Note that, if enemy unit is in an owned city, that city does not generate stars that turn.
GameState.copy() missing a deep copy on the actions lists, otherwise they're not actually received by the players/GUI. Those lists are possibly affected by the actions refactor too?
Resources need to disappear from the board when collected.
Still to be computed. See Tribe.updateNetwork(...).
At the moment, this method runs through the whole board to check tiles that rarely change. Add a list of tiles to City.java (ArrayList, order doesn't matter) that is updated with the calls to Board.setBorderHelper() and access through that list instead.
Preferred: same method, different limits (not size, but position+-RANGE)
Needs two parts:
Note that, if enemy unit is in an owned city, that city does not generate stars that turn.
Use vector2d instead
When a new city is captured (from a village to city), one UNIT moves there from the capital.
If capital has UNIT == 0, then it's taken from another city (at random?)
The attacking unit gets damage back from the target if the target is not killed. This is not happening now in the Attack action.
Also, in some cases (when the attacker is not a ranged unit), the attacker takes the position of the target if the target is killed.
Some terrain is only visible for a tribe when a certain tech is researched:
also, +20 points for every non-city tile added to the tribe's territory. This means that converting village into city means 180 points (100 for city level 1 + 8x20 tiles around for borders). Level Up - Border_growth also adds +20 for all the new tiles.
Current codebase version gives a lot of exceptions everywhere where a list of actors and actor IDs are used, and possibly more - it seems a lot of these IDs are lost at some point, maybe not copied?
Also, do tribes need actor IDs? I can't think of a case where the tribe would be retrieved by actor ID instead of tribe ID.
E.g.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at core.game.Game.initTurn(Game.java:273)
at core.game.Game.processTurn(Game.java:211)
at core.game.Game.tick(Game.java:189)
at core.game.Game.run(Game.java:164)
at Run.runGame(Run.java:28)
at Play.main(Play.java:46)
Exception in thread "main" java.lang.NullPointerException
at core.actions.cityactions.LevelUp.isFeasible(LevelUp.java:34)
at core.actions.cityactions.factory.LevelUpFactory.computeActionVariants(LevelUpFactory.java:24)
at core.actions.cityactions.factory.CityActionBuilder.getActions(CityActionBuilder.java:23)
at core.game.GameState.computePlayerActions(GameState.java:160)
at core.game.Game.initTurn(Game.java:315)
at core.game.Game.processTurn(Game.java:211)
at core.game.Game.tick(Game.java:189)
at core.game.Game.run(Game.java:164)
at Run.runGame(Run.java:28)
at Play.main(Play.java:46)
We've somehow forgotten about naval units (Boat, Ship and Battleship). They were missing in the Types enum, sprites and we don't have classes for them.
I added them to Types and found the sprite sets for them. Stavros, can you please add the classes to the corresponding package? (there are no dependencies, they can be added to the refactor-2 branch). Sprites and types are now merged into master.
I wasn't aware of this... Mind bender must not be able to move into a city tile
All random events in the game must come from a common Random object (which uses a determined random seed).
No computation for this monument yet - https://polytopia.fandom.com/wiki/Altar_of_Peace
If an enemy unit or Nature Bunny moves into one of your cities, star production from that city will stop entirely and you will gain 0 stars from it the next turn. City Class
Units in their tribe's city get a +50% (ร1.5) defence buff, which increases to +300% (ร4) if the city has city walls. Defense Action
It is also important to note that the amount of cities you own influences the prices of tech on the Technology Tree. 1 star per extra city for Tier 1, 2 stars per extra city on Tier 2 and 3 stars on Tier 3 techs. Technology Action
There are two main things that can be refactored in the buildings hierarchy:
There are some variables that are common to many buildings (example: cost) that can be in the upper class (Building) and not in the derivate. In fact, probably most of them are (production, type, even the constraints). We can set void values (null, or 0) to those units that do not have production, for instance. The same is true with the accessor functions (getType(), for instance, but also others).
The actual (constant) values for different properties of buildings should be extracted to a common file. I've created TribesConfig.java for this (check this in the branch refactor-2). The best way would be to pass this values in the class constructor - I've made an example of this for Warrior.java, in refactor-2 branch).
And two extra things that may help simplify things:
All monuments (TowerOfWisdom, ParkOfFortune, etc.) are essentially the same, so we could probably converge them all in a single class Monument.java and remove the other ones.
Doesn't the same concept above in (3) applies to the different types of Temples in the game.
Overall, the concept is to move to a more data-driven approach. Less classes/code and more reliance on parameter values.
Note that in the branch refactor-2 I've also made a refactoring of files and packages below 'units' (now called 'actors', to reflect its meaning better).
Populations can be negative in cities, which happens when losing connection to the capital. But I'm not 100% sure how it happens, so needs investigating.
One clear effect is that a city with -X population generates -X stars.
Find out what it is and implement it
We need functionality to saving/loading gamestates. Ideally in a human readable format (i.e. JSON).
One thing we need to avoid using is clone() - I may have forgotten mentioning this.
We need to create our own copy method for the objects, as clone() has shown unstable behaviour. This is specially true for objects contained in data structures.
Build Road! See also this: https://polytopia.fandom.com/wiki/City_Connections
All constant values (properties of units) should be extracted to a common file: TribesConfig.java
Check this in the branch refactor-2
Note that in this branch there's also a refactoring of files and packages below 'units' (now 'actors', to reflect its meaning better).
Destry.java, execute()
When destroying a CUSTOM HOUSE building, see:
//TODO: Is this correct? The production of a custom house depends on the number of Ports around it,
// so I'm not sure this should be a constant value.
city.subtractProduction(removedBuilding.getPRODUCTION());
I've removed these options from the ResourceGathering.execute() methods, but I wonder if the mine and farm building are taking the added production into account.
BUILDING
CUSTOM HOUSE
isBuildable(): it must check if there's at least 1 port adjacent to it. Otherwise it can't be built.
New method in CustomHouse: computeProduction(c, gs) -> computes and returns the production of this custom house.
Custom House will have its own production that is not added to the city. That way it's easier to ignore this production when destroyed.
FORGE, SAWMIMLL
This function needs changing. A village is not a City object, but a terrain type.
Needs to manage two cases:
Spawning units gives points to the tribe. I haven't seen when in the wiki is this reflected, but it does happen. Also Disband removes these points from the tribe.
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.