Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
numpy.ndarray equivalent in Javascript

I am looking to implement a simple game in Javascript. The game is played by placing colored pieces on a grid, so a natural way to maintain the board state is with a 3D bool matrix, with dimensions corresponding to the board height, board width, and color, respectively. I also want to maintain similar auxiliary matrix structures that make it easier to compute valid moves and to compute game state transitions after moves. Finally, I hope to implement an AI player that runs within the browser, that relies on tree-search, so I want the state tracking operations to be efficient.

In python, I would use numpy.ndarray for this purpose. The data representation is compact, and I am able to perform the necessary update operations on the matrices elegantly and efficiently without for-loops by using various matrix operators like logical-{and,or,not}. I am also able to reassign a single entry within a matrix without needing to reassign the entire matrix.

I am wondering if there is something equivalent in the Javascript world. I know that I can use an array of arrays, but I lose representation compactness along with elegance and efficiency. The tensorflowjs library has the tensor object, which satisfies all those wants, but as far as I can tell, the immutability of the tensor object demands that I reassign the entire tensor whenever I want to reassign a single entry within it, which is a minor drawback. Finally, I've seen some other projects like scijs/ndarray which seem like they might fit the bill. But these seem to not be actively maintained, so I want to make sure I'm not missing something that is more commonly used.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda