algo

package
v0.0.0-...-961e209 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TIME_MILLISECONDE = 5000
	ENERGY_MAX_ATTACK = 10
	MAX_CELLULES      = 9
	MAX_VALEUR        = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Algo

type Algo struct {
	Name       string
	ID         string
	Pc         structure.ProgrammeContainer
	InfosGrid  structure.GridInfos
	Psi        structure.ProgrammeStatusInfos
	StatusCode int
}

func NewAlgo

func NewAlgo(name string) (algo *Algo, err error)

func (*Algo) CaptureCellData

func (a *Algo) CaptureCellData(celluleID int, index int) (ok bool, err error)

func (*Algo) CaptureCellEnergy

func (a *Algo) CaptureCellEnergy(celluleID int, index int) (ok bool, err error)

func (*Algo) CaptureTargetData

func (a *Algo) CaptureTargetData(celluleID int, targetID string) (ok bool, err error)

func (*Algo) CaptureTargetEnergy

func (a *Algo) CaptureTargetEnergy(celluleID int, targetID string) (ok bool, err error)

func (*Algo) Delete

func (a *Algo) Delete() (ok bool, err error)

func (*Algo) Destroy

func (a *Algo) Destroy(celluleID int, targetID string, energy int) (ok bool, res []byte, err error)

func (*Algo) DestroyZone

func (a *Algo) DestroyZone(celluleID int, energy int) (ok bool, res []byte, err error)

func (*Algo) Equilibrium

func (a *Algo) Equilibrium() (ok bool, err error)

func (*Algo) EstimateMove

func (a *Algo) EstimateMove(secteurID string, zoneID string) (data structure.MoveEstimateData, err error)

func (*Algo) ExplorationStop

func (a *Algo) ExplorationStop() (ok bool, err error)

func (*Algo) Explore

func (a *Algo) Explore(celluleID int) (ok bool, res []byte, err error)

func (*Algo) GetInfosProgramme

func (a *Algo) GetInfosProgramme() (ok bool, err error)

func (*Algo) GetProgramme

func (a *Algo) GetProgramme() (ok bool, programmes []string)

func (*Algo) GetStatusGrid

func (a *Algo) GetStatusGrid() (err error)

func (*Algo) GetZoneinfos

func (a *Algo) GetZoneinfos() (ok bool, zoneInfos structure.ZoneInfos)

func (*Algo) Move

func (a *Algo) Move(secteurID string, zoneID string) (ok bool, err error)

func (*Algo) NavigationStop

func (a *Algo) NavigationStop() (ok bool, err error)

func (*Algo) PrintInfo

func (a *Algo) PrintInfo(printGrid bool)

func (*Algo) PushFlag

func (a *Algo) PushFlag() (ok bool, err error)

func (*Algo) Rebuild

func (a *Algo) Rebuild(celluleID int, targetID string, energy int) (ok bool, res []byte, err error)

func (*Algo) Scan

func (a *Algo) Scan() (ok bool, res []byte, err error)

func (*Algo) SearchEnergy

func (a *Algo) SearchEnergy(cellules []structure.CelluleInfos) (index int)

func (*Algo) SearchFlag

func (a *Algo) SearchFlag(cellules []structure.CelluleInfos) (flagFound bool)
func (a *Algo) Attack(celluleID int, targetID string) {
	for j := 0; j < ENERGY_MAX_ATTACK; j++ {
		if ok, res, _ := a.Destroy(celluleID, targetID); !ok {
			jsonPretty, _ := tools.PrettyString(res)
			fmt.Println(jsonPretty)
			tools.Fail("erreur attack")
			return
		}
	}
}
func (a *Algo) Defense(celluleID int, targetID string) {
	for j := 0; j < ENERGY_MAX_ATTACK; j++ {
		if ok, resBuild, _ := a.Rebuild(celluleID, targetID); !ok {
			jsonPretty, _ := tools.PrettyString(resBuild)
			fmt.Println(jsonPretty)
			tools.Fail("erreur rebuild")
			break
		}
	}
}
func (a *Algo) CheckAttack(printInfo bool) {
	maxValeur := a.Psi.Programme.Level * MAX_VALEUR
	for _, cellule := range a.Psi.Programme.Cellules {
		if cellule.CurrentAccesLog.ReceiveDestroy {
			title := aurora.BgYellow("xxx Receveive destroy from")
			tools.Title(fmt.Sprintf(
				"\t%s >>> [%s] cellule [%d]",
				title,
				aurora.Cyan(cellule.CurrentAccesLog.PID),
				cellule.ID,
			))
		}
		if cellule.Valeur < maxValeur && cellule.Energy > 0 {
			if ok, resBuild, _ := a.Rebuild(cellule.ID, a.ID); !ok {
				jsonPretty, _ := tools.PrettyString(resBuild)
				fmt.Println(jsonPretty)
				tools.Fail("erreur rebuild")
			}
			if cellule.CurrentAccesLog.ReceiveDestroy {
				if ok, res, _ := a.Destroy(cellule.ID, cellule.CurrentAccesLog.PID); !ok {
					jsonPretty, _ := tools.PrettyString(res)
					fmt.Println(jsonPretty)
					tools.Fail("erreur attack")
				}
			}
			if printInfo {
				a.PrintInfo(false)
			}
		}
	}
	return
}

func (*Algo) StopMove

func (a *Algo) StopMove() (ok bool, err error)

func (*Algo) Unset

func (a *Algo) Unset()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL