-
Notifications
You must be signed in to change notification settings - Fork 1
/
move.jl
34 lines (25 loc) · 1014 Bytes
/
move.jl
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
#=move.jl - Updates the game file with a move, accepts 1 command line argument,<filename> => database
=#
include("AI.jl")
include("dParse.jl")
module move
using dParse
using BM
using AI
using SQLite
function moveAI(database,difficulty) #Makes a move with the AI, returns the move made
#=----Parses the database and determines where pieces are on the board----=#
#= ---- Opens the Database for reading ---- =#
#database = ARGS[1] #/path/to/database/file {string}
db = SQLite.DB(database) #Opens the database gamefile
(board,gameType,seed,lastMoveID) = dParse.Parse(database)
AI.init(gameType,board,seed,"normal")
(sourcex,sourcey,targetx,targety) = AI.get_play()
move_number = lastMoveID+1
move_type = "move"
SQLite.query(db,"""INSERT INTO moves (move_number, move_type, sourcex, sourcey, targetx, targety, i_am_cheating)
VALUES ("$(move_number)","$(move_type)","$sourcex","$sourcey","$targetx","$targety", "false")""";)
return (sourcex,sourcey,targetx,targety)
end
export moveAI
end