-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcjalgorithm.h
53 lines (39 loc) · 1.21 KB
/
cjalgorithm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* cjalgorithm.m
* Typing
*
* Created by Chris Johnson and Michael Dickens.
*
*/
#ifndef __CJALGORITHM_H__
#define __CJALGORITHM_H__
#include <limits.h>
#include "keyboard.h"
#define FILE_READ_NOT_HAPPEN -100
struct ThreadArg {
Keyboard bestk;
int numRounds;
double chanceToUsePreviousLayout;
int numberOfSwaps;
time_t startTime;
/* Indicates that the subroutine should keep creating new threads until
* this reaches 0.
*/
int numThreads;
/* Indicates whether the current thread is done running. */
int isFinished;
};
void runAlgorithm();
void * runThreadsRec(void *arg);
void greatToBest(Keyboard *k, int numRounds);
void * greatToBestThreadRec(void *arg);
void greatToBestBruteForce(Keyboard *k);
void tryPermutations(Keyboard *bestk, Keyboard *k, int *origLocs, int *locs,
int length, int index);
int64_t anneal(Keyboard *k, int lockins[][2], size_t lockin_length);
int64_t improveLayout(int64_t evaluationToBeat, Keyboard *k,
int lockins[][2], size_t lockin_length);
int smartMutate(int swapIndices[][2], Keyboard *k, int numberOfSwaps);
void initThreadArg(struct ThreadArg *arg);
void copyThreadArg(struct ThreadArg *dest, struct ThreadArg *src);
#endif