flag

package
v0.0.0-...-0992052 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

flag contains a battleline flag.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flag

type Flag struct {
	Players [2]*Player
}

Flag the structer of the flag.

func New

func New() (flag *Flag)

New creates a flag.

func (*Flag) ClaimFlag

func (flag *Flag) ClaimFlag(playerix int, unPlayCards []int) (ok bool, eks []int)

ClaimFlag claims a flag if possible. Its only possible to claim a flag if player have a formation, if both players have a formation it is easy, or if player have the highest formation. The main task is calculate the highest possible formation. I do not have a plan yet but I think we need brute force, but If we are missing four cards and only one combi exist, it's 53*52*51*54=0/24 permutaitions ca 300.000 and how do generate them. The player's formation do limit the possible formation to the ones that are better but again that may be many all to be exact, but if we find one that is better we can stop. I see 3 option:

  1. Just try all permution and if one is higher stop.
  2. For every combination try to make one with the remaining cards
  3. A combination a quick check if player have two troops many combination can be ruled out. color, value and bigger bridge than 2 no line. These three check give a max combination. ranging from top to button

Made permutaitor and will try that first it may be quick ennough. Have the plan for the second solution. Sort the remaining cards a value/card map per color and a value slice of cards map. Then a switch with drop through on the combination and each combination function use the sorted cards

func (*Flag) Claimed

func (flag *Flag) Claimed() bool

Claimed return true if the flag is claimed.

func (*Flag) Copy

func (flag *Flag) Copy() (c *Flag)

Copy copy a flag.

func (*Flag) Env

func (flag *Flag) Env(pix int) (env []int)

Env makes a slice with envirement tactic cards. may be empty.

func (*Flag) Equal

func (flag *Flag) Equal(o *Flag) (equal bool)

Equal tests for equal.

func (*Flag) Formations

func (flag *Flag) Formations() (form [2]*cards.Formation)

Formations returns players formations.

func (*Flag) Free

func (flag *Flag) Free() (v [2]bool)

Free check if there is space for a card on the flag.

func (*Flag) Remove

func (flag *Flag) Remove(cardix int, playerix int) (mudix0 int, mudix1 int, err error)

Remove removes a card from the flag. mudix0 contains a card if removal of the mud card result in an excess card for player 0/1

func (*Flag) Set

func (flag *Flag) Set(cardix int, playerix int) (err error)

Set a card.

func (*Flag) String

func (flag *Flag) String() (txt string)

func (*Flag) Troops

func (flag *Flag) Troops(pix int) (troops []int)

Troops makes a slice with troops maybe empty.

func (*Flag) UsedTac

func (flag *Flag) UsedTac() (v [2][]int)

UsedTac collects the used tactic cards.

func (*Flag) Won

func (flag *Flag) Won() (res [2]bool)

Won returns players won.

type Player

type Player struct {
	Won       bool
	Env       [2]int
	Troops    [4]int
	Formation *cards.Formation
	Strenght  int
}

Player the structer for player details of the flag.

func (*Player) Equal

func (player *Player) Equal(other *Player) (equal bool)

Equal test for equal.

func (*Player) String

func (player *Player) String() (txt string)

Jump to

Keyboard shortcuts

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