Set to version 1.16.1 and prepared new ai code.

This commit is contained in:
johns 2000-03-31 16:02:05 +00:00
parent 5d3b7268cb
commit fd6da9424b
6 changed files with 104 additions and 30 deletions

View file

@ -21,6 +21,8 @@ include $(TOPDIR)/Rules.make
MODULE = ai
OBJS = ai.$(OE)
HDRS = ai_local.h
OBJS = ai.$(OE) new_ai.$(OE) ccl_ai.$(OE)
include $(TOPDIR)/Common.mk

19
ai/ai.cpp Normal file
View file

@ -0,0 +1,19 @@
// ___________ _________ _____ __
// \_ _____/______ ____ ____ \_ ___ \____________ _/ ____\/ |_
// | __) \_ __ \_/ __ \_/ __ \/ \ \/\_ __ \__ \\ __\\ __\
// | \ | | \/\ ___/\ ___/\ \____| | \// __ \| | | |
// \___ / |__| \___ >\___ >\______ /|__| (____ /__| |__|
// \/ \/ \/ \/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// FreeCraft - A free fantasy real time strategy game engine
//
/**@name new_ai.c - The new computer player AI main file. */
/*
** (c) Copyright 2000 by Lutz Sammer
**
** $Id$
*/
#ifdef NEW_AI // {
#endif // } NEW_AI

26
ai/ai_local.h Normal file
View file

@ -0,0 +1,26 @@
// ___________ _________ _____ __
// \_ _____/______ ____ ____ \_ ___ \____________ _/ ____\/ |_
// | __) \_ __ \_/ __ \_/ __ \/ \ \/\_ __ \__ \\ __\\ __\
// | \ | | \/\ ___/\ ___/\ \____| | \// __ \| | | |
// \___ / |__| \___ >\___ >\______ /|__| (____ /__| |__|
// \/ \/ \/ \/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// FreeCraft - A free fantasy real time strategy game engine
//
/**@name ai_local.h - The local AI header file. */
/*
** (c) Copyright 2000 by Lutz Sammer
**
** $Id$
*/
#ifndef __AI_LOCAL_H__
#define __AI_LOCAL_H__
//@{
//@}
#endif // !__AI_LOCAL_H__

View file

@ -15,6 +15,8 @@
** $Id$
*/
#ifndef NEW_AI // {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -1360,9 +1362,9 @@ global void AiTrainingComplete(Unit* unit,Unit* what)
/**
** This is called for each player, each frame.
**
** @param player The player number.
** @param player The player structure pointer.
*/
global void AiEachFrame(int player)
global void AiEachFrame(Player* player)
{
AiCommand command;
@ -1372,8 +1374,8 @@ global void AiEachFrame(int player)
return;
}
AiPlayer=&Ais[player];
DebugLevel3(__FUNCTION__": Player %d\n",player);
AiPlayer=player->Ai;
DebugLevel3(__FUNCTION__": Player %d\n",player->Player);
command = AiPlayer->Commands[AiPlayer->CmdIndex];
if(AiPlayer->GoalHead->Next == 0)
{
@ -1394,15 +1396,15 @@ global void AiEachFrame(int player)
/**
** This called for each player, each second.
**
** @param player The player number.
** @param player The player structure pointer.
*/
global void AiEachSecond(int player)
global void AiEachSecond(Player* player)
{
DebugLevel3(__FUNCTION__": Player %d\n",player);
DebugLevel3(__FUNCTION__": Player %d\n",player->Player);
if( AiSleep ) { // wait some time. FIXME: see above
return;
}
AiPlayer=&Ais[player]; // Prepare ai.
AiPlayer=player->Ai; // Prepare ai.
AiAssignWorker();
if(AiCommandAttack(UnitBallista,
ForceAttacking[AiPlayer->CurrentAttack].Ballista,
@ -1419,18 +1421,19 @@ global void AiEachSecond(int player)
/**
** Setup all at start.
**
** @param player The player number.
** @param player The player structure pointer.
*/
global void AiInit(int player)
global void AiInit(Player* player)
{
int i;
int j;
PlayerAi* aip;
Unit* units[MAX_UNITS];
DebugLevel2(__FUNCTION__": Player %d\n",player);
aip=&Ais[player];
aip->Player=&Players[player];
DebugLevel2(__FUNCTION__": Player %d\n",player->Player);
player->Ai=aip=&Ais[player->Player];
aip->Player=player;
for(i=0; i<UnitTypeMax/(sizeof(int)*8); ++i) {aip->Build[i]=0;}
aip->GoalHead=(AiGoal*)&aip->GoalNil1;
aip->GoalNil1=(AiGoal*)0;
@ -1453,9 +1456,9 @@ global void AiInit(int player)
//
for( i=0; i<UnitTypeInternalMax; ++i ) {
for( j=0; j<MaxCosts; ++j ) {
UnitTypes[i].Stats[player].Costs[j]*=
UnitTypes[i].Stats[player->Player].Costs[j]*=
j==TimeCost ? AiTimeFactor : AiCostFactor;
UnitTypes[i].Stats[player].Costs[j]/=100;
UnitTypes[i].Stats[player->Player].Costs[j]/=100;
}
}
@ -1467,3 +1470,4 @@ global void AiInit(int player)
}
#endif // } NEW_AI

37
ai/script_ai.cpp Normal file
View file

@ -0,0 +1,37 @@
// ___________ _________ _____ __
// \_ _____/______ ____ ____ \_ ___ \____________ _/ ____\/ |_
// | __) \_ __ \_/ __ \_/ __ \/ \ \/\_ __ \__ \\ __\\ __\
// | \ | | \/\ ___/\ ___/\ \____| | \// __ \| | | |
// \___ / |__| \___ >\___ >\______ /|__| (____ /__| |__|
// \/ \/ \/ \/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// FreeCraft - A free fantasy real time strategy game engine
//
/**@name ccl_ai.c - The AI ccl functions. */
/*
** (c) Copyright 2000 by Lutz Sammer
**
** $Id$
*/
//@{
#include <stdio.h>
#include <stdlib.h>
#include "clone.h"
#if defined(USE_CCL) || defined(USE_CCL2) // {
/**
** Register CCL features for unit-type.
*/
global void AiCclRegister(void)
{
// FIXME: Need to save memory here.
}
#endif // } USE_CCL && USE_CCL2
//@}

View file

@ -36,18 +36,4 @@ HDRS = actions.h ai.h ccl.h clone.h construct.h cursor.h font.h icons.h \
all:
echo done.
doc: $(HDRS:.h=.doc)
distlist::
#echo src/include/Makefile >>$(DISTLIST)
@for i in $(HDRS) ; do echo src/include/$$i >>$(DISTLIST) ; done
ci::
@ci -l Makefile
@for i in $(HDRS) ; do ci -l $$i ; done
lockver::
@for i in $(HDRS) ; do $(LOCKVER) $$i ; done
@$(LOCKVER) Makefile
include $(TOPDIR)/Common.mk