Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:01:03+00:00 2026-06-09T07:01:03+00:00

I’m currently working on a game, where I need to create a transposition table

  • 0

I’m currently working on a game, where I need to create a transposition table for my AI. I implemented Hashtable so that the key to the Hashtable is a state under consideration and its corresponding value is the optimal next move.

However, when I save the Hashtable in Android’s internal storage and restore it next time, it seems to have some saved data, but the keys (i.e. game states) are different than the keys I have saved in the previous instance.

Here is how I save and restore my data:

    private void readTranspositionTableFromFile() {
        FileInputStream fis = openFileInput(FILENAME);
        ObjectInputStream ois = new ObjectInputStream(fis);
        transpositionTable = (Hashtable<BoardState, NextMove>) ois.readObject();
        ois.close();
        deleteFile(FILENAME);
    }

    private void writeTranspositionTableToFile() {
        FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(transpositionTable);
        oos.close();
    }

I see no problem in my hashCode() implementation, since it keeps returning same values for same states over and over.

I suspect saving/restoring the transposition table messes up my data because I logged the 2 runtimes and on the first one I got hashCode() to return 3964 and 3029 for the 2 states that were to be added to the table. However, while reading the table from file, the hashCode() returned 9119 twice.

Is there any problem in saving/restoring the data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:01:05+00:00Added an answer on June 9, 2026 at 7:01 am

    My serializing and hashing was completely fine. My program went something like this:

    1. add new key-value pair to transpositionTable
    2. play next move
    3. save transpositionTable to internal storage

    However, after meticulous logging, I found that my transpositionTable changed after step 2). This was because during step 1), I used

    BoardState newKey = currentData.getBoardState();

    and saved it to my transpositionTable. Then in step 2), when my currentData changed, my transpositionTable changed accordingly. I tried using

    BoardState newKey = currentData.getBoardState().clone();

    but that didn’t work either. Finally I had to assign each field of currentData.getBoardState() to newKey manually, which worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.