Is there a problem with the transition table in my negamax algorithm implementation?

I'm currently developing a Chess AI in TypeScript that utilizes negamax with alpha-beta pruning to explore potential moves. The AI incorporates two heuristics: 1) the main heuristic, which assesses leaf nodes during the negamax tree traversal, and 2) a simple yet cost-effective heuristic used for ordering moves to potentially eliminate unnecessary node searches.

In an effort to optimize computation time, I've experimented with implementing a transposition table. While it has significantly reduced processing time, it has also resulted in suboptimal moves being made. I suspect there might be an issue with the implementation of alpha-beta pruning in my code, causing the AI to make incorrect decisions by assuming that certain moves have been pruned. Despite multiple attempts, I am struggling to pinpoint the exact source of the problem. Below is the snippet of the algorithm:

/**
 * Depth first search: negamax with a/b pruning
 */
private lookAheadAtMove(
    boardState: ChessBoardState,
    player: ChessPlayer,
    enemy: ChessPlayer,
    depthRemaining: number,
    alphaPrune: number,
    betaPrune: number,
    negateMult: number,
    transpositionTable: Map<string, iTranspositionTableEntry>
): iLookahedResponse {
    // Code snippet here
}

Despite verifying the correctness of the rest of the algorithm, the issues seem to arise only when the transposition table is involved. To address this, I have attempted the following solutions:

  • Storing only the heuristic score without additional upperbound/lowerbound types
  • Adjusting the mathematical operations for handling negation differently
  • Restricting the use of the table to specific depths
  • Exchanging "<="" with ">=" in the line that determines whether to utilize the transposition table or not (it should ideally be "<=" to retrieve scores from deeper tree levels, but I tested both scenarios).

Answer №1

If your program is functioning properly even without utilizing transposition tables, then there is likely nothing wrong with your alpha/beta algorithm. Alpha/beta always produces the same outcome as a regular mini-/negamax approach; it simply helps in avoiding unnecessary evaluations of certain moves.

For more information on this topic, consider checking out the Chessprogramming website. Additionally, I recommend watching this informative YouTube series that explains these concepts in an easy-to-understand manner.

Unfortunately, debugging transposition tables can be quite challenging. Make sure to double-check that your hash calculations are accurate.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Leveraging TypeScript alongside body-parser to access properties within req.body

I'm currently developing a web application using TypeScript and integrating the body-parser middleware to handle JSON request bodies. I've encountered type errors while attempting to access properties on the Request.body object. For instance, wh ...

Unleash the full power of Angular Components by enhancing them with injected

I am facing a challenge with handling the destruction event of an Angular component in my external module that provides a decorating function. I've run into issues trying to override the ngOnDestroy() method when it includes references to injected ser ...

Populate input fields in HTML using Angular 4

Within my angular 4 project, I am facing the challenge of setting a value in an input field and in a MatSelect without relying on any binding. Here is the HTML structure: <div class="row search-component"> <div class="col-md-5 no-padding-rig ...

The module 'ngx-cookie-service' could not be located

I am currently working with Angular 12 and recently I installed a cookie service using the following command: npm install --save ngx-cookie-service Within my app.module.ts file, when I try to import the 'CookieService' like so: import { Cookie ...

Typescript sometimes struggles to definitively determine whether a property is null or not

interface A { id?: string } interface B { id: string } function test(a: A, b: A) { if (!a.id && !b.id) { return } let c: B = { id: a.id || b.id } } Check out the code on playground An error arises stating that 'objectI ...

Is there a way to define type information for a global variable when utilizing dynamic import within a function?

Here is a simplified version of my server code: server.ts import google from "googleapis"; const androidPublisher = google.androidpublisher("v3"); app.use('something', function(req, res, n){ ... }) ...(only one of the dozens of other meth ...

What is the best way to remove a parent app.js element from a child component?

When I click the delete button, my intention is to filter an array in the parent app.js component and remove a specific item. However, I keep encountering a Typescript error stating Cannot assign to read only property 'message' of object 'Sy ...

The JSX element with type 'Component' does not support any construct or call signatures at this time

I am facing an issue with the following code snippet const pageArea = (Component:ReactNode,title:string) => ({ ...props }) => { return ( <> <div> { Component && (<Component { ...

Steps for personalizing the dataset on a PrimeNG bar graph

I'm currently working with primeng in an Angular project and I need to create a bar chart where the last two horizontal bars have different colors. Right now, the last two bars are incorrectly being assigned to represent dogs and cats. My goal is to ...

How can I prevent scrolling in Angular's cdk-virtual-scroll feature?

Is there a way to use Angular's cdk-virtual-scroll to prevent the scrollbar from moving by default? I have done extensive research but have not been able to find a solution. ...

What is the best way to retrieve an object when a value is not found? Consider implementing a looping mechanism with a specific condition in React and TypeScript to successfully

Greetings, I am faced with an array of objects structured as follows: const arr_obj = [ { id: '1', jobs: [ { completed: false, id: '11', run: { ...

Angular: Retrieving the Time Format from the Browser

Is there a way to retrieve the time format from the operating system or browser within Angular in order to display time in the user's preferred format? I have attempted to search for a solution, but have come up empty-handed. Thank you in advance! ...

What is the best approach to deactivate or manage init and toJSON functionalities?

After creating a .NET core 2.2 webapi and utilizing swagger / nswag to generate the API for my React / typescript application, I encountered a ts(2739) message when attempting to set up a new object: Type '{ firstName: string; lastName: string; }&ap ...

What is the best way to ensure the integrity of an array while allowing multiple threads to read and modify it simultaneously, without the

My current project involves creating an endgame tablebase for a unique chess variant. The technique I am using to fill the tablebase is quite interesting: To begin with, I have a large array of unsigned char, where each element represents a different pos ...

Angular Observables do not update local variables when making API calls

For some reason, I cannot set a value in my local variable as expected. Here is the code snippet: export class memberComponent implements OnInit { member : Member = new Member(); constructor(private memberService: MemberService) {} ngOnInit() { ...

The declaration file for the 'react-tree-graph' module could not be located

I have been working on incorporating a tree visualization into my react project. After adding the 'react-tree-graph' package and importing the Tree module, like so: import Tree from 'react-tree-graph' I encountered the following error ...

show the stored value inside the useRef variable

One of my challenges involves a variable const prediction = useRef<any>(null); A button triggers a function that updates the variable's value: function showResult() { classifier.current.classify(capture, (result) => { ...

The custom native date adapter is facing compatibility issues following the upgrade of Angular/Material from version 5 to 6

In my Angular 5 application, I had implemented a custom date adapter as follows: import {NativeDateAdapter} from "@angular/material"; import {Injectable} from "@angular/core"; @Injectable() export class CustomDateAdapter extends NativeDateAdapter { ...

What is the best way to choose checkboxes from data that is passed dynamically?

https://i.stack.imgur.com/L3k59.png I am looking to add an edit feature to my application. When the user clicks on the edit option, they should be taken to a different page with the previously entered value displayed. While I have successfully retrieved ...

Exploring the Relationship Between the ngOnInit and ionViewWillLoad Lifecycle Hooks

After a few months of utilizing Ionic Framework (ionic-angular 3.9.2 latest) for developing Progressive Web Apps, I find myself pondering the distinction between ngOnInit and ionViewWillLoad. If my understanding serves me right, ngOnInit is an Angular lif ...