bbuecherl / tictac2 Goto Github PK
View Code? Open in Web Editor NEWTic-Tac-Toe Android Game Project
Tic-Tac-Toe Android Game Project
I would like to remove the PauseActivity (currently not implemented) and use alert dialogs instead, they would show up, when playing and pressing back or home buttons.
They would ask the user to either perform the action, or return back to the game.
Current navigation is crashing very often, lacking responsibility and should be more bidirectional, this has to be changed fast.
I discovered a bug in the game model, thats telling me game is over, but i could win with my last mark.
Reproduce: me (blue) starts playing, bot (green) is always second. Play like:
1 2 2
0 0 1
1 0 2
then set last row and mid for:
1 2 2
0 0 1
1 1 2
(hope that) the bot will take mid point:
1 2 2
0 2 1
1 1 2
now i receive getGameRunning() as false, no winner and game is finished.
but me (blue) could win.
Ok, in our backlog, we included a sound feature, its already added to options (sound on/off). My issue is, what sounds do you want to use and on what actions?
Or do you want to add more/less ? @TuttiRH @gherndl @benjaminaaron
The
while working on my smartBotV2[#17] i've encountered a bug within our game parameters.
Try to play a 4x4/5x5/6x6 with win length 3..., if both players play intelligent, the starting one will always win:
0 0 0 0
0 1 2 0
0 0 0 0
0 0 0 0
=>
0 0 0 0
0 1 2 0
0 1 0 0
0 2 0 0
=>
0 1 0 0
0 1 2 0
0 1 0 0
0 2 0 0
=> we have to think about the parameter logic once more
While the tube & wanderField concept is nice I think it would be more elegant to equip each field with the ability to check if it has the same value as one of its neighbors and thus decentralize the winChecking to a deeper level into the architecture (encapsulation).
This might also come I handy for other types of bot intelligence then brute force over all possible moves. An array of "islands" (like chains of 2 or 3 where winLength is 4) for instance that the bot might choose to build out further.
From self-building fields to the Integer-array representation already in use in the two smartBots -> much less code and more performant.
Requires #22 to be fixed.
I will add some device dependent responive layout for version 2.0.
A simple version of smartBot has to work for the first release...
First of all, i thought about how i play TicTacToe.
On a 3x3 I will either start on center or on one of the edges. Why? Because they have the highest possibility of a win arrays...
I do this by counting all possible win arrays of an field:
3 2 3
2 4 2
3 2 3
This start "decision" grid (i will call them "predecision" grids later on) is depending on board size and win length (not on marks per turn).
With our features (Size 3x3-6x6, win length 3-6) we result in 10 predecision grids.
They can be easily stored in the code.
If its the smart bots (1) (furthur refered to as [1]) starts, he will simply set his mark on the "highest" value of the predecision grid.
0 0 0
0 1 0
0 0 0
Now its the other (in my example a human (2) furthur refered to as [2]) players turn: Let me just start like this:
0 0 0
2 1 0
0 0 0
Now the [1] has to recalculate his decision grid. for this second turn, he will simply modify the predecision grid:
3 2 3 4 2 3
2 4 2 => 0 4 1
3 2 3 4 2 3
The grid is changed by these rules:
a. The fields he already marked won't change.
b. The fields the other player marked this round will be set to 0
c. All values of fields affected (inside win array) by the fields marked this round by the other player will increment by 1. (Except it is blocked like in d.)
d. All values of fields affected by two fields marked (one of them this round) by the other player are doubled (e.g. marked Field[1][0],Field[0][2] -> affected: Field[1][2]) Except one of the bots marks already blocks one of the other ones marks (in the example: Bot has a mark at Field[1][1] blocking Field[1][0] from Field[1][2])
e. All values of fields affected directly by fields marked (one of them this round) by the other player will be set to 1000 (e.g. marked 2 2 0
in one row/column/diag)
f. All values of fields affected by two fields marked by the bot (one of them this round) will be tribbled. Except one ot the other players marks block one of the marks (like d.)
g. All values of fields affected directly by fields marked (one of them this round) by the bot will be set to 2000 (like e.)
h. The fields that lost a win length, by beeing blocked by [1] and [2] (in our example this is Field[1][2].
Now [1] will choose the field with the highest value again, if there are more than one possibilities, he will randomly deside.
0 0 0
2 1 0
1 0 0
[2]'s turn, he realises that he will lose, so he blocks:
0 0 2
2 1 0
1 0 0
[1] will refactor the decisiongrid again:
4 2 3 5 3 0
0 4 1 => 0 4 2
4 2 3 4 2 7
now he decides and marks again:
0 0 2
2 1 0
1 0 1
[2] realises that he has lost, he blocks the most obvious:
0 0 2
2 1 0
1 2 1
[1] recalculates the decision tree:
5 3 0 2000 2 0
0 4 2 => 0 4 2
4 2 7 4 0 7
and marks:
1 0 2
2 1 0
1 2 1
SmartBot won.
I hope i did not make a mistake anywhere in the examples.
Feedback appreciated. (Especially for the rules)
I already created the predicision trees.
Would be nice to remove the System.out.println statement (will only show up on the debug console in eclipse) and replace them with either enums, integer or boolean return values. Furthermore we could use Exceptions for error handling.
Android will shut down the process, because it takes to long to calculate, this could be solved by threading it inside async tasks, but we will not fix this till our release tonight..
Adding feature of quick mode - when player doesn't place his mark within a given time his mark will be placed randomly.
@bbuecherl can you add a checkbox for that in the options and a slider for the time interval in the menu where also sound/vibration is?
Including the Google Play Services, implementing a controller for them, adding online multiplayer, ranks and achievements.
i would like to implement a gif generator, which is recording every step in the game, and which will be saved at the end of the game. Now you can either save &share it right from the "game over"-alert, save it, or if he dismisses, it will be deleted.
It will saved to the external storage of his device.
I will add a "Replay" Button to the MenuActivity, where all his saved replays are listed. He will be able to review them and share them (again).
I think we can remove GameInterface, because the views & controllers only use the direct Game object reference.
We have to add java docs to every method/class/constructor and generate a doc folder for simpler reference
I'm thinking about adding an interface for creating custom marks, which enables player to draw rectangles, lines and circles in different colors and use them for playing, they will be stored as JSONArrays locally and will be used online by automatically sending this code over network.
Maybe i will add customize options for GUI elements too.
int[] testBoardArr = {1,2,0,1,0,0,1,2,0,1,2,3,0,0,2,0};
System.out.println(BoardParser.testBoardForWinner(testBoardArr, 4, 4));
Returns 1 as winner, even so 1 has only three in a chain yet.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.