/************************************ * Umass Amherst * CS377 Operating System * Lab2: * Author: Qi Li, Andrew Fagg * Date: 9/22/2002 * * Class in this file: * Compile: javac Map_Data.java * Run: n/a * * Description: defines the data structures for the grid and for * the set of robots and goals. * * ***********************************/ import java.util.*; import java.lang.*; import javax.swing.*; import java.awt.event.*; import java.io.*; import java.awt.*; class Map_Data { int nRowSize,nColSize; // The size of grid is nRowSize*nColSize int nCelldRow,nCelldCol;// Size of individual grid cells in pixels int nRobots; // Total number of robots int nGoals; // Total number of goals int Grid[][]; // grid matix, Grid[i][j]=1 if there is an obstacle at (i,j) // =0 otherwise Abstract_Robot Robots[]; // The array of robots Goal Goals[]; // The array of goals int curNGoals; // The number of uneaten goals Abstract_Distance Dists[]; // One for each different color robot Semaphore sem; // Used to protect the common data reads/writes /* Create the Map structure is the number of different robot color types (3 in our case) */ public Map_Data(int num_colors) { // Create the semaphore that controls access to common data sem = new Semaphore(1); Dists = new Abstract_Distance[num_colors]; }; }