Procedure DataExtraction |
Input: |
statesD, the data table of PiecesState in database. |
files: the XML files of game-logs. |
Output: Non. |
Method: |
(01) let stateIds be the set of PiecesState ids; |
(02) let file be a file of game-log; |
(03) let statesF be the set of the pieces-states extracted from game-logs; |
(04) let newStateId be the new PiecesState id; |
(05) while files.empty == false do |
(06) file = files.getOne(); //Read a game-log. |
(07) Extract the pieces-states from file, and save them to statesF; |
(08) Extract the game result from file, and save it to result; |
(09) for = 0 to statesF.length − 1 do |
(10) //Get the sequence of ids of PiecesState. |
(11) ifFound = false; |
(12) Update the times field of CheckerUsage with statesF[i]. |
(13) for = 0 to statesD.length − 1 do |
(14) if equal(statesF[i], statesD[j].state) then |
(15) stateIds.add(statesD[].id); |
(16) isFound = true; |
(17) count += result; |
(18) break; |
(19) endif |
(20) endfor |
(21) if isFound == false then |
(22) Insert statesF[i] into PiecesState; |
(23) count = result; |
(24) Save the new id to newStateId. |
(25) stateIds.add(newStateId); |
(26) statesD.add(newStateId, statesF[i]); |
(27) endif |
(28) endfor |
(29) if result != 0 then |
(30) = 1; |
(31) if result == then |
(32) = 0; |
(33) endif |
(34) for = 0 to stateIds.length − 1 do |
(35) stateIds[] *= (−1) ∧ (() % 2); |
(36) endfor |
(37) endif |
(38) sequenceString = stateIds[]; |
(39) for = 0 to stateIds.length − 1 do |
(40) sequenceString += (“:” + stateIds[]); |
(41) endfor |
(42) Insert sequenceString into PiecesStateSequence; |
(43) delete(file); //Delete the current game-log. |
(44) endwhile |