package geneticchess

import ()

type TablesColor struct {
	King   [64]float64
	Queen  [64]float64
	Rook   [64]float64
	Knight [64]float64
	Bishop [64]float64
	Pawn   [64]float64
}

type TablesStage struct {
	White *TablesColor
	Black *TablesColor
}

type Tables struct {
	Beginning *TablesStage
	Endgame   *TablesStage
}

var tablePawnBeginning = [64]float64{
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+9.9, +9.9, +9.9, +9.9, +9.9, +9.9, +9.9, +9.9,
	+5.0, +5.5, +5.6, +6.0, +6.0, +5.6, +5.5, +5.0,
	+2.8, +2.8, +3.0, +3.2, +3.2, +3.0, +2.8, +2.8,
	+0.0, +0.0, +0.0, +1.8, +1.8, +0.0, +0.0, +0.0,
	+0.2, +0.0, +0.0, +0.2, +0.2, +0.0, +0.0, +0.2,
	+0.1, +0.2, +0.2, -2.0, -2.0, +0.2, +0.2, +0.1,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
}

var tablePawnEndgame = [64]float64{
	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
	9.9, 9.9, 9.9, 9.9, 9.9, 9.9, 9.9, 9.9,
	6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0,
	4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0,
	2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
	1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
}

var tableKingBeginning = [64]float64{
	-3.0, -4.0, -6.0, -9.0, -9.0, -6.0, -4.0, -3.0,
	-3.0, -4.0, -6.0, -9.0, -9.0, -6.0, -4.0, -3.0,
	-3.0, -4.0, -6.0, -9.0, -9.0, -6.0, -4.0, -3.0,
	-2.5, -2.8, -4.0, -5.0, -5.0, -4.0, -2.8, -2.5,
	-1.2, -1.4, -2.8, -4.0, -4.0, -2.8, -1.4, -1.2,
	-0.1, -0.2, -0.4, -1.0, -1.0, -0.4, -0.2, -0.1,
	+0.1, +0.1, +0.0, +0.0, +0.0, +0.0, +0.1, +0.1,
	+0.2, +9.5, +8.0, -0.5, -0.5, +0.1, +9.9, +0.2,
}

var tableKingEndgame = [64]float64{
	-9.9, -6.0, -6.0, -6.0, -6.0, -6.0, -6.0, -9.9,
	-6.0, -3.0, +0.0, +0.0, +0.0, +0.0, -3.0, -6.0,
	-6.0, +0.0, +3.0, +6.0, +6.0, +3.0, +0.0, -6.0,
	-6.0, +0.0, +6.0, +9.9, +9.9, +6.0, +0.0, -6.0,
	-6.0, +0.0, +6.0, +9.9, +9.9, +6.0, +0.0, -6.0,
	-6.0, +0.0, +3.0, +6.0, +6.0, +3.0, +0.0, -6.0,
	-6.0, -3.0, +0.0, +0.0, +0.0, +0.0, -3.0, -6.0,
	-9.9, -6.0, -6.0, -6.0, -6.0, -6.0, -6.0, -9.9,
}

var tableKnight = [64]float64{
	-10.0, -8.0, -0.6, -0.6, -0.6, -0.6, -8.0, -10.0,
	-8.0, -0.5, -0.2, -0.1, -0.1, -0.2, -0.5, -8.0,
	-0.6, +0.0, +0.1, +0.2, +0.2, +0.1, +0.0, -0.6,
	-0.6, +0.1, +0.2, +0.5, +0.5, +0.2, +0.1, -0.6,
	-0.6, +0.1, +0.2, +0.5, +0.5, +0.2, +0.1, -0.6,
	-0.6, +0.0, +0.1, +0.2, +0.2, +0.1, +0.0, -0.6,
	-8.0, -0.5, -0.2, -0.1, -0.1, -0.2, -0.5, -8.0,
	-10.0, -8.0, -0.6, -0.6, -0.6, -0.6, -8.0, -10.0,
}

var tableBishop = [64]float64{
	-9.9, -8.0, -6.0, -6.0, -6.0, -6.0, -8.0, -9.9,
	-8.0, -5.0, -2.0, -1.0, -1.0, -2.0, -5.0, -8.0,
	-6.0, +0.0, +1.0, +2.0, +2.0, +1.0, +0.0, -6.0,
	-6.0, +1.0, +2.0, +9.0, +9.0, +2.0, +1.0, -6.0,
	-6.0, +1.0, +2.0, +9.0, +9.0, +2.0, +1.0, -6.0,
	-6.0, +0.0, +1.0, +2.0, +2.0, +1.0, +0.0, -6.0,
	-8.0, -5.0, -2.0, -1.0, -1.0, -2.0, -5.0, -8.0,
	-9.9, -8.0, -6.0, -6.0, -6.0, -6.0, -8.0, -9.9,
}

