-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo
177 lines (91 loc) · 6.93 KB
/
todo
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# vim: syntax=none nosmartindent:
Define what bin i will do. like one to generate an array (will return a list of strings), one to parse it (will need to read stdin) and solve it, one to display it, and so on.
flood-create # will output a list of strings of random from 0 to x for size_x and size_y
python should be able to display an array with two stdin : the initial array and the solution.
i would like to do what ?
soluce = $(cat array | solve)
python -array arrayfile -soluce solucestring
---------
how to sort a list based on the length of strings ?
first we need to try to update
and in python i stored 1000 versions of the board....
damn
ok, i need :
one array of 1000, of strings of size like 200. that is the path
one array of integer, that is the number of cells
one array of array of array, that is the actual situation of the board for the ith path
if i need some place in an array to study a new path, then i removed the least good path already stored, based on the number of cells
by design, i avoid paths where the previous move was identical
--
doesn't work with non square matrices...
do a print that displays in a fixed place, and just update what's need to be updated
https://codegolf.stackexchange.com/questions/26232/create-a-flood-paint-ai
i could write a version of the program that use like 10 paths, then 100, then 1000, till it is able to match the number of steps the user is willing to use.
I also need an option like maxpath=, so that i don't have to recompile
i notice that sometimes, more max_path leads to less good results
i need to store these restuls with diff max_path values, and i'll compare the coverage with board_print.
Meaning i need to modify board_print to display the evolution of the coverage, maybe at the bottom.
like step 1, xxx% covered
step 2, xxx% covered
test if a lot of boards are similars.
maybe print out all boards after solving to get an idea
----
https://stackoverflow.com/questions/2525310/how-to-define-and-work-with-an-array-of-bits-in-c
redo an analysis, maybe will start from scratch. meaning i'll have to change the print as well.
array sucks. i need to rethink that as well. note : i don't need to store the board state each time, i just need the owned cells. so i need an array of boolean, or bits. or maybe an array of integer, i would read as bits. so that would be a much shorter array btw
note : i may need 32 bits or 64 bits integer though, to do that. is that really better ?
https://scicomp.stackexchange.com/questions/19353/how-to-change-one-bit-of-a-32-bit-integer-in-c <- play with bits
wonder if i need that path*2 size thing to store all paths though
not a splitted array, but 2 arrays with a pointer, so i just swap pointers. more readable
threads later
https://stackoverflow.com/questions/11624545/how-to-make-main-thread-wait-for-all-child-threads-finish
shorter procedures, that takes a number in parameter that is the actual flood thing
flood-print takes a parameter for the solution, so i can use a variable.
flood-solve and flood-print takes a filename for the actual matrice to solve. can be -
parameters should be like -blah something, not blah=
thread for each step, one per color. each thread updates its own array (can a thread update a memory zone ?)
i hope all arrays are in memory
recap
flood_create 11 11 | flood_solve -bx 5 -by 5 -mp 5000 # will return a string
we have an array for the board
we have a struct for each solution
we have an array of solutions
if one solution has to be removed, we swap pointers to replace the old soltion by another that has to be kept (the last one?), and we -- the count of total solutions
if we have to add a solution, we add to the array.
we have to purge the array each time
not sure how to do
----
we have a list of 'owned cells' and for each, we have a path, and a percentage of cells covered
for each path, we need to do *colors - 1 other paths
ok, for each path, i do :
* check if i have one space free. if not, we find the worst, and we remove it, and we say we'll use that location to store the new 'ownership'
* if free, we inc 'used_path' (we can display memory usage percentage evolution). i think i'll use a -verbose for that, that will replace display-stats
except that static has more memory than dynamic..... but that doesn't mean i can't do what i wrote here
i have to find an easy way to find the worst coverage. i mean for example, i could keep the best coverage somewhere, and when i check a new path, i could discard it if it's n% lower (n=50 by default)
another pb : calculate new paths. if i can interact with current list, i'll destroy everythg. the system i setup is much better
should i just not touch anythg (except maybe parameters), and just do threads ?
-----
rearrange code so it's one object to solve one cube. meaning no global variables.
find a way to duplicate units to switch from one cube solved with multi thread and one cube solved with mono thread
then programe multiples cubes at once, with some parameter like 'file file file' etc, and that will be solved in multi threads. each answer will be written in the output for each cube (one cube -> oneline output, two cubes, first output is first cube, 2nd is second cube)
then check for mpi that thing
--
http://people.sc.fsu.edu/~jburkardt/c_src/mpi/mpi.html
play with mpi and thread, to process like thousands of additions of n numbers, and thread them and mpi them. maybe solving pi yeah, multithread. but without bcast.
will a thread within a thread work ?
create an object to store the initial matrice, and all global var. put also in that object the size_x, surface, etc. t_parameters should store only settings to calculate, like max mp, bx, by.
create a function to solve an input matrice (from begin to end, with appropriate t_parameters and t_matrice)
create a program to solve n matrices
OR
change program so it can solve one matrice with multiple computers, and linearise matrice solving. Not sure it's worth it, it's a lot of datas compared to the process -> no
if i solve multiple matrices at once, i don't need to create threads to update...... i have to make a choice here. but it's faster with threads ? by like 10%. for no reason.
----------------------------------------------------
1. mpi to solve one matrice, with lots of MP
2. find a way to store bits for the 'owned' thing, which is the biggest array i reckon
3. use struct to store that garbage i use to solve
4. create a type to update one color, that would be a subset of 'owneds'. like update(board, owneds[4], color=5, parameters) // do i need parameters ?
----
change so that it uses parameters to open file. if file = -, then stdin
can have multiples files (-file a,b,c,d,etc)
if multiples files, then use mpi if available (is there a variable to count the number of process availables ?) -> noooo, all of that is just 'parallel'. although file=filename is good.
add an option 'delete' to delete the file once done, so i can do a bash that takes any file left. pb : all process will process the same file.