aboutsummaryrefslogtreecommitdiff
path: root/dat.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-10-06 16:31:57 +0000
committerrodri <rgl@antares-labs.eu>2023-10-06 16:31:57 +0000
commitbc5ac3d46558512971ba8c0f6be02382d91d17f1 (patch)
tree93674e89f5c47335e0a8ad23a3319dd9eac6050d /dat.h
parentfb4b4cbf8062bd0ebaedcd2b3aa6cd1112f35258 (diff)
downloadbattleship-bc5ac3d46558512971ba8c0f6be02382d91d17f1.tar.gz
battleship-bc5ac3d46558512971ba8c0f6be02382d91d17f1.tar.bz2
battleship-bc5ac3d46558512971ba8c0f6be02382d91d17f1.zip
initial implementation of an AI.
added different modes for those who want to play with others and those who prefer to play against a bot (-a flag).
Diffstat (limited to 'dat.h')
-rw-r--r--dat.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/dat.h b/dat.h
index 46a3c12..07b7dd3 100644
--- a/dat.h
+++ b/dat.h
@@ -18,6 +18,9 @@ enum {
OH, /* horizontal */
OV, /* vertical */
+ GMPvP = 0,
+ GMPvAI,
+
Waiting0 = 0,
Watching,
Ready,
@@ -25,6 +28,10 @@ enum {
Waiting,
Playing,
+ ASearching = 0,
+ ACalibrating,
+ ABombing,
+
Boardmargin = 50,
TW = 16,
TH = TW,
@@ -55,6 +62,7 @@ typedef struct Map Map;
typedef struct Board Board;
typedef struct Chanpipe Chanpipe;
typedef struct Player Player;
+typedef struct Andy Andy;
typedef struct Match Match;
typedef struct Msg Msg;
typedef struct Stands Stands;
@@ -94,12 +102,32 @@ struct Player
Map;
char name[8+1];
int state;
+ int gamemode;
Match *battle;
NetConnInfo *nci;
Chanpipe io;
Channel *ctl;
};
+struct Andy
+{
+ Map; /* of the enemy */
+ Player *ego;
+ int state;
+ Point2 lastshot;
+ Point2 firsthit;
+ Point2 passdir; /* direction of current pass */
+ int ntries; /* attempts left to find the direction */
+ int passes; /* remaining passes (one per direction) */
+
+ void (*layout)(Andy*, Msg*);
+ void (*shoot)(Andy*, Msg*);
+ void (*engage)(Andy*);
+ void (*disengage)(Andy*);
+ void (*registerhit)(Andy*);
+ void (*registermiss)(Andy*);
+};
+
struct Match
{
RWLock;