Create a List of Positions
Hi!
One lesson I've been looking at creating is coding the agent to create and play TicTacToe. At the heart of it, I thought you could call the Agent in front of you, face a specific direction (let's say South). He could then dig out a TicTacToe area of 3x3, and add each of these Positions to a List as they are dug. That List would then be used to randomly pick a Position to place a block of some type, and eventually check blocks to see if someone won. The issue: I cannot seem to make a List of Positions. Pasted below is a simple attempt at a list, typed to hold Position, but I get an error about the type. If I do not give the list a type, I still get an error. Ideas about how to make a list of Positions? Thanks!
-
places = []start: Position = NonenextPlace: Position = None
agent.teleport(pos(0, 0, 1), SOUTH)start = agent.get_position()for x in range(3):agent.move(FORWARD, 1)nextPlace = agent.get_position()places.append(nextPlace)player.say(places)0 -
(That code DOES work, not sure why but happy and sharing.)
0 -
Good to know that you wrestled that code to the ground and made it conform! sometimes I feel like I have to do some serious cattle wrestling to get my code to do what I wanted to do but in the end I win. lol
So in terms of the user experience what you're wanting them to do is select a spot for their tic tac toe choice right? and then a block would be placed there. So the player would play against the agent essentially. It seems that you would want a vertical board rather than a horizontal board. It might be easiest if the blocks were numbered, and then when the players were choosing a location to put their tic tac toe on, they could just say I'm putting my block on block 3. does that make sense? just my random brainstorming ideas. I'd love to know how this idea works out! come back and let us know. Happy coding!0
Please sign in to leave a comment.
Comments
3 comments