Play my version here. My slightly improved AI are the pink, green and lime player.
This is a modification of the game Dice Wars from gamedesign.jp. I have added the ability to have multiple types of AI so I could try to create my own AI for the game.
Once you have cloned the repository or downloaded the files, simply navigate to
file:///Drive:/the/directory/you/cloned/it/to/index.html in any web browser on your computer (For instance,
Make Your Own AI
Go to line 42 where the array
this.aiis defined. Change one of the numbers in the array to a unique identifier of your choice. The first player is always the human player, so leave it at -1. In the game the player order is always shuffled, but the AI types will always correspond to the same color. In order, including the human player, the colors are purple, lime, green, pink, orange, cyan, yellow, and red. It may be useful to set your ai as the second player so you can play against it in a two player game.
Go to line 449 where
this.com_thinkingis defined. Add a new case using your unique identifier from step 1, and have it return a function that you will define in step 3. Look at the other cases for guidance.
Create your function somewhere after the definition of
this.com_thinking. Look at
this.com_defensivefor techniques to analyze the environment.
- To declare an attack, set
this.area_fromto the id of the attacking region and
this.area_toto the defending region's id (do not return). Once you have no good moves left, end the player's turn by returning 0.
this.adatis the array of regions.
this.adat[i].armis the id of the player who owns the region, and
this.get_pn()returns the id of the player whose turn it is.
this.adat[i].diceis the number of dice the region has
this.adat[i].join[j]is true (1) when region
iis adjacent to region
jand false (0) otherwise.
If you make a cool new AI, let me know!
I plan to make a version of the game that just plays the AI against themselves quickly so you can get statstics on how well each AI performs. It would also be nice break each AI out into it's own file.