<commit_before>- title : EvoDistroLisa - EvoLisa reborn
- description : EvoDistroLisa - EvoLisa reborn
- author : <NAME>
- theme : beige
- transition : default

***

## EvoDistroLisa - EvoLisa resurected by Agents

youtube: http://goo.gl/g6hnnm
blog: http://goo.gl/UY48nn
github: https://goo.gl/9kBDiI

***

### About me

- <NAME>
- BLOBAs @ Sepura
- first line of code written in ~1984
- C, C++, C#, SQL, Java
- (Iron)Python, F#, Scala

---

### Background

- Algorithms
- Data Structures
- Algorithm Complexity
- Graph Theory
- Design Patterns

---

### Most recently

- Parallel
- Distributed
- Reactive
- Functional

***

### Domain

---

### Point

	[lang=fs]
	type Point = { X: double; Y: double }

---

### Color & Brush

 	[lang=fs]
	type Color = { R: double; G: double; B: double }
	type Brush = { A: double; Color: Color }

---

### Polyline & Polygon

	[lang=fs]
	type Polyline = Point list
	type Polygon = { Brush: Brush; Points: Polyline }

---

### Pixels

	[lang=fs]
	type Pixels = { Width: int; Height: int; Pixels: uint32 array }

---

### Scene & RenderedScene

	[lang=fs]
	type Scene = { Polygons: Polygon list }
	type RenderedScene = { Scene: Scene; Fitness: double }

---

### Renderer & Fitter

	[lang=fs]
	type Renderer = Scene -> Pixels
	type Fitter = Pixels -> double

---

### Mutator

	[lang=fs]
	type Mutator = Scene -> Scene

---

### RNG

	[lang=fs]
	type RNG = unit -> double

---

### Factories

	[lang=fs]
	type MutatorFactory = RNG -> Mutator
	type FitterFactory = Pixels -> Fitter


### What are design patterns?

> [...] general reusable solution to a commonly occurring problem within a given context [...] -- **Wikipedia**

---

### What's wrong with OO design patterns?

- Are design patterns missing language features?
- Some patterns are actually anti-patterns
- Abuse of design patterns
- Design patterns are often too heavy

---
<commit_msg>working on slides<commit_after>- title : EvoDistroLisa - EvoLisa reborn
- description : EvoDistroLisa - EvoLisa reborn
- author : <NAME>
- theme : beige
- transition : default

***

## EvoDistroLisa - EvoLisa resurected by Agents

youtube: http://goo.gl/g6hnnm
blog: http://goo.gl/UY48nn
github: https://goo.gl/9kBDiI

***

### About me

- <NAME>
- BLOBAs @ Sepura
- first line of code written in ~1984
- C, C++, C#, SQL, Java
- (Iron)Python, F#, Scala

---

### Background

- Algorithms
- Data Structures
- Algorithm Complexity
- Graph Theory
- Design Patterns

---

### Most recently

- Parallel
- Distributed
- Reactive
- Functional

***

### Domain

Note: the code presented is usually a little bit idealized with "implementation induced ugliness" removed

---

### Point

	[lang=fs]
	type Point = { X: double; Y: double }

---

### Color & Brush

 	[lang=fs]
	type Brush = { A: double; R: double; G: double; B: double }

---

### Polyline & Polygon

	[lang=fs]
	type Polyline = Point array
	type Polygon = { Brush: Brush; Points: Polyline }

---

### Pixels

	[lang=fs]
	type Pixels = { Width: int; Height: int; Pixels: uint32 array }

---

### Scene & RenderedScene

	[lang=fs]
	type Scene = { Polygons: Polygon array }
	type RenderedScene = { Scene: Scene; Fitness: double }

---

### Improve

	[lang=fs]
	type Mutator = Scene -> Scene
	type Renderer = Scene -> Pixels
	type Fitter = Pixels -> double

	let tryImprove mutator renderer fitter (champion: RenderedScene) =
		let challenger = champion.Scene |> mutator
		{ Scene = challenger; Fitness = challenger |> renderer |> fitter }

---

### Select

	let chooseBest publish (champion: RenderedScene) challengers =
		let fitnessOf (scene: RenderedScene) = scene.Fitness
		let challenger = challengers |> Seq.maxBy fitnessOf
		match champion.Fitness >= challenger.Fitness with
		| true -> champion
		| _ -> publish challenger; challenger

### The Loop!

	let loop mutate render fit champion outbox inbox = async {
		let inline recv () = Agent.recvMany inbox
		let inline publish scene = Agent.send outbox scene
		let inline feedback scene = Agent.send inbox scene
		let! challengers = Agent.recvMany inbox
		match select challengers chamtion with
		| Champion _ -> champion
		| Challenger challenger ->
			outbox |> Agent.send challenger
			challenger
		|> improve mutate render fit
		|>
	}


---

### Random Number Generator

	[lang=fs]
	type RNG = unit -> double

---

### Let's mutatate

    [lang=fs]
    let mutateScene rng scene =
        { scene with
			Polygons = mutatePolygons rng scene.Polygons }

---

	[lang=fs]
	let mutatePolygons rng polygons =
		polygons
		|> removePolygon rng
		|> insertPolygon rng
		|> shufflePolygons rng
		|> Array.map (mutatePolygon rng)

---

	[lang=fs]
	let mutatePolygon rng polygon =
		{ polygon with
			Brush = mutateBrush rng polygon.Brush
			Points = mutatePoints rng polygon.Points }

---

	[lang=fs]
	let mutateBrush rng brush =
		{ brush with
			A = mutateValue rng brush.A
			R = mutateValue rng brush.R
			G = mutateValue rng brush.G
			B = mutateValue rng brush.B }

---

	[lang=fs]
	let mutatePoints rng points =
		points
		|> removePoint rng
		|> insertPoint rng
		|> shufflePoints rng
		|> Array.map (mutatePoint rng)

---

	[lang=fs]
	let mutatePoint rng point =
		{ point with
			X = mutateValue rng point.X
			Y = mutateValue rng point.Y }

---

### What are design patterns?

> [...] general reusable solution to a commonly occurring problem within a given context [...] -- **Wikipedia**

---

### What's wrong with OO design patterns?

- Are design patterns missing language features?
- Some patterns are actually anti-patterns
- Abuse of design patterns
- Design patterns are often too heavy

---

{'fraction_non_alphanumeric': 0.1269869619574924, 'fraction_numerical': 0.003572066440435792, 'mean_word_length': 3.0756914119359533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5497331', 'n_tokens_mistral': 2076, 'n_tokens_neox': 1895, 'n_words': 598}