All Projects → Zulko → Easyai

Zulko / Easyai

Licence: other
Python artificial intelligence framework for games

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Easyai

09 Zombierunner Original
First person shooter with Unity terrain and AI pathfinding (http://gdev.tv/cudgithub)
Stars: ✭ 64 (-88.21%)
Mutual labels:  ai, game-development
Godot Steering Ai Framework
A complete framework for Godot to create beautiful and complex AI motion. Works both in 2D and in 3D.
Stars: ✭ 482 (-11.23%)
Mutual labels:  ai, game-development
04 battletank
An open-world head-to-head tank fight with simple AI, terrain, and advanced control system in Unreal 4. (ref: BT_URC) http://gdev.tv/urcgithub
Stars: ✭ 172 (-68.32%)
Mutual labels:  ai, game-development
Unity3d Ai And Procedural Generation Framework
Unity3D AI and Procedural Generation Framework.
Stars: ✭ 58 (-89.32%)
Mutual labels:  ai, game-development
Godot 2d Space Game
A 2D space exploration and mining game made with Godot and our AI framework
Stars: ✭ 462 (-14.92%)
Mutual labels:  ai, game-development
Anakin
High performance Cross-platform Inference-engine, you could run Anakin on x86-cpu,arm, nv-gpu, amd-gpu,bitmain and cambricon devices.
Stars: ✭ 488 (-10.13%)
Mutual labels:  ai
Roygbiv
A 3D engine for the Web
Stars: ✭ 499 (-8.1%)
Mutual labels:  game-development
Unity Build
A powerful automation tool for quickly and easily generating builds of a game with Unity.
Stars: ✭ 483 (-11.05%)
Mutual labels:  game-development
Xray Oxygen
🌀 Oxygen Engine 2.0. [Preview] Discord: https://discord.gg/P3aMf66
Stars: ✭ 481 (-11.42%)
Mutual labels:  ai
Silk.net
The high-speed OpenAL, OpenGL, Vulkan, and GLFW bindings library your mother warned you about.
Stars: ✭ 534 (-1.66%)
Mutual labels:  game-development
Hedera
paint 3D ivy in the Unity Editor, watch procedurally generated meshes simulate growth and clinging in real-time
Stars: ✭ 526 (-3.13%)
Mutual labels:  game-development
Awesome Coreml Models
Collection of models for Core ML
Stars: ✭ 500 (-7.92%)
Mutual labels:  ai
Engine Native
Native engine for Cocos Creator
Stars: ✭ 488 (-10.13%)
Mutual labels:  game-development
Holodeck
High Fidelity Simulator for Reinforcement Learning and Robotics Research.
Stars: ✭ 513 (-5.52%)
Mutual labels:  ai
Texturepanner
This repository hosts a shader for Unity3D whose main goal is to facilitate the creation of neon-like signs, conveyor belts and basically whatever based on scrolling textures
Stars: ✭ 528 (-2.76%)
Mutual labels:  game-development
Legend Wings
iOS Swift Game - Push SpriteKit to the limit
Stars: ✭ 481 (-11.42%)
Mutual labels:  game-development
Lollipopgo
稳定分支2.9.X 版本已更新,由【Golang语言游戏服务器】维护,全球服游戏服务器及区域服框架,目前协议支持websocket、http、KCP、TCP及RPC,采用状态同步(帧同步内测),愿景:打造MMO多人竞技游戏框架! 功能持续更新中... ...
Stars: ✭ 500 (-7.92%)
Mutual labels:  game-development
Fontainebleaudemo
Fontainebleau demo
Stars: ✭ 524 (-3.5%)
Mutual labels:  game-development
Java Sdk
百度AI开放平台 Java SDK
Stars: ✭ 495 (-8.84%)
Mutual labels:  ai
Tetra
🎮 A simple 2D game framework written in Rust
Stars: ✭ 492 (-9.39%)
Mutual labels:  game-development

easyAI

EasyAI (full documentation here_) is a pure-Python artificial intelligence framework for two-players abstract games such as Tic Tac Toe, Connect 4, Reversi, etc. It makes it easy to define the mechanisms of a game, and play against the computer or solve the game. Under the hood, the AI is a Negamax algorithm with alpha-beta pruning and transposition tables as described on Wikipedia_.

Installation

If you have pip installed, type this in a terminal ::

sudo pip install easyAI

Otherwise, download the source code (for instance on Github_), unzip everything into one folder and in this folder, in a terminal, type ::

sudo python setup.py install

Additionally you will need to install Numpy to be able to run some of the examples.

A quick example

Let us define the rules of a game and start a match against the AI:

.. code:: python

from easyAI import TwoPlayersGame, Human_Player, AI_Player, Negamax

class GameOfBones( TwoPlayersGame ):
    """ In turn, the players remove one, two or three bones from a
    pile of bones. The player who removes the last bone loses. """
        
    def __init__(self, players):
        self.players = players
        self.pile = 20 # start with 20 bones in the pile
        self.nplayer = 1 # player 1 starts

    def possible_moves(self): return ['1','2','3']
    def make_move(self,move): self.pile -= int(move) # remove bones.
    def win(self): return self.pile<=0 # opponent took the last bone ?
    def is_over(self): return self.win() # Game stops when someone wins.
    def show(self): print ("%d bones left in the pile" % self.pile)
    def scoring(self): return 100 if game.win() else 0 # For the AI

# Start a match (and store the history of moves when it ends)
ai = Negamax(13) # The AI will think 13 moves in advance 
game = GameOfBones( [ Human_Player(), AI_Player(ai) ] )
history = game.play()

Result: ::

20 bones left in the pile

Player 1 what do you play ? 3

Move #1: player 1 plays 3 :
17 bones left in the pile

Move #2: player 2 plays 1 :
16 bones left in the pile

Player 1 what do you play ?

Solving the game


Let us now solve the game:

.. code:: python

from easyAI import id_solve
r,d,m = id_solve(GameOfBones, ai_depths=range(2,20), win_score=100)

We obtain r=1, meaning that if both players play perfectly, the first player to play can always win (-1 would have meant always lose), d=10, which means that the wins will be in ten moves (i.e. 5 moves per player) or less, and m='3', which indicates that the first player's first move should be '3'.

These computations can be speed up using a transposition table which will store the situations encountered and the best moves for each:

.. code:: python

tt = TT()
GameOfBones.ttentry = lambda game : game.pile # key for the table
r,d,m = id_solve(GameOfBones, range(2,20), win_score=100, tt=tt)

After these lines are run the variable tt contains a transposition table storing the possible situations (here, the possible sizes of the pile) and the optimal moves to perform. With tt you can play perfectly without thinking: ::

.. code:: python game = GameOfBones( [ AI_Player( tt ), Human_Player() ] ) game.play() # you will always lose this game :)

Contribute !

EasyAI is an open source software originally written by Zulko_ and released under the MIT licence. It could do with some improvements, so if your are a Python/AI guru maybe you can contribute through Github_ . Some ideas: AI algos for incomplete information games, better game solving strategies, (efficient) use of databases to store moves, AI algorithms using parallelisation.

For troubleshooting and bug reports, the best for now is to ask on Github_.

.. _here: http://zulko.github.io/easyAI .. _Wikipedia: http://en.wikipedia.org/wiki/Negamax .. _Zulko : https://github.com/Zulko .. _JohnAD : https://github.com/JohnAD .. _Github : https://github.com/Zulko/easyAI

Maintainers

  • Zulko_ (owner)
  • JohnAD_
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].