Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57d3068
commit c3e38a2
Showing
7 changed files
with
95 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
OpenAlchemistAI | ||
=============== | ||
|
||
An AI for the game OpenAlchemist (http://www.openalchemist.com/) | ||
An AI for the game OpenAlchemist (http://www.openalchemist.com/) | ||
|
||
What does it do | ||
--------------- | ||
|
||
Hopefully, play OpenAlchemist on its own, at least the "thinking part", even if it still requires you to move the objects yourself with your keyboard. | ||
The goal is to have an AI that can calculate the best moves and do better than my poor brain. | ||
|
||
How to use it | ||
------------- | ||
|
||
Run the executable while your new game of OpenAlchemist is open and visible on your desktop. It will give you the best move it thinks you should play, in the form of a tuple of Tile,Column, where Column starts at 0. | ||
|
||
How does it work | ||
---------------- | ||
|
||
For the moment, it doesn't use any API from OpenAlchemist since it looked like everything was C++. So it capture the window where the game is running, tries to "see" what the game is, what the next | ||
objects to play are, and then calculate the best move. | ||
The best move is calculated taking into account the current state of the game, the two objects that have to be played, and the two objects that will come afterwards. | ||
|
||
Code organization | ||
----------------- | ||
|
||
There are three source folders: | ||
|
||
* exe: the executable entry point | ||
* src: the main source code | ||
+ Game is the game handling (resolve object collapse and such) and AI code | ||
+ Types contains the type definitions | ||
+ Vision performs the capturing and detection of shapes | ||
* test: contains the unit tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
-- | The executable entry point | ||
module Main where | ||
|
||
import Games.OpenAlchemist.AI.Game | ||
import Games.OpenAlchemist.AI.Vision | ||
import Games.OpenAlchemist.AI.Types | ||
|
||
-- | entry point | ||
main::IO() | ||
main = do | ||
IconFingerPrint smallMM bigMM<-getIconFingerPrint | ||
mpcis<-getGamePicture | ||
IconFingerPrint smallMM bigMM<-getIconFingerPrint -- get icons fingerprint | ||
mpcis<-getGamePicture -- capture picture of game | ||
case mpcis of | ||
Nothing -> return () | ||
Just (preview,toplay,existing)->do | ||
let smallFound=find smallMM preview | ||
-- debugging | ||
let smallFound=find smallMM preview -- see what shapes are in the preview | ||
print smallFound | ||
let bigFound1=find bigMM toplay | ||
let bigFound1=find bigMM toplay -- see what shapes are there to play | ||
print bigFound1 | ||
let bigFound2=find bigMM existing | ||
let bigFound2=find bigMM existing -- see the existing state of the game | ||
print bigFound2 | ||
let previewTiles=findTiles smallMM preview | ||
let previewTiles=findTiles smallMM preview -- get the preview tiles | ||
print previewTiles | ||
let toPlayTiles=findTiles bigMM toplay | ||
let toPlayTiles=findTiles bigMM toplay -- get the current tiles | ||
print toPlayTiles | ||
let game=readGame bigMM existing | ||
let game=readGame bigMM existing -- get the game | ||
print game | ||
let advice=bestOn2 game toPlayTiles previewTiles | ||
let advice=bestOn2 game toPlayTiles previewTiles -- calculate best move | ||
print advice | ||
return() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
-- | test entry point | ||
module Main where | ||
|
||
import Games.OpenAlchemist.AI.GameTests | ||
|