Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda