Recent Forum Posts

Looking for something?

Don't see a match? Post to the community

From categories:
page »

Sorry for the double post, but its been 8 hours and I fee this is relativey different in content compared to my last post.

I am not good at combinatorics, but according to this website, there are 255,168 possible games. If you consider that I do not have to store any of the boards that win after 5 moves, it helps. I also dont have to store any of the boards after 6 moves, but I do at 7. But again not at 8, or 9.

In total I have to store all the boards with 1,3,5,or 7 moves which do not contain a winning sequence. I may not be good enough at math to calculate the exact number, but I know it is a lot

With rotations it would be 774, but if menace went first it would be 304.

I agree strings might be easiest for that. However, the caclulator obviously has limited memory. There are many thousands of boards that can be possible, so I have to find some way to compress it.

I think that while I try and figure out a way to handle the memory I might build a different version of an AI that uses hardcoded logic:

Each square is an input
Each square is an output
Inputs can be 0,-1, or 1.
The AI peices are -1
If an input is not 0, that input cannot be used for an output
If a single row column or diagonal sums to 2, play the empty spot
If more than one row column or diagonal sums to 2, resign
If a row column or diagonal sums to -2, play the empty spot

I think a version without mirroring would be much easier (I got very confuzzled when I tried to implement mirroring right away) because you have much less boards to check for. As for checking the game state, a matrice sounds like it will work, but for rewarding/punishing MENACE, strings would probably be easiest to implement.


How did you download 2.43? I tried installing the very first OS before, and I keep getting an error. I can't install any OS 2.53MP or lower onto my 84+.

(Anyways, I am not using the best mobile device to post this, My 3ds xl is kind of slow in the Internet Browser.)

HaXIgwj.png Bio_Hazard1282

I finished the basic naughts and crosses engine last night, as well as created a partial probability algorithm (I will post the algorithm to the routines page later, as it could be useful in other places).

As of this point I have a very basic AI going, which randomly chooses a position and plays it. This means I created the playing interface for the AI, and am able to start building the logic. However, I would like opinions of which version of menace to implement: With mirroring/rotation, or without mirroring. I for some reason believe that without mirroring would be easier to implement, but am not sure.

X _ _    is different than  _ _ X
_ O _                       _ O _
_ _ _                       _ _ _

X _ _    is the same as   _ _ X  and  _ _ _
_ O _                     _ O _       _ O _
_ _ _                     _ _ _       _ _ X

I would also like suggestions on how to implement the memory for storing each gameboard. The only criteria is that it must be a list of 9 numbers which correspond to the places on the board. I can convert lists to strings, but my thought was a matrix for each move. This would only require 4 matricies. Each matrix would correspond to a turn that MENACE makes. [G] would contain gameboard states for menaces 1st move, where each line represents a gameboard state. -1 would be used to indicate a position which has already been played. This would mean that [G] would look something like this, with the 0's being the partial probability of each layout after the first move. I can then use my list of moves which have been played to determine which line of the matrix is the current gameboard. I could then load that row into the probability list, make the selection and repeat. However, There are thousands of different gameboards that could be played, so i might have to narrow it to a subset based on the moves already played
-1 0 0 0 0 0 0 0 0
0 -1 0 0 0 0 0 0 0
0 0 -1 0 0 0 0 0 0
0 0 0 -1 0 0 0 0 0
0 0 0 0 -1 0 0 0 0
0 0 0 0 0 -1 0 0 0
0 0 0 0 0 0 0 -1 0
0 0 0 0 0 0 0 0 -1

I'm updating this thread with what I have found if anyone is still looking at this.

I found that if I run the above program and then type Ans into a new program and run it, it will crash. However, if I type any commands after Ans it will not crash.

Once again if anyone knows anything about this bug, I'd really like to know.

Note: this only happens on 2.53MP and 2.55MP while using Mathprint.

True, but logBASE( is only available on the 84+SE with OS 2.53 MP or higher

For the 83+ you would have to use ln(

Re: Addition without Addition by TrenlyTrenly, 17 Jun 2018 04:06

Use a logarithm with a smaller base:

You could theoretically lower the base further to just bigger than 1 for a wider range though at that point I'd imagine you'd run into accuracy problems.

The solution to a complex problem is often a simple answer.

Re: Addition without Addition by kg583kg583, 17 Jun 2018 03:48

It's not meant to be that hard, but I'd like to encourage the community to put forth more exercises like these.

How would you modify the code to handle the 99+99 case?

Timothy Foster - @tfAuroratide - Go here if you're nerdy like me

I feel like this was supposed to be more difficult:

The solution to a complex problem is often a simple answer.

Re: Addition without Addition by kg583kg583, 17 Jun 2018 03:04

I forgot about the sum command ( :

Now try it without that.

EDIT: Also without cumSum, because that's basically the same thing.

Timothy Foster - @tfAuroratide - Go here if you're nerdy like me

Re: Addition without Addition by TrenlyTrenly, 17 Jun 2018 02:57

Here's a code golf challenge to poke ya'll brains a little. The goal is to write the smallest program possible that accomplishes the goal. There's no prize; it's just a fun exercise!

Write a program that adds two integers together without the use of +, -, sum, or cumSum.

  • The program may not use the + or - operators.
  • The program may not use the sum command or cumSum command.
  • Assume the first line of your program is :Prompt A,B
  • A and B are both integers whose absolute values are no more than 99
  • You may assume A and B are strictly positive

For a bonus challenge, try writing the same program, except this time A and B are not restricted to the set of positive integers, meaning negative values are allowed.

Timothy Foster - @tfAuroratide - Go here if you're nerdy like me

I like the idea of the primes, but instead of using a list I might use a string. Since I use P as a placeholder variable I can use sub and expr. I’m not sure how to fully implement it, but I will give it a try.

I now have a list of the moves and a corresponding list of primes. Now I just have to figure out how to check for the win conditions.


Edit: Does this look right?

Returns 1 if divisible by any elements in the list, Returns 0 if not

I've watched a video on MENACE being implemented for real. In this scenario, I'd say the best option is still to put the board list into a matrix for the victory check; it would be decently fast for such a small list, and you'd only have to do a victory check after 5 total moves.

For the Timothy's prime idea, it would also be fairly easy to simply have the list converted. Store it as you would, 1-9, then using a list of the first 9 primes convert the list to primes whenever you perform the check. Perhaps even faster than the matrix implementation.

The solution to a complex problem is often a simple answer.

I remember watching a video about MENACE. It's pretty cool.

Are you able to have a secondary list which contains the first 9 primes, and then use your storage list as indices to the prime list?

Timothy Foster - @tfAuroratide - Go here if you're nerdy like me

I am trying to recreate M.E.N.A.C.E. (Machine Educable Naughts And Crosses Engine) on the TI-83/84/+. So far I have the display, and player inputs created. Now I have to finish building the AI. But before I do so I wanted to be able to check the win conditions. I am not using a matrix to do this because the AI requires a list of the moves played to properly function. I have considered using a second list and copying over all the even elements, checking if it contains any of the combinations, then checking the odd elements. However that seems to be a bit of a brute force algorithm, and I was hoping someone would know of a way to do this without using brute force.

While I could change the system to use all prime numbers, since it is displayed on the graphscreen I am using relative coordinates to output the naughts, crosses, and the selected box indicator. This would be extremely time consuming, and would make the code a fair bit longer.

A bit more on the AI, which is partially started: The AI uses a “choice” wherein each event starts equally likely. As the AI learns, the probabilities change. The AI starts with a list which corresponds to the gameboards current state. This list contains the partial probabilites of each play. It then selects one of these at random based on the partial probabilities. If the AI wins, the moves it played each get +3 partial prob. A tie is +1, and a loss is -1.

Explanation of partial probability list:
List corresponds to gameboard: 1,2,3,4,5,6,7,8,9
1 2 3
4 5 6
7 8 9

If the board is:
X _ O
_ _ O

And the list is 0,4,0,0,0,23,2,5,0
4/34 chance of spot 2
23/34 chance of spot 6
2/34 chance of spot 7
5/34 chance of spot 8

If the list happens to be: 0,0,0,0,0,0,0,0,0 the AI will resign as it believes it cannot win

Ha! My first thought was to use primes as well!

I made a new routine page for finding sublist permutations and combinations. You'd probably have to implement the routines with a bit of variation to match your specific goal, Trenly, but they'd work.

The solution to a complex problem is often a simple answer.

If you are not locked to using 1-9, you can accomplish some shortcuts using prime numbers instead. Imagine a grid as follows:

 2  3  5
 7 11 13
17 19 23

Each row, column, and diagonal can now be represented as a multiplication of the respective primes. So the first row is "30", the first column is "238", and so forth. We now have 8 numbers, each of which is unique because their prime factorizations are unique.

When you multiply all the X slots together, you get some number. If that number is divisible by any of the 8 numbers in our magic list, then a row, column, or diagonal has been formed.

Timothy Foster - @tfAuroratide - Go here if you're nerdy like me

I've been trying some stuff out and it does seem as though this is method of testing Tic-Tac-Toe victory. If that is the case, then I'd just use a matrix + Matr▶list( for testing (if I recall correctly this is what I used for my implementation of it).

I'll keep working on the problem though as a general programming technique. Might be able to make a routine for testing permutations in the process.

The solution to a complex problem is often a simple answer.

page »