Giter VIP home page Giter VIP logo

auto-cca's Introduction

CI

Graphics are Copyright GMT Games, copied from the Vassal CC:A module

This work is intended exclusively for education and learning about game-playing AI.

I presented this work in progress at Codemotion Milano 2023; here are the slides.

The story of this repo so far

2023-11-27

Implemented the deck. Now we randomize the players' hands.

The MCTS AI has been set aside for the moment; AI is played by the Greedy player.

BUG: it does not reshuffle the deck when the talon is empty!!!

2023-11-25

When I presented at Codemotion, the MCTS-based AI was weak due to two factors:

  • choosing one unit at a time, ie simple moves were not grouped in macromoves
  • using closed loop instead of OpenLoop

Then I implemented Macromoves. This has substantially improved the MCTS AI, but I then realized that closed loop only works when the card distribution is fixed and unchanging, as it is now. This is a simplification over the real game that I initially implemented to get the AI implementation going. I now see that when we implement randomized hands, the closed loop implementation cannot work anymore.

I then implemented OpenLoopMctsPlayer; it works, but

  1. it does not have macromoves
  2. it is much slower than the original closed loop implementation

One way to address 2 is to implement the Flyweight pattern for all commands, which is a large refactoring that I have started but not completed.

How to

Serve locally with make server or python -m http.server

Run tests with make test (you should npm install jest first).
You may run a single test suite with script/test.sh src/whatever.test.js

Play the game with make open. Notice the "End phase" and "AI continue" buttons, you will need to click them at appropriate times to get the game to proceed. Also, keep an AI on the status text on top of the page: it tells you which phase the game is in.

Open your browser's developer tools to read the AI logs.

Configure the AI parameters in file src/config.js.

In the main scenario (Akragas), you play the Syracusan (bottom) while the MCTS AI plays the Carthaginian (top).

The Playout button pits the MCTS AI (bottom) against a greedy player (top). You can speed up or slow down the moves with the delay value in the textbox.

See a visualization of the search tree with make tree. You can tweak the parameters to change the level of detail you want, however be mindful that the more nodes you show, the longer it takes for the image to appear. The parameters are:

  • scenario: the key of the scenario to run
  • depth: how many levels of the tree to show (don't set it too high or it will take forever to get a picture)
  • threshold: the minimum number of visits below which we don't show a node
  • prune n: for the first n nodes in the tree, we only show the main line, not showing other subtrees
  • iterations, playouts: configure AI parameters

WIP

  • use OpenLoop in MCTS: reimplement best commands
  • implement MAP_CENTER and MAP_EAST

AI TESTS

  • Early game
    • The AI should advance compactly -- no weird backward movements
    • The AI should use all units -- not just the light ones
  • 2on2 Melee
    • should advance compactly
    • should choose attacking a weak unit over a strong one
    • should order combat to maximize potential dice
  • 1to1 Melee
    • light unit to avoid close combat
    • light unit to keep pestering the heavy with bows

TODO AI

  • macro-move sampling: avoid duplicate macro-moves in a node's children
  • macro-move sampling: make units not moving an option
  • macro-move sampling: tune the explore/exploit ratio
  • open loop instead of chance nodes
  • implement evasion, to allow the expected game strategy to emerge
  • make end phase automatic

TODO RULES

  • more cards
  • cavalry bonus movement
  • cavalry, chariot bonus combat
  • leaders
  • terrain
  • "if you don't have any X unit, order a unit of your choice"
  • heavy chariot battles back with 3 dice not 4
  • heavy chariot ignores one sword result
  • warriors, elephants, other units

auto-cca's People

Contributors

xpmatteo avatar xpmatteo-tw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

auto-cca's Issues

Amazing work!

Hi, I'm thinking of implementing some parts of Commands & Colors Ancients as a hobby project in React JS. Probably it will be some simple interactive Tutorial, not a full fledged game, with focus on visuals. By searching on github I found you're repo, truly amazing work! Would it be ok if I use parts of your code if I mention your project in the credits?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.