Comments (5)
At the very least, it looks like we can move the dependency to catanatron gym, as all of the production usages are there (we define the graphs in catanatron.models.board, but only use them in the gym and in tests). That said, it looks like we do use the graph in the catanatron_gym - is that a usage we can easily replace with python stdlib objects or a performant custom class?
from catanatron.
There are some production usages of the STATIC_GRAPH
object (an nx.Graph) in core board methods like board.build_settlement
or the longest_acyclic_path
method (which are used by catanatron_core
). Tho they look like its mostly to "lookup neighbors" given a node.
These usages could be substituted to reading from a hard-coded lookup table (be it a dictionary or multidimensional array). Something like this seems to work:
NEIGHBORS = [list(STATIC_GRAPH.neighbors(i)) for i in range(72)]
That is, compute that once, save the result in a hardcoded python object of literals, and use that instead.
from catanatron.
Here the result:
[[5, 1, 20],
[2, 0, 6],
[1, 3, 9],
[2, 4, 12],
[3, 5, 15],
[4, 0, 16],
[1, 7, 23],
[8, 6, 24],
[7, 9, 27],
[8, 2, 10],
[9, 11, 29],
[10, 12, 32],
[11, 3, 13],
[12, 14, 34],
[13, 15, 37],
[14, 4, 17],
[18, 5, 21],
[15, 18, 39],
[17, 16, 40],
[21, 20, 46],
[0, 19, 22],
[16, 19, 43],
[20, 23, 49],
[6, 22, 52],
[7, 25, 53],
[26, 24, 54],
[25, 27, 57],
[26, 8, 28],
[27, 29, 59],
[28, 10, 30],
[29, 31, 61],
[30, 32, 64],
[31, 11, 33],
[32, 34, 66],
[33, 13, 35],
[34, 36, 68],
[35, 37, 71],
[36, 14, 38],
[37, 39, 73],
[38, 17, 41],
[42, 18, 44],
[39, 42, 75],
[41, 40, 76],
[44, 21, 47],
[40, 43, 79],
[47, 46, 84],
[19, 45, 48],
[43, 45, 81],
[46, 49, 87],
[22, 48, 50],
[49, 51, 89],
[52, 50, 92],
[51, 23, 53],
[24, 52, 94],
[25, 55, 95],
[56, 54],
[55, 57],
[56, 26, 58],
[57, 59],
[58, 28, 60],
[59, 61],
[60, 30, 62],
[61, 63],
[62, 64],
[63, 31, 65],
[64, 66],
[65, 33, 67],
[66, 68],
[67, 35, 69],
[68, 70],
[69, 71],
[70, 36, 72]]
from catanatron.
It would break the ability for us to support customly-shaped maps, but thats ok for now. It seems we could always make the "72" bigger and just require all maps to be contained in a hexagon-like sea of water tiles, like they are right now. Then this would hold.
from catanatron.
where's the 72 coming from?
from catanatron.
Related Issues (20)
- [React][UI] Implement use Year of Plenty action HOT 1
- [React][UI] Implement Use > Knight card HOT 1
- [React][UI] Implement Use > Monopoly HOT 1
- [React][UI] Implement "Use > Road Building". HOT 2
- [React][UI] Disallow player to play development in the same turn it was bought
- [React] Play animations when resources are yield
- [Python] Make MARITIME_TRADE action's value a 10-integer list HOT 2
- pips/dots for numbers in UI
- Simulator CLI seems to ignore first player code in list and also fails with 5 or longer (thus preventing a 4 player workaround) HOT 4
- Improve catanatron-play load time HOT 1
- Refactor code to avoid eager dependencies HOT 1
- Fix Overview.ipynb HOT 2
- Node production improperly calculated. HOT 1
- Gym seems to be broken? HOT 2
- Implement Card Counting HOT 5
- Implement returning all players points vs winner player colour HOT 1
- Create /mcts-score endpoint
- docker-compose images are outdated HOT 5
- [React][UI] Can't cancel road building animation if started
- Not able to play VP on devcards HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catanatron.