Skip to content

A Strategy Turn-Based Game as a platform to develop better SLG AI.

Notifications You must be signed in to change notification settings

Animadversio/PythonSLG

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python SLG

It is a strategy turn based game, inspired by code in PythonStrategyRPG, game mechanism is inspired by Ancient Empire II

  • use AStar algorithm to walk
  • support melee and remote creature
  • use json file to store level data (e.g. position of creatures, map info)

Requirement

  • Python 3.7
  • Python-Pygame 1.9

How To Start Game

$ python main.py

How to Play

  • Use mouse or 4 direction arrows to move cursor, double click space or enter to select the active units, then to move, attack or use magic
  • DClick the HQ to purchase units.
  • Press Tab to end turn.
  • Press 1,2 to select action.

Features

Game System

  • Unit with AOE magic. Remote and melee unit. Far reaching siege unit.
  • Purchasing unit from HeadQuarter or Castle.

Policy

Advanced policy for planning multiple unit action coordination is a crucial part of this project. The following policies have been implemented.

  • Greedy one step reward maximization policy.
  • Greedy one step reward maximization, with heuristics
    • position maximize threat posing on others
    • Position minimize danger posed by opponent units.
    • Attack unit that eliminate the most threat posed by it.
  • Dynamic threat estimation by employing greedy policy on the opponent and find the maximal damage they can do.

Working in Progress

  • Path finding and attack finding. @Oct.8
  • Simple UI and control loop Demo. @Oct.9
  • Add attack and counter attack computation. @Oct.10
  • HP display in text @Oct.10
  • Unit die and pop out of list @Oct.10
  • Enemy unit inpassable @Oct.10
  • Cancel selection. @Oct.10
  • CounterAttack criterion @Oct.10
  • Start More Unit Numerical design @Oct.10
  • Wrap up the Game loop with a class! @Oct.10
  • Recursive Successor function call. @Oct.10
  • Implement Baseline random legal action policy, trajectory sampling. @Oct.10
  • DFS List all strategy in one Turn(not good) @Oct.11
  • Deep copy for game state method. @Oct.10
  • Primitive Reward or Evaluation Function for State x Action pair. @Oct.11
  • New Baseline, Greedy policy (in the space of Select+Move+Attack Maximize single step reward) @Oct.11
  • Video Playback, or playing action sequence on the screen passively. @Oct.11
  • Recursive or MiniMax Quality definition! Threat Elimination Strategy @Oct.12
  • Add unit, StoneMan, StormSummoner @Oct.12
  • Debug Cannot stay in same location problem @Oct.12
  • Ability and Buff design, StormSummoner. IMplement AOE attack! @Oct.12
  • Speed up by disable legality check! or decrease the move range computation. @Oct.12
  • Updata GUI loop to support Action selection @Oct.12
  • New GUI display for AOE ability! @Oct.12
  • Debug the AOE attack random die. @Oct.13
  • Scalable Approximate Threat Elimination Algor @Oct.13
  • Search Tree recursion 2-3 levels for Threat Elimination algorithm @Oct.13
  • debug negative harm affect positively @Oct.13
  • Utility function, computing combat info, computing attack coverage, and Mov Attack pair... @Oct.14
  • Danger of tile calculation add this to heuristic. @Oct.14
  • Risk aversion greedy policy, alpha to trade off risk and reward. @Oct.14
    • Many interesting behavior emerged from this change! Very well done.
    • Still, it doesn't estimate the potential benefit (2nd order gain) of that position...
    • This is a first order estimate of next enemy turn lost, but no 2nd order estimate of gain in the next turn..
  • Simple estimation of threat posing on others, and Maximize threat on others, minimize threat posed on me. @Oct.15
  • Efficiency increase by improving the deep clone unit and game state, improve attack range computation by not saving the set. @Oct.15
  • Debug the negative threat elimin value problem @Oct.15
  • Debug the negative risk problem @Oct.15
  • Debug the reward calculation negative problem.... @Oct.15
  • Debug the overkill over reward problem @Oct.15
  • Add more printing interface @oCT.15
  • Increase efficiency by approximating greedy policy and merging movement and attack planning! @Oct.17-18
    • This change is SO EFFECTIVE that planning time is lower than .5 sec for each side now!
    • Implement approximate fast search for AOE as well!
  • Economy and Unit purchase design.
    • Add building castle system.
    • Add income and funding
    • Add buying action
  • Make it compatible with previous policies, test the game with unit purchasing with the search based AIs. @Dec.3 @Nov.28
  • Let AI and human play together or AI with different parameters play and compete.
  • Considering buying in threat computation. (adding it to the oppopolicy) @Dec.4
  • Change the Risk evaluation @Dec.4
  • Add attraction to enemy to avoid being too defensive
    • Actually this should be a function of the overall strategy, advance or retreat or focus on certain nodes.
  • Build in HQ attraction for enemy strategy as well. (which will induce defence for this in threat elimination part.) @Dec.4
  • Strategy to save the HQ of both sides. (Add in threat value for occupying HQ, and thrat elim will work) @Dec.4
  • Speed up the threat computation! And debug the threat value. @Dec.4
    • Player AI begins to use body walls to defend the others.
  • Note for an action sequence, there are some single move evaluation function and some final evaluation function. Combine the two into a single final evaluation will make the thing inefficient. Since some evaluation are determined in the middle of the sequence instead of the end of it. Thus evaluate at the parent node part will save computation.
  • Self play parameter optimization! Semi-Genetic Algorithm @Dec.4
  • Make unit value learnable
  • Save some event list for offline learning purpose!
  • Change the DFS part to more efficient
  • Prune the main search to limit to trunk of action sequences.
  • Make large scale self play possible.
  • Add the Monte Carlo Tree Search to the game
  • Learning based Value or Q evaluation, by self play and offline learning.
  • Occupy and Factory and barrack.
  • Prune Search tree, making it less expansion! Discard useless moves soon.
  • Optimize efficiency of the copy of unit
  • Pre compute a match table to save computation.
  • Ability and Buff design, Heal
  • Ability and Buff design, Summon?
  • Ability and Buff design, Attack Aura, Defence Aura?
  • Ability and Buff design, Berserker, Attack + Def + as HP - ?

About

A Strategy Turn-Based Game as a platform to develop better SLG AI.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%