简体   繁体   中英

Using an arraylist to create a grid

I'm doing a project for a software development class (in Java) and we need to create an environment for a simulation using AI. We are doing a simple simulation of an ocean environment that contains plankton and whales. The plankton are part of the environment and the whales are the agents that will eat (store, trade, etc) the plankton. I'm trying to create the ocean environment right now and I'm kinda stuck. It's going to be a 2D grid that is 50 by 50. We don't need to create a GUI but we need to randomly fill the arraylist with plankton at the start of the simulation. I don't know if I should be making two lists, one for x and one for y, or just one.

We didn't get any lessons or instructions on this type stuff so sorry if this is a really simple question. I've been doing some searching around forums but I'm still a little confused.

Thanks

You can use an

ArrayList<ArrayList>

in which position of the list would be a new list, that would simulate a matrix, really is a simple question and you should show somme code or any prove that you tried, but this is so simple that i'm gonna answer your question ;)

So, a List of List ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM