biosphere

package module
v0.0.0-...-6dfff6f Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: MIT Imports: 10 Imported by: 0

README

biosphere

golang genetic algorithm

examples

Robot Roby

chart

生命游戏

目标
  • 生存
  • 繁衍
  • 进化
规则
  • 生命有活力
    • 用数字表示
    • 可以增加减少
    • 每次行动减少活力
  • 亲近活力多
    • 增加大量活力
  • 近亲活力少
    • 增加少量活力
行为
  1. 随机
  2. 亲近
  3. 繁殖(训练过程不实现)
    • 训练过程随机布局
    • 运行过程亲近高活力目标进行繁殖
格子状态

4 x 4 x 4 x 4 x 4 = 1024

  1. 空格子: 0
  2. 墙壁: 1
  3. 高活力: 2
  4. 低活力: 3
判定
  • 移动: 活力-1
    • 撞墙: 扣5分
  • 亲近:活力-1
    • 高活力+10分
    • 低活力+5分
    • 没有对象-1分

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bio

type Bio interface {
	// Init 初始化
	Init() []int
	// 评分
	Score(dna []int, times int) int
	// 繁殖
	Breed(parent ...[]int) []int
	// 变异
	Variation(dna []int) []int
}

Bio 生命

type Biosphere

type Biosphere struct {

	// GroupSize 族群大小
	GroupSize int
	// EvalTimes 进化次数
	EvalTimes int
	// 每代尝试次数
	TryTimes int
	// 变异次数
	VariationTimes int
	// 幸存数量
	Survival int
	// contains filtered or unexported fields
}

Biosphere 生物圈

func NewBiosphere

func NewBiosphere(bio Bio) *Biosphere

NewBiosphere 新建生物圈

func (*Biosphere) Best

func (b *Biosphere) Best(size int)

Best 显示最佳

func (*Biosphere) Chart

func (b *Biosphere) Chart(name string)

Chart 保存图表

func (*Biosphere) PrintTimes

func (b *Biosphere) PrintTimes(times ...int)

PrintTimes 输出时间

func (*Biosphere) Run

func (b *Biosphere) Run()

Run 运行

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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