var tableRookBeginning = [64]float64{
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+5.0, +5.0, +5.0, +5.0, +5.0, +5.0, +5.0, +5.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	-1.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, -1.0,
}

var tableRookEndgame = [64]float64{
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
}

var tableQueen = [64]float64{
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
}

func NewTables() *Tables {
	t := &Tables{}

	t.Beginning = &TablesStage{
		White: &TablesColor{
			King:   tableKingBeginning,
			Pawn:   tablePawnBeginning,
			Knight: tableKnight,
			Bishop: tableBishop,
			Rook:   tableRookBeginning,
			Queen:  tableQueen,
		},
		Black: &TablesColor{
			King:   t.mirror(tableKingBeginning),
			Pawn:   t.mirror(tablePawnBeginning),
			Knight: t.mirror(tableKnight),
			Bishop: t.mirror(tableBishop),
			Rook:   t.mirror(tableRookBeginning),
			Queen:  t.mirror(tableQueen),
		},
	}
	t.Endgame = &TablesStage{
		White: &TablesColor{
			King:   tableKingEndgame,
			Pawn:   tablePawnEndgame,
			Knight: tableKnight,
			Bishop: tableBishop,
			Rook:   tableRookEndgame,
			Queen:  tableQueen,
		},
		Black: &TablesColor{
			King:   t.mirror(tableKingEndgame),
			Pawn:   t.mirror(tablePawnEndgame),
			Knight: t.mirror(tableKnight),
			Bishop: t.mirror(tableBishop),
			Rook:   t.mirror(tableRookEndgame),
			Queen:  t.mirror(tableQueen),
		},
	}

	return t
}

func (tbl *Tables) mirror(t [64]float64) [64]float64 {
	return [64]float64{
		t[56], t[57], t[58], t[59], t[60], t[61], t[62], t[63],
		t[48], t[49], t[50], t[51], t[52], t[53], t[54], t[55],
		t[40], t[41], t[42], t[43], t[44], t[45], t[46], t[47],
		t[32], t[33], t[34], t[35], t[36], t[37], t[38], t[39],
		t[24], t[25], t[26], t[27], t[28], t[29], t[30], t[31],
		t[16], t[17], t[18], t[19], t[20], t[21], t[22], t[23],
		t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15],
		t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7],
	}
}
package geneticchess

import ()

type TablesColor struct {
	King   [64]float64
	Queen  [64]float64
	Rook   [64]float64
	Knight [64]float64
	Bishop [64]float64
	Pawn   [64]float64
}

type TablesStage struct {
	White *TablesColor
	Black *TablesColor
}

type Tables struct {
	Beginning *TablesStage
	Endgame   *TablesStage
}

var tablePawnBeginning = [64]float64{
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+9.9, +9.9, +9.9, +9.9, +9.9, +9.9, +9.9, +9.9,
	+5.0, +5.5, +5.6, +6.0, +6.0, +5.6, +5.5, +5.0,
	+2.8, +2.8, +3.0, +3.2, +3.2, +3.0, +2.8, +2.8,
	+0.0, +0.0, +0.0, +1.8, +1.8, +0.0, +0.0, +0.0,
	+0.2, +0.0, +0.0, +0.2, +0.2, +0.0, +0.0, +0.2,
	+0.1, +0.2, +0.2, -2.0, -2.0, +0.2, +0.2, +0.1,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
}

var tablePawnEndgame = [64]float64{
	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
	9.9, 9.9, 9.9, 9.9, 9.9, 9.9, 9.9, 9.9,
	6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0,
	4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0,
	2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
	1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
}

var tableKingBeginning = [64]float64{
	-3.0, -4.0, -6.0, -9.0, -9.0, -6.0, -4.0, -3.0,
	-3.0, -4.0, -6.0, -9.0, -9.0, -6.0, -4.0, -3.0,
	-3.0, -4.0, -6.0, -9.0, -9.0, -6.0, -4.0, -3.0,
	-2.5, -2.8, -4.0, -5.0, -5.0, -4.0, -2.8, -2.5,
	-1.2, -1.4, -2.8, -4.0, -4.0, -2.8, -1.4, -1.2,
	-0.1, -0.2, -0.4, -1.0, -1.0, -0.4, -0.2, -0.1,
	+0.1, +0.1, +0.0, +0.0, +0.0, +0.0, +0.1, +0.1,
	+0.2, +9.5, +8.0, -0.5, -0.5, +0.1, +9.9, +0.2,
}

