Previous<-- Index--> Next

PACS : API

Since you have to program the players, you need some information about the game. And you need this information inside your program! For this reason we have developped what is called an Application Programmer Interface. This API consists of a series of Modula-2 procedures, type and constants that you can use inside your program. And it is using these procedures (constants and types) that you will be able to make a player.

In order to structure the files that make up PACS the API has been put in one file. This file is called PACSInterface.def. As you can see this is a (XDS) definition file. It only contains procedure headings, type definitions and constants. You can (or have to) use all of these to build your program. You can do this by IMPORTing the elements that you need in your file(s). Let us take short look at some of the element of the API.

TYPES

Here is an example of three types available to you (there are more!!):
    ObjectEn = (NO_EL, APPLE, BONUS, MINE, EATER, GHOST, HUNTER, EXPLORER);
    ElEn = [NO_EL .. MINE];
    PlTypeEn = [EATER..EXPLORER];
    DirEn = (UP, RIGHT, DOWN, LEFT);

    CampEn = (WHITE, BLACK);

    PropRc = RECORD         (* properties of a player *)
      camp: CampEn;
      plType: PlTypeEn;
      id: CARDINAL;
      pos: PosRc;
      nbrMoves: [0..MAX_NBR_MOVES];
      nbrMoves: [0..MAX_NBR_MOVES];
      nbrApples: [0..MAX_NBR_APPLES_EATER_CAN_CARRY];
      nbrWalls: CARDINAL;
      wasKilled: BOOLEAN;
    END;
The first type is used to represent directions. The CampEn type is defined in order to distinguish the teams in the arena. The PropRc type is used by PACS to give information about the players. So, you can see that the record contains: And this is the type of the procedure that you will have to program:

   PlBehaviourPr = PROCEDURE (PropRc, ViewRcPt): MoveRcPt;
 

Procedures

We now look at a few procedure you could use in your program. Again, you find these and more in PACSInterface.def. Some procedures are provided for your convenience. There are for example, quite some procedure to print the variable of different types in a human readable way on screen (see WrDirEn and WrCampEn).
  PROCEDURE WrDirEn(dir: DirEn);
  PROCEDURE WrCampEn(camp: CampEn);

  PROCEDURE OppositeDir(dir: DirEn): DirEn;

  PROCEDURE IsHome(pos: PosRc): BOOLEAN;

  PROCEDURE IsWall(pos: PosRc; dir: DirEn): BOOLEAN;
OppositeDir return the opposite direction of a give direction. Is home on the other hand return TRUE if the given position is indeed a home cell. The procedure IsWall allows you to detect whether moving in a given direction and given a position in the arena will make your player hit the wall. 
Previous<-- Index--> Next
-Back to the top -