diff options
author | rodri <rgl@antares-labs.eu> | 2023-10-06 16:31:57 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-10-06 16:31:57 +0000 |
commit | bc5ac3d46558512971ba8c0f6be02382d91d17f1 (patch) | |
tree | 93674e89f5c47335e0a8ad23a3319dd9eac6050d /dat.h | |
parent | fb4b4cbf8062bd0ebaedcd2b3aa6cd1112f35258 (diff) | |
download | battleship-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.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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; |