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

  • Home
  • SEARCH
  • 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 6963121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:44:55+00:00 2026-05-27T15:44:55+00:00

This is a chunk of code I’m using for Google’s antai challenge whenever I

  • 0

This is a chunk of code I’m using for Google’s antai challenge whenever I run it it seems to go into some endless loop then I get the stack trace at the bottom. I’m burnt out looking at this code I can’t for the life of me figure this out.

public class Node 
{
    private final int xCoord, yCoord;
    private int F, G, H;
    private Tile location;
    Node previousNode;
    private Tile [] neighbors;

    /*  
    G 
    the exact cost to reach this node from the starting node.
    H 
    the estimated(heuristic) cost to reach the destination from here.
    F = G + H 
    As the algorithm runs the F value of a node tells us how expensive we think it will         be to reach our goal by way of that node.
    */

    public Node(Tile loc)
    {
        location = loc;
        xCoord = location.getCol();
        yCoord = location.getRow();
        F=G=H=0;
        setNeighbors();
    }

    private void setNeighbors()
    {
        if(neighbors == null)
        {
            neighbors = new Tile[4];
        }
        neighbors[0] = new Tile(xCoord+1,yCoord);
        neighbors[1] = new Tile(xCoord-1,yCoord);
        neighbors[2] = new Tile(xCoord,yCoord+1);
        neighbors[3] = new Tile(xCoord,yCoord-1);//error occurs here!!!!!!
    }
}

        /**
 * Represents a tile of the game map.
 */
public class Tile implements Comparable<Tile> {
    private final int row;

    private final int col;

    /**
     * Creates new {@link Tile} object.
     * 
     * @param row row index
     * @param col column index
     */
    public Tile(int row, int col) {
        this.row = row;
        this.col = col;
    }

    /**
     * Returns row index.
     * 
     * @return row index
     */
    public int getRow() {
        return row;
    }

    /**
     * Returns column index.
     * 
     * @return column index
     */
    public int getCol() {
        return col;
    }

    /** 
     * {@inheritDoc}
     */
    @Override
    public int compareTo(Tile o) {
        return hashCode() - o.hashCode();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        return row * Ants.MAX_MAP_SIZE + col;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object o) {
        boolean result = false;
        if (o instanceof Tile) {
            Tile tile = (Tile)o;
            result = row == tile.row && col == tile.col;
        }
        return result;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return row + " " + col;
    }
    }

the actual error I’m receiving is:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at Node.setNeighbors(Node.java:37)
    at Node.<init>(Node.java:25)
    at AstarSearch.assessRoute(AstarSearch.java:73)
    at MyBot.gatherFood(MyBot.java:153)
    at MyBot.doTurn(MyBot.java:124)
    at AbstractSystemInputParser.processLine(AbstractSystemInputParser.java:54)
    at AbstractSystemInputReader.readSystemInput(AbstractSystemInputReader.java:18)
    at MyBot.main(MyBot.java:25)

any help is appreciated

  • 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-05-27T15:44:55+00:00Added an answer on May 27, 2026 at 3:44 pm

    I don’t know what this Google challenge is, so this may not be of much use (ie I don’t know if you have access to the JVM), though it is a generic method to help diagnose this kind of problem.

    I suggest turning on the JVM flag -XX:+HeapDumpOnOutOfMemoryError, and running your code again. An OutOfMemoryError will cause the heap to be dumped. You can then analyse this offline using something like Eclipse MAT.

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

Sidebar

Related Questions

I will be using some jQuery below this chunk of code (which I may
Cheers, I ran into this chunk of code in Programming Game AI by Example:
I'm trying to switch views in my app using this chunk of code: self->variable1
I ran across this chunk of code (modified) in our application, and am confused
can anyone offer a selector to do away with this horrible chunk of code:
This morning we found an old chunk of code that was causing a library
If I have a chunk of code like this: .hover( function () { hoverState($(#navbar
Let's say you have the following chunk of code: <div id=container> <someelement>This is any
How can I improve performance of this chunk of code ? What would be
Can someone verify the integrity of this chunk of code? I want to decorate

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.