var tableKingEndgame = [64]float64{
	-9.9, -6.0, -6.0, -6.0, -6.0, -6.0, -6.0, -9.9,
	-6.0, -3.0, +0.0, +0.0, +0.0, +0.0, -3.0, -6.0,
	-6.0, +0.0, +3.0, +6.0, +6.0, +3.0, +0.0, -6.0,
	-6.0, +0.0, +6.0, +9.9, +9.9, +6.0, +0.0, -6.0,
	-6.0, +0.0, +6.0, +9.9, +9.9, +6.0, +0.0, -6.0,
	-6.0, +0.0, +3.0, +6.0, +6.0, +3.0, +0.0, -6.0,
	-6.0, -3.0, +0.0, +0.0, +0.0, +0.0, -3.0, -6.0,
	-9.9, -6.0, -6.0, -6.0, -6.0, -6.0, -6.0, -9.9,
}

var tableKnight = [64]float64{
	-10.0, -8.0, -0.6, -0.6, -0.6, -0.6, -8.0, -10.0,
	-8.0, -0.5, -0.2, -0.1, -0.1, -0.2, -0.5, -8.0,
	-0.6, +0.0, +0.1, +0.2, +0.2, +0.1, +0.0, -0.6,
	-0.6, +0.1, +0.2, +0.5, +0.5, +0.2, +0.1, -0.6,
	-0.6, +0.1, +0.2, +0.5, +0.5, +0.2, +0.1, -0.6,
	-0.6, +0.0, +0.1, +0.2, +0.2, +0.1, +0.0, -0.6,
	-8.0, -0.5, -0.2, -0.1, -0.1, -0.2, -0.5, -8.0,
	-10.0, -8.0, -0.6, -0.6, -0.6, -0.6, -8.0, -10.0,
}

var tableBishop = [64]float64{
	-9.9, -8.0, -6.0, -6.0, -6.0, -6.0, -8.0, -9.9,
	-8.0, -5.0, -2.0, -1.0, -1.0, -2.0, -5.0, -8.0,
	-6.0, +0.0, +1.0, +2.0, +2.0, +1.0, +0.0, -6.0,
	-6.0, +1.0, +2.0, +9.0, +9.0, +2.0, +1.0, -6.0,
	-6.0, +1.0, +2.0, +9.0, +9.0, +2.0, +1.0, -6.0,
	-6.0, +0.0, +1.0, +2.0, +2.0, +1.0, +0.0, -6.0,
	-8.0, -5.0, -2.0, -1.0, -1.0, -2.0, -5.0, -8.0,
	-9.9, -8.0, -6.0, -6.0, -6.0, -6.0, -8.0, -9.9,
}

var tableRookBeginning = [64]float64{
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+5.0, +5.0, +5.0, +5.0, +5.0, +5.0, +5.0, +5.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	-1.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, -1.0,
}

var tableRookEndgame = [64]float64{
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
}

var tableQueen = [64]float64{
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
	+0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0, +0.0,
}

func NewTables() *Tables {
	t := &Tables{}

	t.Beginning = &TablesStage{
		White: &TablesColor{
			King:   tableKingBeginning,
			Pawn:   tablePawnBeginning,
			Knight: tableKnight,
			Bishop: tableBishop,
			Rook:   tableRookBeginning,
			Queen:  tableQueen,
		},
		Black: &TablesColor{
			King:   t.mirror(tableKingBeginning),
			Pawn:   t.mirror(tablePawnBeginning),
			Knight: t.mirror(tableKnight),
			Bishop: t.mirror(tableBishop),
			Rook:   t.mirror(tableRookBeginning),
			Queen:  t.mirror(tableQueen),
		},
	}
	t.Endgame = &TablesStage{
		White: &TablesColor{
			King:   tableKingEndgame,
			Pawn:   tablePawnEndgame,
			Knight: tableKnight,
			Bishop: tableBishop,
			Rook:   tableRookEndgame,
			Queen:  tableQueen,
		},
		Black: &TablesColor{
			King:   t.mirror(tableKingEndgame),
			Pawn:   t.mirror(tablePawnEndgame),
			Knight: t.mirror(tableKnight),
			Bishop: t.mirror(tableBishop),
			Rook:   t.mirror(tableRookEndgame),
			Queen:  t.mirror(tableQueen),
		},
	}

	return t
}

func (tbl *Tables) mirror(t [64]float64) [64]float64 {
	return [64]float64{
		t[56], t[57], t[58], t[59], t[60], t[61], t[62], t[63],
		t[48], t[49], t[50], t[51], t[52], t[53], t[54], t[55],
		t[40], t[41], t[42], t[43], t[44], t[45], t[46], t[47],
		t[32], t[33], t[34], t[35], t[36], t[37], t[38], t[39],
		t[24], t[25], t[26], t[27], t[28], t[29], t[30], t[31],
		t[16], t[17], t[18], t[19], t[20], t[21], t[22], t[23],
		t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15],
		t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7],
	}
}
