問題タブ [calculation]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
algorithm - How to calculate Heuristic values for minimax
I am developing a software for a board game (2 player) which has 10x4 cells and both the players have 9 pieces each. Initially, the pieces for player 1 will be at the top of the board and for player 2 all the pieces will be at the bottom of the board (similar to chess but a lot less complex!).
I have used MiniMax algorithm to calculate the next best move. Now, the algorithm itself seems to work fine. The problem that I am facing is in Heuristic value calculation. If there is no best move found in the depth till I am searching (4 currently), my code simply takes the first step which it finds from the move list. That is probably because the score of all the moves are same till the depth of 4!
So, it just keeps stalling. Eg., it will move piece 1 from position A to B in 1st turn and in the 2nd turn it will move the same piece from position B to A. It keeps on doing that until the opponent moves closer to my pieces.
Now, what I want would love to know is how do I make sure that if the opponent is NOT closing in, I do that instead of stalling. Currently, I am calculating the heuristic values based on the difference between my pieces and opp pieces. How to calculate the values such that those moves which lead to position closer to the opponent's pieces are selected? Appreciate your help! Thanks!
postgresql - 計算のための PostgreSQL 構成ファイルとクエリの設計
私はPGが初めてで、この単純なクエリを実行しようとしていますが、Postgresがクラッシュしています. r1のみを計算しようとするとクエリは数秒で機能しますが、以下のようにr1に加えてr2からr6を計算しようとすると「メモリ不足」と表示されます。クエリの設計が悪い?計算フィールド r1...r6 を他の計算で参照するので、このクエリをビューにしようと考えていました。主な構成ファイルのパラメーターは以下のとおりです。Windows 10、PG 9.6、40 GB RAM、64 ビット。何をすべきかについてのアイデアはありますか?ありがとう!
編集: 最後に LIMIT 500 を追加してみましたが、うまくいきましたが、このクエリでクエリを実行すると、つまり別のクエリで計算された r1、r2、r3... を使用すると、新しいクエリはすべてのレコードまたは500個限定なのかな?
私の設定ファイルのパラメータ: